diff --git a/.github/workflows/code_quality.yml b/.github/workflows/code_quality.yml new file mode 100644 index 00000000000..65f350e1b53 --- /dev/null +++ b/.github/workflows/code_quality.yml @@ -0,0 +1,25 @@ +name: Qodana +on: + schedule: + - cron: "0 20 * * *" + workflow_dispatch: + branches: + - develop +# push: +# branches: +# - develop + +jobs: + qodana: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + #php-version: '7.1' + - name: 'Qodana Scan' + uses: JetBrains/qodana-action@v2022.3.0 + #with: + # php-version: '7.1' + env: + QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/doxygen-gh-pages.yml.disabled b/.github/workflows/doxygen-gh-pages.yml.disabled new file mode 100644 index 00000000000..33dd47aa6e6 --- /dev/null +++ b/.github/workflows/doxygen-gh-pages.yml.disabled @@ -0,0 +1,38 @@ +# See syntax file on https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions +name: Doxygen +on: + schedule: + - cron: "0 15 * * *" + workflow_dispatch: + branches: + - develop +permissions: + contents: write + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Build + uses: DenverCoder1/doxygen-github-pages-action@v1.2.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: gh-pages + folder: build/html + config_file: build/doxygen/dolibarr-doxygen.doxyfile + +# - name: Deploy +# uses: JamesIves/github-pages-deploy-action@v4 +# with: +# branch: gh-pages +# folder: build/html # The folder the action should deploy. +# target-folder: docs/html2 + +#jobs: +# doxygen: +# runs-on: ubuntu-latest +# steps: +# - name: 'Doxygen' +# uses: mattnotmitt/doxygen-action@1.9.5 +# with: +# doxyfile-path: build/doxygen diff --git a/.github/workflows/exakat.yml b/.github/workflows/exakat.yml.disabled similarity index 93% rename from .github/workflows/exakat.yml rename to .github/workflows/exakat.yml.disabled index 528626e0308..1e9121a0e00 100644 --- a/.github/workflows/exakat.yml +++ b/.github/workflows/exakat.yml.disabled @@ -4,6 +4,9 @@ name: "Exakat analysis" on: schedule: - cron: "0 20 * * *" + workflow_dispatch: + branches: + - develop permissions: contents: read @@ -13,6 +16,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + with: + fetch-depth: 1 - name: Exakat uses: docker://exakat/exakat-ga with: diff --git a/.github/workflows/stale-issues-safe.yml b/.github/workflows/stale-issues-safe.yml index 4ac9fa8f5b9..af04675d48d 100644 --- a/.github/workflows/stale-issues-safe.yml +++ b/.github/workflows/stale-issues-safe.yml @@ -6,7 +6,8 @@ on: - cron: "0 21 * * *" issue_comment: types: [created] - + workflow_dispatch: + permissions: {} # none jobs: diff --git a/.gitignore b/.gitignore index 55a4c417ce7..e9603bd2d8f 100644 --- a/.gitignore +++ b/.gitignore @@ -14,7 +14,6 @@ default.properties /.pydevproject /.vscode .DS_Store -.idea *.iml *.orig Thumbs.db diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 00000000000..52e0bf0ae03 --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/ChangeLog b/ChangeLog index f09ea530dd8..1a3e96b18ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,11 +5,15 @@ English Dolibarr ChangeLog ***** ChangeLog for 18.0.0 compared to 17.0.0 ***** +NEW: PHP 8.2 compatibility: + + WARNING: Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: -* The deprecated method escapeunderscore() of database handlers has been removed. You must use escapeforlike instead. - +* The deprecated method "escapeunderscore()" of database handlers has been removed. You must use "escapeforlike()" instead. +* The method "nb_expedition()" has been renamed into "countNbOfShipments()" +* Revert default type of hooks. Default is now 'addreplace' hooks (and exception become 'output' hooks, that become deprecated). @@ -21,7 +25,7 @@ For users: NEW: Minimal PHP version is now PHP 7.0 instead of PHP 5.6 NEW: #21780 Add pid field to Cronjob class and store PID on job execution NEW: #19680 Add option PRODUCT_ALLOW_EXTERNAL_DOWNLOAD to automatically have uploaded files shared publicly by a link -NEW: #20650 can move the checkbox column on left (experimental option) +NEW: #20650 can move the checkbox column on left (experimental option MAIN_CHECKBOX_LEFT_COLUMN) NEW: #21000 Added columns 'alias_name' on project, supplier invoice, supplier order, supplier proposals and task list NEW: #21395 Added option for dark theme mode in display - color and theme NEW: #21397 added option to auto define barcode numbers for third-parties in barcode module setup @@ -96,18 +100,18 @@ NEW: can sort and preselected best supplier price NEW: Can use products categories to make inventory NEW: Change filter type on tickets list into a multiselect combo NEW: conf TIMESPENT_ALWAYS_UPDATE_THM, when it's on we always check current thm of user to update it in task time line -NEW: constant PROPAL_NEW_AS_SIGNED NEW: show date delivery planned on orders linked to company and product NEW: Default values in extrafields are not more limited to 255 char. NEW: display currency in takepos menu NEW: Enable online signature for interventions NEW: Encrypt all sensitive constants in llx_const -NEW: extrafield price with currency NEW: filter on reception dates (from / to) in cheque paiement card NEW: Contracts: Default template of contract is not mandatory NEW: Contracts: Manage Position (Rank) on Contract Lines NEW: EMail-Collector: add IMAP port setting NEW: EMail-Collector: add a button "Test collect" +NEW: Extrafields: field price with currency +NEW: Extrafields: support IP type in extrafields NEW: Members: default_lang for members NEW: Members: Table of membership types NEW: Members: add free membership amounts at the membership type level @@ -127,21 +131,17 @@ NEW: Website: can switch status of website and page from the website toolbar NEW: Website: Templates of websites are now directories and not zip into core repo NEW: Website: add 4 other templates in website module NEW: If we select another view list mode, we keep it -NEW: Init module bookcal NEW: Introduce dolEncrypt and dolDecrypt to be able to encrypt data in db NEW: Invoice - Add french mention on pdf when vat debit option is on NEW: invoice export : add accounting affectation NEW: label on products categories filter NEW: The link "add to bookmark" is always on top in the bookmark popup -NEW: MAIN_SEARCH_CATEGORY_PRODUCT_ON_LISTS const to show category customer filter NEW: Make module WebservicesClient deprecated. Use module WebHook instead. NEW: manage no email with thirdparties (better for GDPR) NEW: Manage VAT on all lines on purchases cycle NEW: manage virtual stock at a future date NEW: On a bank reconciled line, we can modify the bank receipt NEW: On a form to send an email, we show all emails of all contacts of object -NEW: Option PRODUCTBATCH_SHOW_WAREHOUSE_ON_SHIPMENT showing wh on PDF -NEW: Option PRODUIT_DESC_IN_FORM accept (desktop only or +smartphone) NEW: Page for mass stock transfer can be used with no source stock NEW: parent company column and filter in invoice and order list NEW: Add show "Sales rep" option for PDF @@ -165,22 +165,28 @@ NEW: show product label on inventory NEW: show sell-by and eat-by dates only if not empty NEW: show SellBy/EatBy dates for each batch product in shipment card NEW: skip accept/refuse process for proposals (option PROPAL_SKIP_ACCEPT_REFUSE) -NEW: SMTP using oauth2 authentication +NEW: experimental SMTP using PhpImap allowing OAuth2 authentication (need to add option MAIN_IMAP_USE_PHPIMAP) NEW: can substitue project title in mail template NEW: Supplier order list - Add column private and public note -NEW: Support IP type in extrafields NEW: The purge of files can purge only if older than a number of seconds NEW: Update ActionComm type_code on email message ticket NEW: VAT - Admin - Add information on deadline day for submission of VAT declaration NEW: expand/collapse permissions on user permission page NEW: Add the target to select attendees of event for emailings + Option / Const for System: +NEW: Option PRODUCTBATCH_SHOW_WAREHOUSE_ON_SHIPMENT showing warehouse on PDF +NEW: Option PRODUIT_DESC_IN_FORM accept (desktop only or +smartphone) +NEW: MAIN_SEARCH_CATEGORY_PRODUCT_ON_LISTS const to show category customer filter +NEW: constant PROPAL_NEW_AS_SIGNED + Localisation: NEW: adding JAPAN Chart-of-Account and regions/departments NEW: adding NIF verification for Algeria Modules NEW: Experimental module Asset +NEW: Init module bookcal For developers or integrators: @@ -190,20 +196,26 @@ NEW: ModuleBuilder can generate code of class from an existing SQL table NEW: #20912 Add trigger to record the event of sending an email from a project NEW: #21750 Added "Get lines and Post lines from BOM" at the REST Service NEW: #22370 Modulebuilder supports 'alwayseditable' (like extrafields) -NEW: Removed completely the need for the library adodbtime -NEW: hook on agenda pages -NEW: hook to complete payment in TakePOS -NEW: hook "changeHelpURL" to modify target of the help button -NEW: hook formConfirm on action comm card -NEW: hook to modify supplier product html select -NEW: Add new hook for show virtual stock details on product stock card -NEW: Add new hooks for actioncomm NEW: conf->global->SYSLOG_FILE_ONEPERSESSION accept a string -NEW: translate for contact type API, setup/ticket API, shipping method API NEW: All ajax pages have now a top_httphead() -NEW: support multilang in Civilities API + + API: NEW: Add API for the partnership module NEW: Add "Get lines and Post lines from BOM" in the API +NEW: translate for contact type API, setup/ticket API, shipping method API +NEW: support multilang in Civilities API + + Hooks: +NEW: Actioncomm - add new hooks for actioncomm +NEW: Actioncomm - hook formConfirm on action comm card +NEW: Agenda - hook on agenda pages +NEW: Help - hook "changeHelpURL" to modify target of the help button +NEW: Product - add hook to show virtual stock details on product stock card +NEW: Product - add hook to modify supplier product html select +NEW: TakePOS - add hook to complete payment in TakePOS + + +NEW: Removed completely the need for the library adodbtime NEW: Replace fk_categories_product with categories_product in inventory NEW: Rewrite of SQL request. Removed the join on category (for filter on categ), replaced with a EXISTS/NOT @@ -222,6 +234,39 @@ Following changes may create regressions for some external modules, but were nec * Rename the substitution for project label instead of project title in substitution variables +***** ChangeLog for 16.0.4 compared to 16.0.2 ***** + +FIX: Amount of localtax1 and 2 not correctly save on purchase order (the rate was saved instead) +FIX: #20415 +FIX: #21280 +FIX: #23008 +FIX: #22271 +FIX: #22837 +FIX: #23019 Impossible to add task times to an existing draft invoice +FIX: #23072 +FIX: #23087 +FIX: #23115 +FIX: #23116 +FIX: #23281 +FIX: bad selection of barcode numbering module +FIX: Can't see all time spent by all user +FIX: CI +FIX: CommonObject - showOptionals - Display blank td when MAIN_VIEW_LINE_NUMBER is enabled and action is confirm_valid +FIX: Documents API inconsistency +FIX: #23075 +FIX: #23117 +FIX: get multicurrency infos of propal when create order from propal with "WORKFLOW_PROPAL_AUTOCREATE_ORDER" conf +FIX: Give predictable order to inventory lines +FIX: include class multicurrency +FIX: methods declaration (backport fix 67b9a7dc07d708231d12b5e58800334d4a01ef98) +FIX: multicurrency_tx and not currency_tx +FIX: PGSQL Integer type does not have a free length +FIX: Product list in setup.php in new Module +FIX: propal and order stats broken on Tag+User(retricted customer list) +FIX: saving of numbering module for jobs +FIX: Stickler +FIX: travis + ***** ChangeLog for 16.0.3 compared to 16.0.2 ***** FIX: $sign is useless diff --git a/build/doxygen/dolibarr-doxygen-build.pl b/build/doxygen/dolibarr-doxygen-build.pl index 75a5cceddbe..5a4849a3a5b 100755 --- a/build/doxygen/dolibarr-doxygen-build.pl +++ b/build/doxygen/dolibarr-doxygen-build.pl @@ -17,9 +17,9 @@ use Cwd; my $dir = getcwd; print "Current dir is: $dir\n"; -print "Running dir for doxygen must be: $DIR\n"; +#print "Running dir for doxygen must be: $DIR\n"; -if (! -s $CONFFILE) +if (! -s "build/doxygen/$CONFFILE") { print "Error: current directory for building Dolibarr doxygen documentation is not correct.\n"; print "\n"; @@ -30,7 +30,7 @@ if (! -s $CONFFILE) exit 1; } -$SOURCE="../.."; +$SOURCE="."; # Get version $MAJOR, $MINOR and $BUILD $result = open( IN, "< " . $SOURCE . "/htdocs/filefunc.inc.php" ); @@ -47,8 +47,8 @@ $version=$MAJOR.".".$MINOR.".".$BUILD; print "Running doxygen for version ".$version.", please wait...\n"; -print "cat $CONFFILE | sed -e 's/x\.y\.z/".$version."/' | doxygen $OPTIONS - 2>&1\n"; -$result=`cat $CONFFILE | sed -e 's/x\.y\.z/$version/' | doxygen $OPTIONS - 2>&1`; +print "cat build/doxygen/$CONFFILE | sed -e 's/x\.y\.z/".$version."/' | doxygen $OPTIONS - 2>&1\n"; +$result=`cat build/doxygen/$CONFFILE | sed -e 's/x\.y\.z/$version/' | doxygen $OPTIONS - 2>&1`; print $result; diff --git a/build/doxygen/dolibarr-doxygen.doxyfile b/build/doxygen/dolibarr-doxygen.doxyfile index 31400661ecc..6f668ebad7e 100644 --- a/build/doxygen/dolibarr-doxygen.doxyfile +++ b/build/doxygen/dolibarr-doxygen.doxyfile @@ -1,14 +1,17 @@ -# Doxyfile 1.7.3 +# Doxyfile 1.8.16 # This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project +# doxygen (www.doxygen.org) for a project. # -# All text after a hash (#) is considered a comment and will be ignored +# All text after a double hash (##) is considered a comment and is placed in +# front of the TAG it is preceding. +# +# All text after a single hash (#) is considered a comment and will be ignored. # The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") +# TAG = value [value, ...] +# For lists, items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (\" \"). #--------------------------------------------------------------------------- # Project related configuration options @@ -38,7 +41,7 @@ PROJECT_NUMBER = x.y.z # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. -OUTPUT_DIRECTORY = ../../build +OUTPUT_DIRECTORY = build # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output @@ -114,7 +117,7 @@ FULL_PATH_NAMES = YES # If left blank the directory from which doxygen is run is used as the # path to strip. -STRIP_FROM_PATH = "../.." +STRIP_FROM_PATH = "/home/dolibarr/doxygen.dolibarr.org/" # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells @@ -287,7 +290,7 @@ TYPEDEF_HIDES_STRUCT = NO # 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols -SYMBOL_CACHE_SIZE = 0 +#SYMBOL_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options @@ -448,7 +451,7 @@ GENERATE_TODOLIST = NO # disable (NO) the test list. This list is created by putting \test # commands in the documentation. -GENERATE_TESTLIST = YES +GENERATE_TESTLIST = NO # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug @@ -487,7 +490,7 @@ SHOW_USED_FILES = YES # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is NO. -SHOW_DIRECTORIES = YES +#SHOW_DIRECTORIES = YES # Set the SHOW_FILES tag to NO to disable the generation of the Files page. # This will remove the Files entry from the Quick Index and from the @@ -571,7 +574,7 @@ WARN_FORMAT = "$file:$line: $text" # and error messages should be written. If left blank the output is written # to stderr. -WARN_LOGFILE = doxygen_warnings.log +WARN_LOGFILE = build/html/doxygen_warnings.log #--------------------------------------------------------------------------- # configuration options related to the input files @@ -582,7 +585,7 @@ WARN_LOGFILE = doxygen_warnings.log # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = ../../htdocs ../../scripts +INPUT = htdocs scripts # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is @@ -611,7 +614,7 @@ RECURSIVE = YES # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. -EXCLUDE = ../../build ../../dev ../../doc ../../document ../../documents ../../htdocs/conf/conf.php ../../htdocs/custom ../../htdocs/document ../../htdocs/documents ../../htdocs/includes +EXCLUDE = build dev doc document documents htdocs/conf/conf.php htdocs/custom htdocs/document htdocs/documents htdocs/includes htdocs/install/doctemplates # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix filesystem feature) are excluded @@ -625,7 +628,7 @@ EXCLUDE_SYMLINKS = YES # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* -EXCLUDE_PATTERNS = */CVS/* *google* *pibarcode* +EXCLUDE_PATTERNS = */CVS/* # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the @@ -639,27 +642,27 @@ EXCLUDE_SYMBOLS = # directories that contain example code fragments that are included (see # the \include command). -EXAMPLE_PATH = ../../htdocs/modulebuilder/template +#EXAMPLE_PATH = htdocs/modulebuilder/template # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. -EXAMPLE_PATTERNS = *.php +#EXAMPLE_PATTERNS = *.php # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. -EXAMPLE_RECURSIVE = NO +#EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). -IMAGE_PATH = ../../doc/images +IMAGE_PATH = doc/images # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program @@ -762,7 +765,7 @@ ALPHABETICAL_INDEX = YES # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) -COLS_IN_ALPHA_INDEX = 5 +#COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. @@ -775,14 +778,16 @@ IGNORE_PREFIX = # configuration options related to the HTML output #--------------------------------------------------------------------------- -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. +# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output +# The default value is: YES. GENERATE_HTML = YES -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: html. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_OUTPUT = html @@ -797,14 +802,14 @@ HTML_FILE_EXTENSION = .html # standard header. # Does not work with 1.7.3 -#HTML_HEADER = doxygen_header.html +#HTML_HEADER = build/doxygen/doxygen_header.html # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. # Does not work with 1.7.3 -HTML_FOOTER = doxygen_footer.html +HTML_FOOTER = build/doxygen/doxygen_footer.html # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to @@ -850,7 +855,18 @@ HTML_TIMESTAMP = YES # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. -HTML_ALIGN_MEMBERS = YES +#HTML_ALIGN_MEMBERS = YES + +# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML +# documentation will contain a main index with vertical navigation menus that +# are dynamically created via Javascript. If disabled, the navigation index will +# consists of multiple levels of tabs that are statically embedded in every HTML +# page. Disable this option to support browsers that do not have Javascript, +# like the Qt help browser. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_MENUS = NO # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the @@ -858,7 +874,7 @@ HTML_ALIGN_MEMBERS = YES # JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox # Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). -HTML_DYNAMIC_SECTIONS = YES +HTML_DYNAMIC_SECTIONS = NO # If the GENERATE_DOCSET tag is set to YES, additional index files # will be generated that can be used as input for Apple's Xcode 3 @@ -1003,7 +1019,7 @@ QHG_LOCATION = # the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before # the help appears. -GENERATE_ECLIPSEHELP = YES +GENERATE_ECLIPSEHELP = NO # A unique identifier for the eclipse help plugin. When installing the plugin # the directory name containing the HTML and XML files should also have @@ -1035,7 +1051,7 @@ GENERATE_TREEVIEW = NO # By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, # and Class Hierarchy pages using a tree view instead of an ordered list. -USE_INLINE_TREES = NO +#USE_INLINE_TREES = NO # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree @@ -1072,7 +1088,7 @@ FORMULA_TRANSPARENT = YES # typically be disabled. For large projects the javascript based search engine # can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. -SEARCHENGINE = NO +SEARCHENGINE = YES # When the SERVER_BASED_SEARCH tag is enabled the search engine will be # implemented using a PHP enabled web server instead of at the web client @@ -1082,7 +1098,7 @@ SEARCHENGINE = NO # full text search. The disadvances is that it is more difficult to setup # and does not have live searching capabilities. -SERVER_BASED_SEARCH = NO +SERVER_BASED_SEARCH = YES #--------------------------------------------------------------------------- # configuration options related to the LaTeX output @@ -1260,13 +1276,13 @@ XML_OUTPUT = xml # which can be used by a validating XML parser to check the # syntax of the XML files. -XML_SCHEMA = +#XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. -XML_DTD = +#XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting @@ -1431,7 +1447,7 @@ EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). -PERL_PATH = /usr/bin/perl +#PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool @@ -1453,7 +1469,7 @@ CLASS_DIAGRAMS = NO # the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. -MSCGEN_PATH = +#MSCGEN_PATH = # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented @@ -1485,7 +1501,7 @@ DOT_NUM_THREADS = 0 # DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory # containing the font. -DOT_FONTNAME = FreeSans.ttf +#DOT_FONTNAME = FreeSans.ttf # The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. # The default size is 10pt. @@ -1634,3 +1650,7 @@ GENERATE_LEGEND = YES # the various graphs. DOT_CLEANUP = YES + + +FULL_SIDEBAR = NO +HTML_EXTRA_STYLESHEET = build/doxygen/doxygen-awesome.css diff --git a/build/doxygen/doxygen-awesome.css b/build/doxygen/doxygen-awesome.css new file mode 100644 index 00000000000..0b1c8c20892 --- /dev/null +++ b/build/doxygen/doxygen-awesome.css @@ -0,0 +1,2413 @@ +/** + +Doxygen Awesome +https://github.com/jothepro/doxygen-awesome-css + +MIT License + +Copyright (c) 2021 - 2022 jothepro + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +*/ + +html { + /* primary theme color. This will affect the entire websites color scheme: links, arrows, labels, ... */ + --primary-color: #1779c4; + --primary-dark-color: #335c80; + --primary-light-color: #70b1e9; + + /* page base colors */ + --page-background-color: #ffffff; + --page-foreground-color: #2f4153; + --page-secondary-foreground-color: #6f7e8e; + + /* color for all separators on the website: hr, borders, ... */ + --separator-color: #dedede; + + /* border radius for all rounded components. Will affect many components, like dropdowns, memitems, codeblocks, ... */ + --border-radius-large: 8px; + --border-radius-small: 4px; + --border-radius-medium: 6px; + + /* default spacings. Most components reference these values for spacing, to provide uniform spacing on the page. */ + --spacing-small: 5px; + --spacing-medium: 10px; + --spacing-large: 16px; + + /* default box shadow used for raising an element above the normal content. Used in dropdowns, search result, ... */ + --box-shadow: 0 2px 8px 0 rgba(0,0,0,.075); + + --odd-color: rgba(0,0,0,.028); + + /* font-families. will affect all text on the website + * font-family: the normal font for text, headlines, menus + * font-family-monospace: used for preformatted text in memtitle, code, fragments + */ + --font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif; + --font-family-monospace: ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace; + + /* font sizes */ + --page-font-size: 15.6px; + --navigation-font-size: 14.4px; + --toc-font-size: 13.4px; + --code-font-size: 14px; /* affects code, fragment */ + --title-font-size: 22px; + + /* content text properties. These only affect the page content, not the navigation or any other ui elements */ + --content-line-height: 27px; + /* The content is centered and constraint in it's width. To make the content fill the whole page, set the variable to auto.*/ + --content-maxwidth: 1050px; + --table-line-height: 24px; + --toc-sticky-top: var(--spacing-medium); + --toc-width: 200px; + --toc-max-height: calc(100vh - 2 * var(--spacing-medium) - 85px); + + /* colors for various content boxes: @warning, @note, @deprecated @bug */ + --warning-color: #f8d1cc; + --warning-color-dark: #b61825; + --warning-color-darker: #75070f; + --note-color: #faf3d8; + --note-color-dark: #f3a600; + --note-color-darker: #5f4204; + --todo-color: #e4f3ff; + --todo-color-dark: #1879C4; + --todo-color-darker: #274a5c; + --deprecated-color: #ecf0f3; + --deprecated-color-dark: #5b6269; + --deprecated-color-darker: #43454a; + --bug-color: #e4dafd; + --bug-color-dark: #5b2bdd; + --bug-color-darker: #2a0d72; + --invariant-color: #d8f1e3; + --invariant-color-dark: #44b86f; + --invariant-color-darker: #265532; + + /* blockquote colors */ + --blockquote-background: #f8f9fa; + --blockquote-foreground: #636568; + + /* table colors */ + --tablehead-background: #f1f1f1; + --tablehead-foreground: var(--page-foreground-color); + + /* menu-display: block | none + * Visibility of the top navigation on screens >= 768px. On smaller screen the menu is always visible. + * `GENERATE_TREEVIEW` MUST be enabled! + */ + --menu-display: block; + + --menu-focus-foreground: var(--page-background-color); + --menu-focus-background: var(--primary-color); + --menu-selected-background: rgba(0,0,0,.05); + + + --header-background: var(--page-background-color); + --header-foreground: var(--page-foreground-color); + + /* searchbar colors */ + --searchbar-background: var(--side-nav-background); + --searchbar-foreground: var(--page-foreground-color); + + /* searchbar size + * (`searchbar-width` is only applied on screens >= 768px. + * on smaller screens the searchbar will always fill the entire screen width) */ + --searchbar-height: 33px; + --searchbar-width: 210px; + --searchbar-border-radius: var(--searchbar-height); + + /* code block colors */ + --code-background: #f5f5f5; + --code-foreground: var(--page-foreground-color); + + /* fragment colors */ + --fragment-background: #F8F9FA; + --fragment-foreground: #37474F; + --fragment-keyword: #bb6bb2; + --fragment-keywordtype: #8258b3; + --fragment-keywordflow: #d67c3b; + --fragment-token: #438a59; + --fragment-comment: #969696; + --fragment-link: #5383d6; + --fragment-preprocessor: #46aaa5; + --fragment-linenumber-color: #797979; + --fragment-linenumber-background: #f4f4f5; + --fragment-linenumber-border: #e3e5e7; + --fragment-lineheight: 20px; + + /* sidebar navigation (treeview) colors */ + --side-nav-background: #fbfbfb; + --side-nav-foreground: var(--page-foreground-color); + --side-nav-arrow-opacity: 0; + --side-nav-arrow-hover-opacity: 0.9; + + --toc-background: var(--side-nav-background); + --toc-foreground: var(--side-nav-foreground); + + /* height of an item in any tree / collapsable table */ + --tree-item-height: 30px; + + --memname-font-size: var(--code-font-size); + --memtitle-font-size: 18px; + + --webkit-scrollbar-size: 7px; + --webkit-scrollbar-padding: 4px; + --webkit-scrollbar-color: var(--separator-color); +} + +@media screen and (max-width: 767px) { + html { + --page-font-size: 16px; + --navigation-font-size: 16px; + --toc-font-size: 15px; + --code-font-size: 15px; /* affects code, fragment */ + --title-font-size: 22px; + } +} + +@media (prefers-color-scheme: dark) { + html:not(.light-mode) { + color-scheme: dark; + + --primary-color: #1982d2; + --primary-dark-color: #86a9c4; + --primary-light-color: #4779ac; + + --box-shadow: 0 2px 8px 0 rgba(0,0,0,.35); + + --odd-color: rgba(100,100,100,.06); + + --menu-selected-background: rgba(0,0,0,.4); + + --page-background-color: #1C1D1F; + --page-foreground-color: #d2dbde; + --page-secondary-foreground-color: #859399; + --separator-color: #38393b; + --side-nav-background: #252628; + + --code-background: #2a2c2f; + + --tablehead-background: #2a2c2f; + + --blockquote-background: #222325; + --blockquote-foreground: #7e8c92; + + --warning-color: #2e1917; + --warning-color-dark: #ad2617; + --warning-color-darker: #f5b1aa; + --note-color: #3b2e04; + --note-color-dark: #f1b602; + --note-color-darker: #ceb670; + --todo-color: #163750; + --todo-color-dark: #1982D2; + --todo-color-darker: #dcf0fa; + --deprecated-color: #2e323b; + --deprecated-color-dark: #738396; + --deprecated-color-darker: #abb0bd; + --bug-color: #2a2536; + --bug-color-dark: #7661b3; + --bug-color-darker: #ae9ed6; + --invariant-color: #303a35; + --invariant-color-dark: #76ce96; + --invariant-color-darker: #cceed5; + + --fragment-background: #282c34; + --fragment-foreground: #dbe4eb; + --fragment-keyword: #cc99cd; + --fragment-keywordtype: #ab99cd; + --fragment-keywordflow: #e08000; + --fragment-token: #7ec699; + --fragment-comment: #999999; + --fragment-link: #98c0e3; + --fragment-preprocessor: #65cabe; + --fragment-linenumber-color: #cccccc; + --fragment-linenumber-background: #35393c; + --fragment-linenumber-border: #1f1f1f; + } +} + +/* dark mode variables are defined twice, to support both the dark-mode without and with doxygen-awesome-darkmode-toggle.js */ +html.dark-mode { + color-scheme: dark; + + --primary-color: #1982d2; + --primary-dark-color: #86a9c4; + --primary-light-color: #4779ac; + + --box-shadow: 0 2px 8px 0 rgba(0,0,0,.30); + + --odd-color: rgba(100,100,100,.06); + + --menu-selected-background: rgba(0,0,0,.4); + + --page-background-color: #1C1D1F; + --page-foreground-color: #d2dbde; + --page-secondary-foreground-color: #859399; + --separator-color: #38393b; + --side-nav-background: #252628; + + --code-background: #2a2c2f; + + --tablehead-background: #2a2c2f; + + --blockquote-background: #222325; + --blockquote-foreground: #7e8c92; + + --warning-color: #2e1917; + --warning-color-dark: #ad2617; + --warning-color-darker: #f5b1aa; + --note-color: #3b2e04; + --note-color-dark: #f1b602; + --note-color-darker: #ceb670; + --todo-color: #163750; + --todo-color-dark: #1982D2; + --todo-color-darker: #dcf0fa; + --deprecated-color: #2e323b; + --deprecated-color-dark: #738396; + --deprecated-color-darker: #abb0bd; + --bug-color: #2a2536; + --bug-color-dark: #7661b3; + --bug-color-darker: #ae9ed6; + --invariant-color: #303a35; + --invariant-color-dark: #76ce96; + --invariant-color-darker: #cceed5; + + --fragment-background: #282c34; + --fragment-foreground: #dbe4eb; + --fragment-keyword: #cc99cd; + --fragment-keywordtype: #ab99cd; + --fragment-keywordflow: #e08000; + --fragment-token: #7ec699; + --fragment-comment: #999999; + --fragment-link: #98c0e3; + --fragment-preprocessor: #65cabe; + --fragment-linenumber-color: #cccccc; + --fragment-linenumber-background: #35393c; + --fragment-linenumber-border: #1f1f1f; +} + +body { + color: var(--page-foreground-color); + background-color: var(--page-background-color); + font-size: var(--page-font-size); +} + +body, table, div, p, dl, #nav-tree .label, .title, +.sm-dox a, .sm-dox a:hover, .sm-dox a:focus, #projectname, +.SelectItem, #MSearchField, .navpath li.navelem a, +.navpath li.navelem a:hover, p.reference, p.definition { + font-family: var(--font-family); +} + +h1, h2, h3, h4, h5 { + margin-top: .9em; + font-weight: 600; + line-height: initial; +} + +p, div, table, dl, p.reference, p.definition { + font-size: var(--page-font-size); +} + +p.reference, p.definition { + color: var(--page-secondary-foreground-color); +} + +a:link, a:visited, a:hover, a:focus, a:active { + color: var(--primary-color) !important; + font-weight: 500; +} + +a.anchor { + scroll-margin-top: var(--spacing-large); + display: block; +} + +/* + Title and top navigation + */ + +#top { + background: var(--header-background); + border-bottom: 1px solid var(--separator-color); +} + +@media screen and (min-width: 768px) { + #top { + display: flex; + flex-wrap: wrap; + justify-content: space-between; + align-items: center; + } +} + +#main-nav { + flex-grow: 5; + padding: var(--spacing-small) var(--spacing-medium); +} + +#titlearea { + width: auto; + padding: var(--spacing-medium) var(--spacing-large); + background: none; + color: var(--header-foreground); + border-bottom: none; +} + +@media screen and (max-width: 767px) { + #titlearea { + padding-bottom: var(--spacing-small); + } +} + +#titlearea table tbody tr { + height: auto !important; +} + +#projectname { + font-size: var(--title-font-size); + font-weight: 600; +} + +#projectnumber { + font-family: inherit; + font-size: 60%; +} + +#projectbrief { + font-family: inherit; + font-size: 80%; +} + +#projectlogo { + vertical-align: middle; +} + +#projectlogo img { + max-height: calc(var(--title-font-size) * 2); + margin-right: var(--spacing-small); +} + +.sm-dox, .tabs, .tabs2, .tabs3 { + background: none; + padding: 0; +} + +.tabs, .tabs2, .tabs3 { + border-bottom: 1px solid var(--separator-color); + margin-bottom: -1px; +} + +.main-menu-btn-icon, .main-menu-btn-icon:before, .main-menu-btn-icon:after { + background: var(--page-secondary-foreground-color); +} + +@media screen and (max-width: 767px) { + .sm-dox a span.sub-arrow { + background: var(--code-background); + } + + #main-menu a.has-submenu span.sub-arrow { + color: var(--page-secondary-foreground-color); + border-radius: var(--border-radius-medium); + } + + #main-menu a.has-submenu:hover span.sub-arrow { + color: var(--page-foreground-color); + } +} + +@media screen and (min-width: 768px) { + .sm-dox li, .tablist li { + display: var(--menu-display); + } + + .sm-dox a span.sub-arrow { + border-color: var(--header-foreground) transparent transparent transparent; + } + + .sm-dox a:hover span.sub-arrow { + border-color: var(--menu-focus-foreground) transparent transparent transparent; + } + + .sm-dox ul a span.sub-arrow { + border-color: transparent transparent transparent var(--page-foreground-color); + } + + .sm-dox ul a:hover span.sub-arrow { + border-color: transparent transparent transparent var(--menu-focus-foreground); + } +} + +.sm-dox ul { + background: var(--page-background-color); + box-shadow: var(--box-shadow); + border: 1px solid var(--separator-color); + border-radius: var(--border-radius-medium) !important; + padding: var(--spacing-small); + animation: ease-out 150ms slideInMenu; +} + +@keyframes slideInMenu { + from { + opacity: 0; + transform: translate(0px, -2px); + } + + to { + opacity: 1; + transform: translate(0px, 0px); + } +} + +.sm-dox ul a { + color: var(--page-foreground-color) !important; + background: var(--page-background-color); + font-size: var(--navigation-font-size); +} + +.sm-dox>li>ul:after { + border-bottom-color: var(--page-background-color) !important; +} + +.sm-dox>li>ul:before { + border-bottom-color: var(--separator-color) !important; +} + +.sm-dox ul a:hover, .sm-dox ul a:active, .sm-dox ul a:focus { + font-size: var(--navigation-font-size) !important; + color: var(--menu-focus-foreground) !important; + text-shadow: none; + background-color: var(--menu-focus-background); + border-radius: var(--border-radius-small) !important; +} + +.sm-dox a, .sm-dox a:focus, .tablist li, .tablist li a, .tablist li.current a { + text-shadow: none; + background: transparent; + background-image: none !important; + color: var(--header-foreground) !important; + font-weight: normal; + font-size: var(--navigation-font-size); + border-radius: var(--border-radius-small) !important; +} + +.sm-dox a:focus { + outline: auto; +} + +.sm-dox a:hover, .sm-dox a:active, .tablist li a:hover { + text-shadow: none; + font-weight: normal; + background: var(--menu-focus-background); + color: var(--menu-focus-foreground) !important; + border-radius: var(--border-radius-small) !important; + font-size: var(--navigation-font-size); +} + +.tablist li.current { + border-radius: var(--border-radius-small); + background: var(--menu-selected-background); +} + +.tablist li { + margin: var(--spacing-small) 0 var(--spacing-small) var(--spacing-small); +} + +.tablist a { + padding: 0 var(--spacing-large); +} + + +/* + Search box + */ + +#MSearchBox { + height: var(--searchbar-height); + background: var(--searchbar-background); + border-radius: var(--searchbar-border-radius); + border: 1px solid var(--separator-color); + overflow: hidden; + width: var(--searchbar-width); + position: relative; + box-shadow: none; + display: block; + margin-top: 0; +} + +/* until Doxygen 1.9.4 */ +.left img#MSearchSelect { + left: 0; + user-select: none; + padding-left: 8px; +} + +/* Doxygen 1.9.5 */ +.left span#MSearchSelect { + left: 0; + user-select: none; + margin-left: 8px; + padding: 0; +} + +.left #MSearchSelect[src$=".png"] { + padding-left: 0 +} + +.SelectionMark { + user-select: none; +} + +.tabs .left #MSearchSelect { + padding-left: 0; +} + +.tabs #MSearchBox { + position: absolute; + right: var(--spacing-medium); +} + +@media screen and (max-width: 767px) { + .tabs #MSearchBox { + position: relative; + right: 0; + margin-left: var(--spacing-medium); + margin-top: 0; + } +} + +#MSearchSelectWindow, #MSearchResultsWindow { + z-index: 9999; +} + +#MSearchBox.MSearchBoxActive { + border-color: var(--primary-color); + box-shadow: inset 0 0 0 1px var(--primary-color); +} + +#main-menu > li:last-child { + margin-right: 0; +} + +@media screen and (max-width: 767px) { + #main-menu > li:last-child { + height: 50px; + } +} + +#MSearchField { + font-size: var(--navigation-font-size); + height: calc(var(--searchbar-height) - 2px); + background: transparent; + width: calc(var(--searchbar-width) - 64px); +} + +.MSearchBoxActive #MSearchField { + color: var(--searchbar-foreground); +} + +#MSearchSelect { + top: calc(calc(var(--searchbar-height) / 2) - 11px); +} + +#MSearchBox span.left, #MSearchBox span.right { + background: none; + background-image: none; +} + +#MSearchBox span.right { + padding-top: calc(calc(var(--searchbar-height) / 2) - 12px); + position: absolute; + right: var(--spacing-small); +} + +.tabs #MSearchBox span.right { + top: calc(calc(var(--searchbar-height) / 2) - 12px); +} + +@keyframes slideInSearchResults { + from { + opacity: 0; + transform: translate(0, 15px); + } + + to { + opacity: 1; + transform: translate(0, 20px); + } +} + +#MSearchResultsWindow { + left: auto !important; + right: var(--spacing-medium); + border-radius: var(--border-radius-large); + border: 1px solid var(--separator-color); + transform: translate(0, 20px); + box-shadow: var(--box-shadow); + animation: ease-out 280ms slideInSearchResults; + background: var(--page-background-color); +} + +iframe#MSearchResults { + margin: 4px; +} + +iframe { + color-scheme: normal; +} + +@media (prefers-color-scheme: dark) { + html:not(.light-mode) iframe#MSearchResults { + filter: invert() hue-rotate(180deg); + } +} + +html.dark-mode iframe#MSearchResults { + filter: invert() hue-rotate(180deg); +} + +#MSearchResults .SRPage { + background-color: transparent; +} + +#MSearchResults .SRPage .SREntry { + font-size: 10pt; + padding: var(--spacing-small) var(--spacing-medium); +} + +#MSearchSelectWindow { + border: 1px solid var(--separator-color); + border-radius: var(--border-radius-medium); + box-shadow: var(--box-shadow); + background: var(--page-background-color); + padding-top: var(--spacing-small); + padding-bottom: var(--spacing-small); +} + +#MSearchSelectWindow a.SelectItem { + font-size: var(--navigation-font-size); + line-height: var(--content-line-height); + margin: 0 var(--spacing-small); + border-radius: var(--border-radius-small); + color: var(--page-foreground-color) !important; + font-weight: normal; +} + +#MSearchSelectWindow a.SelectItem:hover { + background: var(--menu-focus-background); + color: var(--menu-focus-foreground) !important; +} + +@media screen and (max-width: 767px) { + #MSearchBox { + margin-top: var(--spacing-medium); + margin-bottom: var(--spacing-medium); + width: calc(100vw - 30px); + } + + #main-menu > li:last-child { + float: none !important; + } + + #MSearchField { + width: calc(100vw - 110px); + } + + @keyframes slideInSearchResultsMobile { + from { + opacity: 0; + transform: translate(0, 15px); + } + + to { + opacity: 1; + transform: translate(0, 20px); + } + } + + #MSearchResultsWindow { + left: var(--spacing-medium) !important; + right: var(--spacing-medium); + overflow: auto; + transform: translate(0, 20px); + animation: ease-out 280ms slideInSearchResultsMobile; + width: auto !important; + } + + /* + * Overwrites for fixing the searchbox on mobile in doxygen 1.9.2 + */ + label.main-menu-btn ~ #searchBoxPos1 { + top: 3px !important; + right: 6px !important; + left: 45px; + display: flex; + } + + label.main-menu-btn ~ #searchBoxPos1 > #MSearchBox { + margin-top: 0; + margin-bottom: 0; + flex-grow: 2; + float: left; + } +} + +/* + Tree view + */ + +#side-nav { + padding: 0 !important; + background: var(--side-nav-background); +} + +@media screen and (max-width: 767px) { + #side-nav { + display: none; + } + + #doc-content { + margin-left: 0 !important; + } +} + +#nav-tree { + background: transparent; +} + +#nav-tree .label { + font-size: var(--navigation-font-size); +} + +#nav-tree .item { + height: var(--tree-item-height); + line-height: var(--tree-item-height); +} + +#nav-sync { + bottom: 12px; + right: 12px; + top: auto !important; + user-select: none; +} + +#nav-tree .selected { + text-shadow: none; + background-image: none; + background-color: transparent; + position: relative; +} + +#nav-tree .selected::after { + content: ""; + position: absolute; + top: 1px; + bottom: 1px; + left: 0; + width: 4px; + border-radius: 0 var(--border-radius-small) var(--border-radius-small) 0; + background: var(--primary-color); +} + + +#nav-tree a { + color: var(--side-nav-foreground) !important; + font-weight: normal; +} + +#nav-tree a:focus { + outline-style: auto; +} + +#nav-tree .arrow { + opacity: var(--side-nav-arrow-opacity); +} + +.arrow { + color: inherit; + cursor: pointer; + font-size: 45%; + vertical-align: middle; + margin-right: 2px; + font-family: serif; + height: auto; + text-align: right; +} + +#nav-tree div.item:hover .arrow, #nav-tree a:focus .arrow { + opacity: var(--side-nav-arrow-hover-opacity); +} + +#nav-tree .selected a { + color: var(--primary-color) !important; + font-weight: bolder; + font-weight: 600; +} + +.ui-resizable-e { + background: var(--separator-color); + width: 1px; +} + +/* + Contents + */ + +div.header { + border-bottom: 1px solid var(--separator-color); + background-color: var(--page-background-color); + background-image: none; +} + +@media screen and (min-width: 1000px) { + #doc-content > div > div.contents, + .PageDoc > div.contents { + display: flex; + flex-direction: row-reverse; + flex-wrap: nowrap; + align-items: flex-start; + } + + div.contents .textblock { + min-width: 200px; + flex-grow: 1; + } +} + +div.contents, div.header .title, div.header .summary { + max-width: var(--content-maxwidth); +} + +div.contents, div.header .title { + line-height: initial; + margin: calc(var(--spacing-medium) + .2em) auto var(--spacing-medium) auto; +} + +div.header .summary { + margin: var(--spacing-medium) auto 0 auto; +} + +div.headertitle { + padding: 0; +} + +div.header .title { + font-weight: 600; + font-size: 225%; + padding: var(--spacing-medium) var(--spacing-large); + word-break: break-word; +} + +div.header .summary { + width: auto; + display: block; + float: none; + padding: 0 var(--spacing-large); +} + +td.memSeparator { + border-color: var(--separator-color); +} + +span.mlabel { + background: var(--primary-color); + border: none; + padding: 4px 9px; + border-radius: 12px; + margin-right: var(--spacing-medium); +} + +span.mlabel:last-of-type { + margin-right: 2px; +} + +div.contents { + padding: 0 var(--spacing-large); +} + +div.contents p, div.contents li { + line-height: var(--content-line-height); +} + +div.contents div.dyncontent { + margin: var(--spacing-medium) 0; +} + +@media (prefers-color-scheme: dark) { + html:not(.light-mode) div.contents div.dyncontent img, + html:not(.light-mode) div.contents center img, + html:not(.light-mode) div.contents > table img, + html:not(.light-mode) div.contents div.dyncontent iframe, + html:not(.light-mode) div.contents center iframe, + html:not(.light-mode) div.contents table iframe { + filter: hue-rotate(180deg) invert(); + } +} + +html.dark-mode div.contents div.dyncontent img, +html.dark-mode div.contents center img, +html.dark-mode div.contents > table img, +html.dark-mode div.contents div.dyncontent iframe, +html.dark-mode div.contents center iframe, +html.dark-mode div.contents table iframe { + filter: hue-rotate(180deg) invert(); +} + +h2.groupheader { + border-bottom: 0px; + color: var(--page-foreground-color); + box-shadow: + 100px 0 var(--page-background-color), + -100px 0 var(--page-background-color), + 100px 0.75px var(--separator-color), + -100px 0.75px var(--separator-color), + 500px 0 var(--page-background-color), + -500px 0 var(--page-background-color), + 500px 0.75px var(--separator-color), + -500px 0.75px var(--separator-color), + 900px 0 var(--page-background-color), + -900px 0 var(--page-background-color), + 900px 0.75px var(--separator-color), + -900px 0.75px var(--separator-color), + 1400px 0 var(--page-background-color), + -1400px 0 var(--page-background-color), + 1400px 0.75px var(--separator-color), + -1400px 0.75px var(--separator-color), + 1900px 0 var(--page-background-color), + -1900px 0 var(--page-background-color), + 1900px 0.75px var(--separator-color), + -1900px 0.75px var(--separator-color); +} + +blockquote { + margin: 0 var(--spacing-medium) 0 var(--spacing-medium); + padding: var(--spacing-small) var(--spacing-large); + background: var(--blockquote-background); + color: var(--blockquote-foreground); + border-left: 0; + overflow: visible; + border-radius: var(--border-radius-medium); + overflow: visible; + position: relative; +} + +blockquote::before, blockquote::after { + font-weight: bold; + font-family: serif; + font-size: 360%; + opacity: .15; + position: absolute; +} + +blockquote::before { + content: "“"; + left: -10px; + top: 4px; +} + +blockquote::after { + content: "”"; + right: -8px; + bottom: -25px; +} + +blockquote p { + margin: var(--spacing-small) 0 var(--spacing-medium) 0; +} +.paramname { + font-weight: 600; + color: var(--primary-dark-color); +} + +.paramname > code { + border: 0; +} + +table.params .paramname { + font-weight: 600; + font-family: var(--font-family-monospace); + font-size: var(--code-font-size); + padding-right: var(--spacing-small); + line-height: var(--table-line-height); +} + +h1.glow, h2.glow, h3.glow, h4.glow, h5.glow, h6.glow { + text-shadow: 0 0 15px var(--primary-light-color); +} + +.alphachar a { + color: var(--page-foreground-color); +} + +/* + Table of Contents + */ + +div.contents .toc { + max-height: var(--toc-max-height); + min-width: var(--toc-width); + border: 0; + border-left: 1px solid var(--separator-color); + border-radius: 0; + background-color: transparent; + box-shadow: none; + position: sticky; + top: var(--toc-sticky-top); + padding: 0 var(--spacing-large); + margin: var(--spacing-small) 0 var(--spacing-large) var(--spacing-large); +} + +div.toc h3 { + color: var(--toc-foreground); + font-size: var(--navigation-font-size); + margin: var(--spacing-large) 0 var(--spacing-medium) 0; +} + +div.toc li { + padding: 0; + background: none; + line-height: var(--toc-font-size); + margin: var(--toc-font-size) 0 0 0; +} + +div.toc li::before { + display: none; +} + +div.toc ul { + margin-top: 0 +} + +div.toc li a { + font-size: var(--toc-font-size); + color: var(--page-foreground-color) !important; + text-decoration: none; +} + +div.toc li a:hover, div.toc li a.active { + color: var(--primary-color) !important; +} + +div.toc li a.aboveActive { + color: var(--page-secondary-foreground-color) !important; +} + + +@media screen and (max-width: 999px) { + div.contents .toc { + max-height: 45vh; + float: none; + width: auto; + margin: 0 0 var(--spacing-medium) 0; + position: relative; + top: 0; + position: relative; + border: 1px solid var(--separator-color); + border-radius: var(--border-radius-medium); + background-color: var(--toc-background); + box-shadow: var(--box-shadow); + } + + div.contents .toc.interactive { + max-height: calc(var(--navigation-font-size) + 2 * var(--spacing-large)); + overflow: hidden; + } + + div.contents .toc > h3 { + -webkit-tap-highlight-color: transparent; + cursor: pointer; + position: sticky; + top: 0; + background-color: var(--toc-background); + margin: 0; + padding: var(--spacing-large) 0; + display: block; + } + + div.contents .toc.interactive > h3::before { + content: ""; + width: 0; + height: 0; + border-left: 4px solid transparent; + border-right: 4px solid transparent; + border-top: 5px solid var(--primary-color); + display: inline-block; + margin-right: var(--spacing-small); + margin-bottom: calc(var(--navigation-font-size) / 4); + transform: rotate(-90deg); + transition: transform 0.25s ease-out; + } + + div.contents .toc.interactive.open > h3::before { + transform: rotate(0deg); + } + + div.contents .toc.interactive.open { + max-height: 45vh; + overflow: auto; + transition: max-height 0.2s ease-in-out; + } + + div.contents .toc a, div.contents .toc a.active { + color: var(--primary-color) !important; + } + + div.contents .toc a:hover { + text-decoration: underline; + } +} + +/* + Code & Fragments + */ + +code, div.fragment, pre.fragment { + border-radius: var(--border-radius-small); + border: 1px solid var(--separator-color); + overflow: hidden; +} + +code { + display: inline; + background: var(--code-background); + color: var(--code-foreground); + padding: 2px 6px; +} + +div.fragment, pre.fragment { + margin: var(--spacing-medium) 0; + padding: calc(var(--spacing-large) - (var(--spacing-large) / 6)) var(--spacing-large); + background: var(--fragment-background); + color: var(--fragment-foreground); + overflow-x: auto; +} + +@media screen and (max-width: 767px) { + div.fragment, pre.fragment { + border-top-right-radius: 0; + border-bottom-right-radius: 0; + border-right: 0; + } + + .contents > div.fragment, + .textblock > div.fragment, + .textblock > pre.fragment, + .contents > .doxygen-awesome-fragment-wrapper > div.fragment, + .textblock > .doxygen-awesome-fragment-wrapper > div.fragment, + .textblock > .doxygen-awesome-fragment-wrapper > pre.fragment { + margin: var(--spacing-medium) calc(0px - var(--spacing-large)); + border-radius: 0; + border-left: 0; + } + + .textblock li > .fragment, + .textblock li > .doxygen-awesome-fragment-wrapper > .fragment { + margin: var(--spacing-medium) calc(0px - var(--spacing-large)); + } + + .memdoc li > .fragment, + .memdoc li > .doxygen-awesome-fragment-wrapper > .fragment { + margin: var(--spacing-medium) calc(0px - var(--spacing-medium)); + } + + .textblock ul, .memdoc ul { + overflow: initial; + } + + .memdoc > div.fragment, + .memdoc > pre.fragment, + dl dd > div.fragment, + dl dd pre.fragment, + .memdoc > .doxygen-awesome-fragment-wrapper > div.fragment, + .memdoc > .doxygen-awesome-fragment-wrapper > pre.fragment, + dl dd > .doxygen-awesome-fragment-wrapper > div.fragment, + dl dd .doxygen-awesome-fragment-wrapper > pre.fragment { + margin: var(--spacing-medium) calc(0px - var(--spacing-medium)); + border-radius: 0; + border-left: 0; + } +} + +code, code a, pre.fragment, div.fragment, div.fragment .line, div.fragment span, div.fragment .line a, div.fragment .line span { + font-family: var(--font-family-monospace); + font-size: var(--code-font-size) !important; +} + +div.line:after { + margin-right: var(--spacing-medium); +} + +div.fragment .line, pre.fragment { + white-space: pre; + word-wrap: initial; + line-height: var(--fragment-lineheight); +} + +div.fragment span.keyword { + color: var(--fragment-keyword); +} + +div.fragment span.keywordtype { + color: var(--fragment-keywordtype); +} + +div.fragment span.keywordflow { + color: var(--fragment-keywordflow); +} + +div.fragment span.stringliteral { + color: var(--fragment-token) +} + +div.fragment span.comment { + color: var(--fragment-comment); +} + +div.fragment a.code { + color: var(--fragment-link) !important; +} + +div.fragment span.preprocessor { + color: var(--fragment-preprocessor); +} + +div.fragment span.lineno { + display: inline-block; + width: 27px; + border-right: none; + background: var(--fragment-linenumber-background); + color: var(--fragment-linenumber-color); +} + +div.fragment span.lineno a { + background: none; + color: var(--fragment-link) !important; +} + +div.fragment .line:first-child .lineno { + box-shadow: -999999px 0px 0 999999px var(--fragment-linenumber-background), -999998px 0px 0 999999px var(--fragment-linenumber-border); +} + +div.line { + border-radius: var(--border-radius-small); +} + +div.line.glow { + background-color: var(--primary-light-color); + box-shadow: none; +} + +/* + dl warning, attention, note, deprecated, bug, ... + */ + +dl.bug dt a, dl.deprecated dt a, dl.todo dt a { + font-weight: bold !important; +} + +dl.warning, dl.attention, dl.note, dl.deprecated, dl.bug, dl.invariant, dl.pre, dl.todo, dl.remark { + padding: var(--spacing-medium); + margin: var(--spacing-medium) 0; + color: var(--page-background-color); + overflow: hidden; + margin-left: 0; + border-radius: var(--border-radius-small); +} + +dl.section dd { + margin-bottom: 2px; +} + +dl.warning, dl.attention { + background: var(--warning-color); + border-left: 8px solid var(--warning-color-dark); + color: var(--warning-color-darker); +} + +dl.warning dt, dl.attention dt { + color: var(--warning-color-dark); +} + +dl.note, dl.remark { + background: var(--note-color); + border-left: 8px solid var(--note-color-dark); + color: var(--note-color-darker); +} + +dl.note dt, dl.remark dt { + color: var(--note-color-dark); +} + +dl.todo { + background: var(--todo-color); + border-left: 8px solid var(--todo-color-dark); + color: var(--todo-color-darker); +} + +dl.todo dt { + color: var(--todo-color-dark); +} + +dl.bug dt a { + color: var(--todo-color-dark) !important; +} + +dl.bug { + background: var(--bug-color); + border-left: 8px solid var(--bug-color-dark); + color: var(--bug-color-darker); +} + +dl.bug dt a { + color: var(--bug-color-dark) !important; +} + +dl.deprecated { + background: var(--deprecated-color); + border-left: 8px solid var(--deprecated-color-dark); + color: var(--deprecated-color-darker); +} + +dl.deprecated dt a { + color: var(--deprecated-color-dark) !important; +} + +dl.section dd, dl.bug dd, dl.deprecated dd, dl.todo dd { + margin-inline-start: 0px; +} + +dl.invariant, dl.pre { + background: var(--invariant-color); + border-left: 8px solid var(--invariant-color-dark); + color: var(--invariant-color-darker); +} + +dl.invariant dt, dl.pre dt { + color: var(--invariant-color-dark); +} + +/* + memitem + */ + +div.memdoc, div.memproto, h2.memtitle { + box-shadow: none; + background-image: none; + border: none; +} + +div.memdoc { + padding: 0 var(--spacing-medium); + background: var(--page-background-color); +} + +h2.memtitle, div.memitem { + border: 1px solid var(--separator-color); + box-shadow: var(--box-shadow); +} + +h2.memtitle { + box-shadow: 0px var(--spacing-medium) 0 -1px var(--fragment-background), var(--box-shadow); +} + +div.memitem { + transition: none; +} + +div.memproto, h2.memtitle { + background: var(--fragment-background); +} + +h2.memtitle { + font-weight: 500; + font-size: var(--memtitle-font-size); + font-family: var(--font-family-monospace); + border-bottom: none; + border-top-left-radius: var(--border-radius-medium); + border-top-right-radius: var(--border-radius-medium); + word-break: break-all; + position: relative; +} + +h2.memtitle:after { + content: ""; + display: block; + background: var(--fragment-background); + height: var(--spacing-medium); + bottom: calc(0px - var(--spacing-medium)); + left: 0; + right: -14px; + position: absolute; + border-top-right-radius: var(--border-radius-medium); +} + +h2.memtitle > span.permalink { + font-size: inherit; +} + +h2.memtitle > span.permalink > a { + text-decoration: none; + padding-left: 3px; + margin-right: -4px; + user-select: none; + display: inline-block; + margin-top: -6px; +} + +h2.memtitle > span.permalink > a:hover { + color: var(--primary-dark-color) !important; +} + +a:target + h2.memtitle, a:target + h2.memtitle + div.memitem { + border-color: var(--primary-light-color); +} + +div.memitem { + border-top-right-radius: var(--border-radius-medium); + border-bottom-right-radius: var(--border-radius-medium); + border-bottom-left-radius: var(--border-radius-medium); + overflow: hidden; + display: block !important; +} + +div.memdoc { + border-radius: 0; +} + +div.memproto { + border-radius: 0 var(--border-radius-small) 0 0; + overflow: auto; + border-bottom: 1px solid var(--separator-color); + padding: var(--spacing-medium); + margin-bottom: -1px; +} + +div.memtitle { + border-top-right-radius: var(--border-radius-medium); + border-top-left-radius: var(--border-radius-medium); +} + +div.memproto table.memname { + font-family: var(--font-family-monospace); + color: var(--page-foreground-color); + font-size: var(--memname-font-size); + text-shadow: none; +} + +div.memproto div.memtemplate { + font-family: var(--font-family-monospace); + color: var(--primary-dark-color); + font-size: var(--memname-font-size); + margin-left: 2px; + text-shadow: none; +} + +table.mlabels, table.mlabels > tbody { + display: block; +} + +td.mlabels-left { + width: auto; +} + +td.mlabels-right { + margin-top: 3px; + position: sticky; + left: 0; +} + +table.mlabels > tbody > tr:first-child { + display: flex; + justify-content: space-between; + flex-wrap: wrap; +} + +.memname, .memitem span.mlabels { + margin: 0 +} + +/* + reflist + */ + +dl.reflist { + box-shadow: var(--box-shadow); + border-radius: var(--border-radius-medium); + border: 1px solid var(--separator-color); + overflow: hidden; + padding: 0; +} + + +dl.reflist dt, dl.reflist dd { + box-shadow: none; + text-shadow: none; + background-image: none; + border: none; + padding: 12px; +} + + +dl.reflist dt { + font-weight: 500; + border-radius: 0; + background: var(--code-background); + border-bottom: 1px solid var(--separator-color); + color: var(--page-foreground-color) +} + + +dl.reflist dd { + background: none; +} + +/* + Table + */ + +.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname), +.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname) tbody { + display: inline-block; + max-width: 100%; +} + +.contents > table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname):not(.classindex) { + margin-left: calc(0px - var(--spacing-large)); + margin-right: calc(0px - var(--spacing-large)); + max-width: calc(100% + 2 * var(--spacing-large)); +} + +table.fieldtable, +table.markdownTable tbody, +table.doxtable tbody { + border: none; + margin: var(--spacing-medium) 0; + box-shadow: 0 0 0 1px var(--separator-color); + border-radius: var(--border-radius-small); +} + +table.doxtable caption { + display: block; +} + +table.fieldtable { + border-collapse: collapse; + width: 100%; +} + +th.markdownTableHeadLeft, +th.markdownTableHeadRight, +th.markdownTableHeadCenter, +th.markdownTableHeadNone, +table.doxtable th { + background: var(--tablehead-background); + color: var(--tablehead-foreground); + font-weight: 600; + font-size: var(--page-font-size); +} + +th.markdownTableHeadLeft:first-child, +th.markdownTableHeadRight:first-child, +th.markdownTableHeadCenter:first-child, +th.markdownTableHeadNone:first-child, +table.doxtable tr th:first-child { + border-top-left-radius: var(--border-radius-small); +} + +th.markdownTableHeadLeft:last-child, +th.markdownTableHeadRight:last-child, +th.markdownTableHeadCenter:last-child, +th.markdownTableHeadNone:last-child, +table.doxtable tr th:last-child { + border-top-right-radius: var(--border-radius-small); +} + +table.markdownTable td, +table.markdownTable th, +table.fieldtable td, +table.fieldtable th, +table.doxtable td, +table.doxtable th { + border: 1px solid var(--separator-color); + padding: var(--spacing-small) var(--spacing-medium); +} + +table.markdownTable td:last-child, +table.markdownTable th:last-child, +table.fieldtable td:last-child, +table.fieldtable th:last-child, +table.doxtable td:last-child, +table.doxtable th:last-child { + border-right: none; +} + +table.markdownTable td:first-child, +table.markdownTable th:first-child, +table.fieldtable td:first-child, +table.fieldtable th:first-child, +table.doxtable td:first-child, +table.doxtable th:first-child { + border-left: none; +} + +table.markdownTable tr:first-child td, +table.markdownTable tr:first-child th, +table.fieldtable tr:first-child td, +table.fieldtable tr:first-child th, +table.doxtable tr:first-child td, +table.doxtable tr:first-child th { + border-top: none; +} + +table.markdownTable tr:last-child td, +table.markdownTable tr:last-child th, +table.fieldtable tr:last-child td, +table.fieldtable tr:last-child th, +table.doxtable tr:last-child td, +table.doxtable tr:last-child th { + border-bottom: none; +} + +table.markdownTable tr, table.doxtable tr { + border-bottom: 1px solid var(--separator-color); +} + +table.markdownTable tr:last-child, table.doxtable tr:last-child { + border-bottom: none; +} + +table.fieldtable th { + font-size: var(--page-font-size); + font-weight: 600; + background-image: none; + background-color: var(--tablehead-background); + color: var(--tablehead-foreground); +} + +table.fieldtable td.fieldtype, .fieldtable td.fieldname, .fieldtable td.fielddoc, .fieldtable th { + border-bottom: 1px solid var(--separator-color); + border-right: 1px solid var(--separator-color); +} + +table.fieldtable tr:last-child td:first-child { + border-bottom-left-radius: var(--border-radius-small); +} + +table.fieldtable tr:last-child td:last-child { + border-bottom-right-radius: var(--border-radius-small); +} + +.memberdecls td.glow, .fieldtable tr.glow { + background-color: var(--primary-light-color); + box-shadow: none; +} + +table.memberdecls { + display: block; + -webkit-tap-highlight-color: transparent; +} + +table.memberdecls tr[class^='memitem'] { + font-family: var(--font-family-monospace); + font-size: var(--code-font-size); +} + +table.memberdecls tr[class^='memitem'] .memTemplParams { + font-family: var(--font-family-monospace); + font-size: var(--code-font-size); + color: var(--primary-dark-color); + white-space: normal; +} + +table.memberdecls .memItemLeft, +table.memberdecls .memItemRight, +table.memberdecls .memTemplItemLeft, +table.memberdecls .memTemplItemRight, +table.memberdecls .memTemplParams { + transition: none; + padding-top: var(--spacing-small); + padding-bottom: var(--spacing-small); + border-top: 1px solid var(--separator-color); + border-bottom: 1px solid var(--separator-color); + background-color: var(--fragment-background); +} + +table.memberdecls .memTemplItemLeft, +table.memberdecls .memTemplItemRight { + padding-top: 2px; +} + +table.memberdecls .memTemplParams { + border-bottom: 0; + border-left: 1px solid var(--separator-color); + border-right: 1px solid var(--separator-color); + border-radius: var(--border-radius-small) var(--border-radius-small) 0 0; + padding-bottom: var(--spacing-small); +} + +table.memberdecls .memTemplItemLeft { + border-radius: 0 0 0 var(--border-radius-small); + border-left: 1px solid var(--separator-color); + border-top: 0; +} + +table.memberdecls .memTemplItemRight { + border-radius: 0 0 var(--border-radius-small) 0; + border-right: 1px solid var(--separator-color); + padding-left: 0; + border-top: 0; +} + +table.memberdecls .memItemLeft { + border-radius: var(--border-radius-small) 0 0 var(--border-radius-small); + border-left: 1px solid var(--separator-color); + padding-left: var(--spacing-medium); + padding-right: 0; +} + +table.memberdecls .memItemRight { + border-radius: 0 var(--border-radius-small) var(--border-radius-small) 0; + border-right: 1px solid var(--separator-color); + padding-right: var(--spacing-medium); + padding-left: 0; + +} + +table.memberdecls .mdescLeft, table.memberdecls .mdescRight { + background: none; + color: var(--page-foreground-color); + padding: var(--spacing-small) 0; +} + +table.memberdecls .memItemLeft, +table.memberdecls .memTemplItemLeft { + padding-right: var(--spacing-medium); +} + +table.memberdecls .memSeparator { + background: var(--page-background-color); + height: var(--spacing-large); + border: 0; + transition: none; +} + +table.memberdecls .groupheader { + margin-bottom: var(--spacing-large); +} + +table.memberdecls .inherit_header td { + padding: 0 0 var(--spacing-medium) 0; + text-indent: -12px; + color: var(--page-secondary-foreground-color); +} + +table.memberdecls img[src="closed.png"], +table.memberdecls img[src="open.png"], +div.dynheader img[src="open.png"], +div.dynheader img[src="closed.png"] { + width: 0; + height: 0; + border-left: 4px solid transparent; + border-right: 4px solid transparent; + border-top: 5px solid var(--primary-color); + margin-top: 8px; + display: block; + float: left; + margin-left: -10px; + transition: transform 0.25s ease-out; +} + +table.memberdecls img { + margin-right: 10px; +} + +table.memberdecls img[src="closed.png"], +div.dynheader img[src="closed.png"] { + transform: rotate(-90deg); + +} + +.compoundTemplParams { + font-family: var(--font-family-monospace); + color: var(--primary-dark-color); + font-size: var(--code-font-size); +} + +@media screen and (max-width: 767px) { + + table.memberdecls .memItemLeft, + table.memberdecls .memItemRight, + table.memberdecls .mdescLeft, + table.memberdecls .mdescRight, + table.memberdecls .memTemplItemLeft, + table.memberdecls .memTemplItemRight, + table.memberdecls .memTemplParams { + display: block; + text-align: left; + padding-left: var(--spacing-large); + margin: 0 calc(0px - var(--spacing-large)) 0 calc(0px - var(--spacing-large)); + border-right: none; + border-left: none; + border-radius: 0; + white-space: normal; + } + + table.memberdecls .memItemLeft, + table.memberdecls .mdescLeft, + table.memberdecls .memTemplItemLeft { + border-bottom: 0; + padding-bottom: 0; + } + + table.memberdecls .memTemplItemLeft { + padding-top: 0; + } + + table.memberdecls .mdescLeft { + margin-bottom: calc(0px - var(--page-font-size)); + } + + table.memberdecls .memItemRight, + table.memberdecls .mdescRight, + table.memberdecls .memTemplItemRight { + border-top: 0; + padding-top: 0; + padding-right: var(--spacing-large); + overflow-x: auto; + } + + table.memberdecls tr[class^='memitem']:not(.inherit) { + display: block; + width: calc(100vw - 2 * var(--spacing-large)); + } + + table.memberdecls .mdescRight { + color: var(--page-foreground-color); + } + + table.memberdecls tr.inherit { + visibility: hidden; + } + + table.memberdecls tr[style="display: table-row;"] { + display: block !important; + visibility: visible; + width: calc(100vw - 2 * var(--spacing-large)); + animation: fade .5s; + } + + @keyframes fade { + 0% { + opacity: 0; + max-height: 0; + } + + 100% { + opacity: 1; + max-height: 200px; + } + } +} + + +/* + Horizontal Rule + */ + +hr { + margin-top: var(--spacing-large); + margin-bottom: var(--spacing-large); + height: 1px; + background-color: var(--separator-color); + border: 0; +} + +.contents hr { + box-shadow: 100px 0 0 var(--separator-color), + -100px 0 0 var(--separator-color), + 500px 0 0 var(--separator-color), + -500px 0 0 var(--separator-color), + 1500px 0 0 var(--separator-color), + -1500px 0 0 var(--separator-color), + 2000px 0 0 var(--separator-color), + -2000px 0 0 var(--separator-color); +} + +.contents img, .contents .center, .contents center, .contents div.image object { + max-width: 100%; + overflow: auto; +} + +@media screen and (max-width: 767px) { + .contents .dyncontent > .center, .contents > center { + margin-left: calc(0px - var(--spacing-large)); + margin-right: calc(0px - var(--spacing-large)); + max-width: calc(100% + 2 * var(--spacing-large)); + } +} + +/* + Directories + */ +div.directory { + border-top: 1px solid var(--separator-color); + border-bottom: 1px solid var(--separator-color); + width: auto; +} + +table.directory { + font-family: var(--font-family); + font-size: var(--page-font-size); + font-weight: normal; + width: 100%; +} + +table.directory td.entry, table.directory td.desc { + padding: calc(var(--spacing-small) / 2) var(--spacing-small); + line-height: var(--table-line-height); +} + +table.directory tr.even td:last-child { + border-radius: 0 var(--border-radius-small) var(--border-radius-small) 0; +} + +table.directory tr.even td:first-child { + border-radius: var(--border-radius-small) 0 0 var(--border-radius-small); +} + +table.directory tr.even:last-child td:last-child { + border-radius: 0 var(--border-radius-small) 0 0; +} + +table.directory tr.even:last-child td:first-child { + border-radius: var(--border-radius-small) 0 0 0; +} + +table.directory td.desc { + min-width: 250px; +} + +table.directory tr.even { + background-color: var(--odd-color); +} + +table.directory tr.odd { + background-color: transparent; +} + +.icona { + width: auto; + height: auto; + margin: 0 var(--spacing-small); +} + +.icon { + background: var(--primary-color); + border-radius: var(--border-radius-small); + font-size: var(--page-font-size); + padding: calc(var(--page-font-size) / 5); + line-height: var(--page-font-size); + transform: scale(0.8); + height: auto; + width: var(--page-font-size); + user-select: none; +} + +.iconfopen, .icondoc, .iconfclosed { + background-position: center; + margin-bottom: 0; + height: var(--table-line-height); +} + +.icondoc { + filter: saturate(0.2); +} + +@media screen and (max-width: 767px) { + div.directory { + margin-left: calc(0px - var(--spacing-large)); + margin-right: calc(0px - var(--spacing-large)); + } +} + +@media (prefers-color-scheme: dark) { + html:not(.light-mode) .iconfopen, html:not(.light-mode) .iconfclosed { + filter: hue-rotate(180deg) invert(); + } +} + +html.dark-mode .iconfopen, html.dark-mode .iconfclosed { + filter: hue-rotate(180deg) invert(); +} + +/* + Class list + */ + +.classindex dl.odd { + background: var(--odd-color); + border-radius: var(--border-radius-small); +} + +.classindex dl.even { + background-color: transparent; +} + +/* + Class Index Doxygen 1.8 +*/ + +table.classindex { + margin-left: 0; + margin-right: 0; + width: 100%; +} + +table.classindex table div.ah { + background-image: none; + background-color: initial; + border-color: var(--separator-color); + color: var(--page-foreground-color); + box-shadow: var(--box-shadow); + border-radius: var(--border-radius-large); + padding: var(--spacing-small); +} + +div.qindex { + background-color: var(--odd-color); + border-radius: var(--border-radius-small); + border: 1px solid var(--separator-color); + padding: var(--spacing-small) 0; +} + +/* + Footer and nav-path + */ + +#nav-path { + width: 100%; +} + +#nav-path ul { + background-image: none; + background: var(--page-background-color); + border: none; + border-top: 1px solid var(--separator-color); + border-bottom: 1px solid var(--separator-color); + border-bottom: 0; + box-shadow: 0 0.75px 0 var(--separator-color); + font-size: var(--navigation-font-size); +} + +img.footer { + width: 60px; +} + +.navpath li.footer { + color: var(--page-secondary-foreground-color); +} + +address.footer { + color: var(--page-secondary-foreground-color); + margin-bottom: var(--spacing-large); +} + +#nav-path li.navelem { + background-image: none; + display: flex; + align-items: center; +} + +.navpath li.navelem a { + text-shadow: none; + display: inline-block; + color: var(--primary-color) !important; +} + +.navpath li.navelem b { + color: var(--primary-dark-color); + font-weight: 500; +} + +li.navelem { + padding: 0; + margin-left: -8px; +} + +li.navelem:first-child { + margin-left: var(--spacing-large); +} + +li.navelem:first-child:before { + display: none; +} + +#nav-path li.navelem:after { + content: ''; + border: 5px solid var(--page-background-color); + border-bottom-color: transparent; + border-right-color: transparent; + border-top-color: transparent; + transform: translateY(-1px) scaleY(4.2); + z-index: 10; + margin-left: 6px; +} + +#nav-path li.navelem:before { + content: ''; + border: 5px solid var(--separator-color); + border-bottom-color: transparent; + border-right-color: transparent; + border-top-color: transparent; + transform: translateY(-1px) scaleY(3.2); + margin-right: var(--spacing-small); +} + +.navpath li.navelem a:hover { + color: var(--primary-color); +} + +/* + Scrollbars for Webkit +*/ + +#nav-tree::-webkit-scrollbar, +div.fragment::-webkit-scrollbar, +pre.fragment::-webkit-scrollbar, +div.memproto::-webkit-scrollbar, +.contents center::-webkit-scrollbar, +.contents .center::-webkit-scrollbar, +.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname) tbody::-webkit-scrollbar, +div.contents .toc::-webkit-scrollbar { + background: transparent; + width: calc(var(--webkit-scrollbar-size) + var(--webkit-scrollbar-padding) + var(--webkit-scrollbar-padding)); + height: calc(var(--webkit-scrollbar-size) + var(--webkit-scrollbar-padding) + var(--webkit-scrollbar-padding)); +} + +#nav-tree::-webkit-scrollbar-thumb, +div.fragment::-webkit-scrollbar-thumb, +pre.fragment::-webkit-scrollbar-thumb, +div.memproto::-webkit-scrollbar-thumb, +.contents center::-webkit-scrollbar-thumb, +.contents .center::-webkit-scrollbar-thumb, +.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname) tbody::-webkit-scrollbar-thumb, +div.contents .toc::-webkit-scrollbar-thumb { + background-color: transparent; + border: var(--webkit-scrollbar-padding) solid transparent; + border-radius: calc(var(--webkit-scrollbar-padding) + var(--webkit-scrollbar-padding)); + background-clip: padding-box; +} + +#nav-tree:hover::-webkit-scrollbar-thumb, +div.fragment:hover::-webkit-scrollbar-thumb, +pre.fragment:hover::-webkit-scrollbar-thumb, +div.memproto:hover::-webkit-scrollbar-thumb, +.contents center:hover::-webkit-scrollbar-thumb, +.contents .center:hover::-webkit-scrollbar-thumb, +.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname) tbody:hover::-webkit-scrollbar-thumb, +div.contents .toc:hover::-webkit-scrollbar-thumb { + background-color: var(--webkit-scrollbar-color); +} + +#nav-tree::-webkit-scrollbar-track, +div.fragment::-webkit-scrollbar-track, +pre.fragment::-webkit-scrollbar-track, +div.memproto::-webkit-scrollbar-track, +.contents center::-webkit-scrollbar-track, +.contents .center::-webkit-scrollbar-track, +.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname) tbody::-webkit-scrollbar-track, +div.contents .toc::-webkit-scrollbar-track { + background: transparent; +} + +#nav-tree::-webkit-scrollbar-corner { + background-color: var(--side-nav-background); +} + +#nav-tree, +div.fragment, +pre.fragment, +div.memproto, +.contents center, +.contents .center, +.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname) tbody, +div.contents .toc { + overflow-x: auto; + overflow-x: overlay; +} + +#nav-tree { + overflow-x: auto; + overflow-y: auto; + overflow-y: overlay; +} + +/* + Scrollbars for Firefox +*/ + +#nav-tree, +div.fragment, +pre.fragment, +div.memproto, +.contents center, +.contents .center, +.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname) tbody, +div.contents .toc { + scrollbar-width: thin; +} + +/* + Optional Dark mode toggle button +*/ + +doxygen-awesome-dark-mode-toggle { + display: inline-block; + margin: 0 0 0 var(--spacing-small); + padding: 0; + width: var(--searchbar-height); + height: var(--searchbar-height); + background: none; + border: none; + border-radius: var(--searchbar-height); + vertical-align: middle; + text-align: center; + line-height: var(--searchbar-height); + font-size: 22px; + display: flex; + align-items: center; + justify-content: center; + user-select: none; + cursor: pointer; +} + +doxygen-awesome-dark-mode-toggle > svg { + transition: transform .1s ease-in-out; +} + +doxygen-awesome-dark-mode-toggle:active > svg { + transform: scale(.5); +} + +doxygen-awesome-dark-mode-toggle:hover { + background-color: rgba(0,0,0,.03); +} + +html.dark-mode doxygen-awesome-dark-mode-toggle:hover { + background-color: rgba(0,0,0,.18); +} + +/* + Optional fragment copy button +*/ +.doxygen-awesome-fragment-wrapper { + position: relative; +} + +doxygen-awesome-fragment-copy-button { + opacity: 0; + background: var(--fragment-background); + width: 28px; + height: 28px; + position: absolute; + right: calc(var(--spacing-large) - (var(--spacing-large) / 2.5)); + top: calc(var(--spacing-large) - (var(--spacing-large) / 2.5)); + border: 1px solid var(--fragment-foreground); + cursor: pointer; + border-radius: var(--border-radius-small); + display: flex; + justify-content: center; + align-items: center; +} + +.doxygen-awesome-fragment-wrapper:hover doxygen-awesome-fragment-copy-button, doxygen-awesome-fragment-copy-button.success { + opacity: .28; +} + +doxygen-awesome-fragment-copy-button:hover, doxygen-awesome-fragment-copy-button.success { + opacity: 1 !important; +} + +doxygen-awesome-fragment-copy-button:active:not([class~=success]) svg { + transform: scale(.91); +} + +doxygen-awesome-fragment-copy-button svg { + fill: var(--fragment-foreground); + width: 18px; + height: 18px; +} + +doxygen-awesome-fragment-copy-button.success svg { + fill: rgb(14, 168, 14); +} + +doxygen-awesome-fragment-copy-button.success { + border-color: rgb(14, 168, 14); +} + +@media screen and (max-width: 767px) { + .textblock > .doxygen-awesome-fragment-wrapper > doxygen-awesome-fragment-copy-button, + .textblock li > .doxygen-awesome-fragment-wrapper > doxygen-awesome-fragment-copy-button, + .memdoc li > .doxygen-awesome-fragment-wrapper > doxygen-awesome-fragment-copy-button, + .memdoc > .doxygen-awesome-fragment-wrapper > doxygen-awesome-fragment-copy-button, + dl dd > .doxygen-awesome-fragment-wrapper > doxygen-awesome-fragment-copy-button { + right: 0; + } +} + +/* + Optional paragraph link button +*/ + +a.anchorlink { + font-size: 90%; + margin-left: var(--spacing-small); + color: var(--page-foreground-color) !important; + text-decoration: none; + opacity: .15; + display: none; + transition: opacity .1s ease-in-out, color .1s ease-in-out; +} + +a.anchorlink svg { + fill: var(--page-foreground-color); +} + +h3 a.anchorlink svg, h4 a.anchorlink svg { + margin-bottom: -3px; + margin-top: -4px; +} + +a.anchorlink:hover { + opacity: .45; +} + +h2:hover a.anchorlink, h1:hover a.anchorlink, h3:hover a.anchorlink, h4:hover a.anchorlink { + display: inline-block; +} + + +#MSearchBox .left { + background: none !important; +} +#MSearchBox .right { + background: none !important; +} diff --git a/dev/resources/iso-normes/qr-bar-codes/barcode_EAN13.txt b/dev/resources/iso-normes/qr-bar-codes/barcode_EAN13.txt index e8000035788..549c6e29a1d 100644 --- a/dev/resources/iso-normes/qr-bar-codes/barcode_EAN13.txt +++ b/dev/resources/iso-normes/qr-bar-codes/barcode_EAN13.txt @@ -10,8 +10,7 @@ Signification des chiffres. - 1 chiffre pour la somme de controle Cette regle subit de nombreuses entorses pour ameliorer l'usage des chiffres disponibles. -Voici la liste des codes pays ou systeme : - +Voici la liste des codes pays ou systeme, les préfixes qui ne sont pas explicitement mentionnés sont réservés par GS1 : EN @@ -25,105 +24,139 @@ Meaning of the numbers: This rule has been twisted many times to improve the use of the available numbers. -Here is the list of country codes or system: +Here is the list of country codes or system, prefixes not explicitly listed are reserved by GS1: -List -==== +List (https://www.gs1.org/prefixes) +=================================== -00 - 13 UCC (U.S.A / États-Unis & Canada) -20 - 29 Flag for internal numbering / Codification interne en magasin -30 - 37 GENCOD-EAN France -380 BCCI (Bulgaria) -383 SANA (Slovenia) -385 CRO-EAN (Croatia) -387 EAN-BIH (Bosnia-Herzegovina) -400-440 CCG (DE/Germany/Allemagne) -45 + 49 Distribution Code Center - DCC (Japan) -460-469 UNISCAN - EAN Russia (Federation de Russie) -471 CAN Taiwan -474 EAN Estonia -475 EAN Latvia -476 EAN Azerbaijan -477 EAN Lithuania -478 EAN Uzbekistan -479 EAN Sri Lanka -480 PANC Philippines -481 EAN Belarus -482 EAN Ukraine -484 EAN Moldova -485 EAN Armenia -486 EAN Georgia -487 EAN Kazakhstan -489 HKANA Hong Kong -50 E Centre UK - United Kingdom -520 HELLCAN-EAN HELLAS - Greece -528 EAN Lebanon -529 EAN Cyprus -531 EAN-MAC (FYR Macedonia) -535 EAN Malta -539 EAN Ireland -54 ICODIF/EAN Belgium & Luxembourg -560 CODIPOR (Portugal) -569 EAN Iceland/Islande -57 EAN Denmark -590 EAN Poland -594 EAN Romania -599 H.A.P.M.H. (Hungary) -600-601 EAN South Africa -609 EAN Mauritius Island -611 EAN Morocco -613 EAN Algeria -619 Tunicode (Tunisia) -621 EAN Syria -622 EAN Egypt -625 EAN Jordan/Jordanie -626 EAN Iran -628 EAN Saudi Arabia -64 EAN Finland -690-693 ANCC - Article Numbering Centre of China -70 EAN Norge (Norvege) -729 Israeli Bar Code Association - EAN Israel -73 EAN Suede -740 EAN Guatemala -741 EAN El Salvador -742 ICCC (Honduras) -743 EAN Nicaragua -744 EAN Costa Rica Panama -746 746 EAN Republique Dominicaine -750 AMECE (Mexique) -759 EAN Venezuela -76 EAN (Schweiz, Suisse, Svizzera) -770 IAC (Colombie) -773 EAN Uruguay -775 APC - EAN Peru (Perou) -777 EAN Bolivie -779 CODIGO - EAN Argentine -780 EAN Chili -784 EAN Paraguay -786 ECOP (Equateur) -789 EAN Bresil -80 - 83 INDICOD (Italy) -84 AECOC (Espagne) -850 Camera de Comercio de la Republica de Cuba (Cuba) -858 EAN Slovaquie -859 EAN Republique Tcheque -860 EAN YU (Yougoslavie) -867 EAN DPR Korea (Coree du Nord) -869 Union of Chambers of Commerce of Turkey (Turquie) -87 EAN Nederland (Hollande) -880 EAN Korea (Coree du Sud) -885 EAN Thailande -888 SANC (Singapour) -890 EAN Inde -893 EAN Vietnam -899 EAN Indonesie -90 - 91 EAN Autriche -93 EAN Australie -94 EAN Nouvelle Zelande -955 Malaysian Article Numbering Council (MANC) - Malaisie -977 Publications sirielles (ISSN) -978 - 979 Livres (ISBN) -980 Refus de remboursement -981 - 982 Coupons (monnaie courante) -99 Coupons +0000000 Flag for internal numbering / Codification interne en magasin +00001–01999 GS1 US (U.S.A / États-Unis & Canada) +020-029 Restricted / Restreint +030-039 GS1 US (U.S.A / États-Unis & Canada) +040-049 Flag for internal numbering / Codification interne en magasin +050-059 GS1 US (U.S.A / États-Unis & Canada) +060-139 GS1 US (U.S.A / États-Unis & Canada) +300-379 GS1 France +380 GS1 Bulgaria +383 GS1 Slovenija +385 GS1 Croatia +387 GS1 BIH (Bosnia-Herzegovina) +389 GS1 Montenegro +400-440 GS1 Germany +450-459 GS1 Japan +460-469 GS1 Russia +470 GS1 Kyrgyzstan +471 GS1 Chinese Taipei +474 GS1 Estonia +475 GS1 Latvia +476 GS1 Azerbaijan +477 GS1 Lithuania +478 GS1 Uzbekistan +479 GS1 Sri Lanka +480 GS1 Philippines +481 GS1 Belarus +482 GS1 Ukraine +483 GS1 Turkmenistan +484 GS1 Moldova +485 GS1 Armenia +486 GS1 Georgia +487 GS1 Kazakstan +488 GS1 Tajikistan +489 GS1 Hong Kong, China +490-499 GS1 Japan +500-509 GS1 UK +520-521 GS1 Association Greece +528 GS1 Lebanon +529 GS1 Cyprus +530 GS1 Albania +531 GS1 Macedonia +535 GS1 Malta +539 GS1 Ireland +540-549 GS1 Belgium & Luxembourg +560 GS1 Portugal +569 GS1 Iceland +570-579 GS1 Denmark +590 GS1 Poland +594 GS1 Romania +599 GS1 Hungary +600-601 GS1 South Africa +603 GS1 Ghana +604 GS1 Senegal +607 GS1 Oman +608 GS1 Bahrain +609 GS1 Mauritius +611 GS1 Morocco +613 GS1 Algeria +615 GS1 Nigeria +616 GS1 Kenya +617 GS1 Cameroon +618 GS1 Côte d'Ivoire +619 GS1 Tunisia +620 GS1 Tanzania +621 GS1 Syria +622 GS1 Egypt +624 GS1 Libya +625 GS1 Jordan +626 GS1 Iran +627 GS1 Kuwait +628 GS1 Saudi Arabia +629 GS1 Emirates +630 GS1 Qatar +631 GS1 Namibia +640-649 GS1 Finland +690-699 GS1 China +700-709 GS1 Norway +729 GS1 Israel +730-739 GS1 Sweden +740 GS1 Guatemala +741 GS1 El Salvador +742 GS1 Honduras +743 GS1 Nicaragua +744 GS1 Costa Rica +745 GS1 Panama +746 GS1 Republica Dominicana +750 GS1 Mexico +754-755 GS1 Canada +759 GS1 Venezuela +760-769 GS1 Schweiz, Suisse, Svizzera +770-771 GS1 Colombia +773 GS1 Uruguay +775 GS1 Peru +777 GS1 Bolivia +778-779 GS1 Argentina +780 GS1 Chile +784 GS1 Paraguay +786 GS1 Ecuador +789-790 GS1 Brasil +800-839 GS1 Italy +840-849 GS1 Spain +850 GS1 Cuba +858 GS1 Slovakia +859 GS1 Czech +860 GS1 Serbia +865 GS1 Mongolia +867 GS1 North Korea +868-869 GS1 Türkiye +870-879 GS1 Netherlands +880 GS1 South Korea +883 GS1 Myanmar +884 GS1 Cambodia +885 GS1 Thailand +888 GS1 Singapore +890 GS1 India +893 GS1 Vietnam +896 GS1 Pakistan +899 GS1 Indonesia +900-919 GS1 Austria +930-939 GS1 Australia +940-949 GS1 New Zealand +950 GS1 Global Office +955 GS1 Malaysia +958 GS1 Macao, China +960-969 Global Office - GTIN-8 +977 Serial publications / Publications en série (ISSN) +978-979 Bookland / Livres (ISBN) +980 Refund receipts / Remboursements +981-983 GS1 Coupons +99 GS1 Coupons diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 21d60103135..91b7673ab81 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -47,6 +47,7 @@ $search_label = GETPOST('search_label', 'alpha'); $search_labelshort = GETPOST('search_labelshort', 'alpha'); $search_accountparent = GETPOST('search_accountparent', 'alpha'); $search_pcgtype = GETPOST('search_pcgtype', 'alpha'); +$search_import_key = GETPOST('search_import_key', 'alpha'); $toselect = GETPOST('toselect', 'array'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $confirm = GETPOST('confirm', 'alpha'); @@ -83,16 +84,19 @@ if (!$sortorder) { } $arrayfields = array( - 'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1), - 'aa.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), - 'aa.labelshort'=>array('label'=>$langs->trans("LabelToShow"), 'checked'=>1), - 'aa.account_parent'=>array('label'=>$langs->trans("Accountparent"), 'checked'=>1), - 'aa.pcg_type'=>array('label'=>$langs->trans("Pcgtype"), 'checked'=>1, 'help'=>'PcgtypeDesc'), - 'aa.reconcilable'=>array('label'=>$langs->trans("Reconcilable"), 'checked'=>1), - 'aa.active'=>array('label'=>$langs->trans("Activated"), 'checked'=>1) + 'aa.account_number'=>array('label'=>"AccountNumber", 'checked'=>1), + 'aa.label'=>array('label'=>"Label", 'checked'=>1), + 'aa.labelshort'=>array('label'=>"LabelToShow", 'checked'=>1), + 'aa.account_parent'=>array('label'=>"Accountparent", 'checked'=>1), + 'aa.pcg_type'=>array('label'=>"Pcgtype", 'checked'=>1, 'help'=>'PcgtypeDesc'), + 'categories'=>array('label'=>"AccountingCategories", 'checked'=>-1, 'help'=>'AccountingCategoriesDesc'), + 'aa.reconcilable'=>array('label'=>"Reconcilable", 'checked'=>1), + 'aa.active'=>array('label'=>"Activated", 'checked'=>1), + 'aa.import_key'=>array('label'=>"ImportId", 'checked'=>-1) ); if ($conf->global->MAIN_FEATURES_LEVEL < 2) { + unset($arrayfields['categories']); unset($arrayfields['aa.reconcilable']); } @@ -226,15 +230,12 @@ if ($action == 'delete') { $pcgver = $conf->global->CHARTOFACCOUNTS; -$sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.account_number, aa.account_parent , aa.label, aa.labelshort, aa.reconcilable, aa.active, "; +$sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.account_number, aa.account_parent, aa.label, aa.labelshort, aa.fk_accounting_category,"; +$sql .= " aa.reconcilable, aa.active, aa.import_key,"; $sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = ".$conf->entity; -if ($db->type == 'pgsql') { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity; -} else { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity; -} +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = ".((int) $conf->entity); +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".((int) $conf->entity); $sql .= " WHERE asy.rowid = ".((int) $pcgver); //print $sql; if (strlen(trim($search_account))) { @@ -337,6 +338,9 @@ if ($resql) { if ($search_pcgtype) { $param .= '&search_pcgtype='.urlencode($search_pcgtype); } + if ($optioncss != '') { + $param .= '&search_import_key='.urlencode($search_import_key); + } if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } @@ -439,8 +443,17 @@ if ($resql) { print $formaccounting->select_account($search_accountparent, 'search_accountparent', 2, array(), 0, 0, 'maxwidth150'); print ''; } + // Predefined group if (!empty($arrayfields['aa.pcg_type']['checked'])) { - print ''; + print ''; + } + // Custom groups + if (!empty($arrayfields['categories']['checked'])) { + print ''; + } + // Import key + if (!empty($arrayfields['aa.import_key']['checked'])) { + print ''; } if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['aa.reconcilable']['checked'])) { @@ -471,6 +484,12 @@ if ($resql) { if (!empty($arrayfields['aa.pcg_type']['checked'])) { print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type,aa.account_number', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help'], 1); } + if (!empty($arrayfields['categories']['checked'])) { + print_liste_field_titre($arrayfields['categories']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, '', $arrayfields['categories']['help'], 1); + } + if (!empty($arrayfields['aa.import_key']['checked'])) { + print_liste_field_titre($arrayfields['aa.import_key']['label'], $_SERVER["PHP_SELF"], 'aa.import_key', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.import_key']['help'], 1); + } if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['aa.reconcilable']['checked'])) { print_liste_field_titre($arrayfields['aa.reconcilable']['label'], $_SERVER["PHP_SELF"], 'aa.reconcilable', '', $param, '', $sortfield, $sortorder); @@ -505,7 +524,7 @@ if ($resql) { // Account label if (!empty($arrayfields['aa.label']['checked'])) { print ""; - print $obj->label; + print dol_escape_htmltag($obj->label); print "\n"; if (!$i) { $totalarray['nbfield']++; @@ -515,7 +534,7 @@ if ($resql) { // Account label to show (label short) if (!empty($arrayfields['aa.labelshort']['checked'])) { print ""; - print $obj->labelshort; + print dol_escape_htmltag($obj->labelshort); print "\n"; if (!$i) { $totalarray['nbfield']++; @@ -549,10 +568,30 @@ if ($resql) { } } - // Chart of accounts type + // Predefined group (deprecated) if (!empty($arrayfields['aa.pcg_type']['checked'])) { print ""; - print $obj->pcg_type; + print dol_escape_htmltag($obj->pcg_type); + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Custom accounts + if (!empty($arrayfields['categories']['checked'])) { + print ""; + // TODO Get all custom groups labels the account is in + print dol_escape_htmltag($obj->fk_accounting_category); + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Import id + if (!empty($arrayfields['aa.import_key']['checked'])) { + print ""; + print dol_escape_htmltag($obj->import_key); print "\n"; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index 02921a78cb2..c5b8fd20045 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -640,7 +640,8 @@ if ($id) { foreach ($fieldlist as $field => $value) { $showfield = 1; $class = "left"; - $valuetoshow = $obj->{$fieldlist[$field]}; + $tmpvar = $fieldlist[$field]; + $valuetoshow = $obj->$tmpvar; if ($value == 'type_template') { $valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow; } diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 97d2509b898..43d1852c720 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -282,7 +282,7 @@ if ($action == 'create') { print $form->textwithpicto($langs->trans("AccountingCategory"), $langs->transnoentitiesnoconv("AccountingAccountGroupsDesc")); print ''; print ''; - $formaccounting->select_accounting_category($object->account_category, 'account_category', 1, 0, 1); + print $formaccounting->select_accounting_category($object->account_category, 'account_category', 1, 0, 1); print ''; print ''; @@ -359,7 +359,7 @@ if ($action == 'create') { print $form->textwithpicto($langs->trans("AccountingCategory"), $langs->transnoentitiesnoconv("AccountingAccountGroupsDesc")); print ''; print ''; - $formaccounting->select_accounting_category($object->account_category, 'account_category', 1); + print $formaccounting->select_accounting_category($object->account_category, 'account_category', 1); print ''; print ''; diff --git a/htdocs/accountancy/admin/categories.php b/htdocs/accountancy/admin/categories.php index 442c0d6763b..7b660419daf 100644 --- a/htdocs/accountancy/admin/categories.php +++ b/htdocs/accountancy/admin/categories.php @@ -45,6 +45,26 @@ if ($cat_id == 0) { $cat_id = null; } +// Load variable for pagination +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + // If $page is not defined, or '' or -1 or if we click on clear filters + $page = 0; +} +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; + +if (empty($sortfield)) { + $sortfield = 'account_number'; +} +if (empty($sortorder)) { + $sortorder = 'ASC'; +} + // Security check if (!$user->hasRight('accounting', 'chartofaccount')) { accessforbidden(); @@ -111,7 +131,7 @@ print ''; // Select the category print ''; print ''; @@ -137,14 +157,6 @@ if (!empty($cat_id)) { if (is_array($accountingcategory->lines_cptbk) && count($accountingcategory->lines_cptbk) > 0) { print img_picto($langs->trans("AccountingAccount"), 'accounting_account', 'class="pictofixedwith"'); print $form->multiselectarray('cpt_bk', $arraykeyvalue, GETPOST('cpt_bk', 'array'), null, null, '', 0, "80%", '', '', $langs->transnoentitiesnoconv("AddAccountFromBookKeepingWithNoCategories")); - //print '
'; - /*print '
'; - print ajax_combobox('cpt_bk'); - */ print ' '; } } @@ -152,13 +164,16 @@ if (!empty($cat_id)) { print ''; -if ($action == 'display' || $action == 'delete') { +if ((empty($action) || $action == 'display' || $action == 'delete') && $cat_id > 0) { + $param = 'account_category='.((int) $cat_id); + print '
'; print '
'.$langs->trans("AccountingCategory").''; -$formaccounting->select_accounting_category($cat_id, 'account_category', 1, 0, 0, 0); +print $formaccounting->select_accounting_category($cat_id, 'account_category', 1, 0, 0, 0); print ''; print '
'."\n"; print ''; - print '"; - print '"; - print "\n"; + print getTitleFieldOfList('AccountAccounting', 0, $_SERVER['PHP_SELF'], 'account_number', '', $param, '', $sortfield, $sortorder, '')."\n"; + print getTitleFieldOfList('Label', 0, $_SERVER['PHP_SELF'], 'label', '', $param, '', $sortfield, $sortorder, '')."\n"; + print getTitleFieldOfList('', 0, $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, '')."\n"; + print ''."\n"; if (!empty($cat_id)) { $return = $accountingcategory->display($cat_id); // This load ->lines_display @@ -167,6 +182,8 @@ if ($action == 'display' || $action == 'delete') { } if (is_array($accountingcategory->lines_display) && count($accountingcategory->lines_display) > 0) { + $accountingcategory->lines_display = dol_sort_array($accountingcategory->lines_display, $sortfield, $sortorder, -1, 0, 1); + foreach ($accountingcategory->lines_display as $cpt) { print ''; print ''; diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index 0e7bd908c9a..0fd7b9012eb 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -444,15 +444,37 @@ if ($search_country_id > 0) { if ($sortfield == 'country') { $sortfield = 'country_code'; } +if (empty($sortfield)) { + $sortfield = 'position'; +} + $sql .= $db->order($sortfield, $sortorder); $sql .= $db->plimit($listlimit + 1, $offset); //print $sql; $fieldlist = explode(',', $tabfield[$id]); +$param = '&id='.$id; +if ($search_country_id > 0) { + $param .= '&search_country_id='.urlencode($search_country_id); +} +$paramwithsearch = $param; +if ($sortorder) { + $paramwithsearch .= '&sortorder='.urlencode($sortorder); +} +if ($sortfield) { + $paramwithsearch .= '&sortfield='.urlencode($sortfield); +} +if (GETPOST('from', 'alpha')) { + $paramwithsearch .= '&from='.urlencode(GETPOST('from', 'alpha')); +} + print ''; print ''; print ''; +print ''; +print ''; + print '
'; print '
'.$langs->trans("AccountAccounting")."'.$langs->trans("Label")."
'.length_accountg($cpt->account_number).'
'; @@ -571,20 +593,6 @@ if ($resql) { $num = $db->num_rows($resql); $i = 0; - $param = '&id='.$id; - if ($search_country_id > 0) { - $param .= '&search_country_id='.urlencode($search_country_id); - } - $paramwithsearch = $param; - if ($sortorder) { - $paramwithsearch .= '&sortorder='.$sortorder; - } - if ($sortfield) { - $paramwithsearch .= '&sortfield='.$sortfield; - } - if (GETPOST('from', 'alpha')) { - $paramwithsearch .= '&from='.GETPOST('from', 'alpha'); - } // There is several pages if ($num > $listlimit) { print ''; print '
'; @@ -743,7 +751,8 @@ if ($resql) { foreach ($fieldlist as $field => $value) { $showfield = 1; $class = "left"; - $valuetoshow = $obj->{$fieldlist[$field]}; + $tmpvar = $fieldlist[$field]; + $valuetoshow = $obj->$tmpvar; if ($value == 'category_type') { $valuetoshow = yn($valuetoshow); } elseif ($valuetoshow == 'all') { @@ -822,7 +831,7 @@ if ($resql) { } // Link to setup the group - print ''; + print ''; if (empty($obj->formula)) { print ''; print $langs->trans("ListOfAccounts"); diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index 9a3b63adcc3..2bd1037db39 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -84,6 +84,9 @@ $list_account[] = 'ACCOUNTING_VAT_PAY_ACCOUNT'; if (isModEnabled('banque')) { $list_account[] = 'ACCOUNTING_ACCOUNT_TRANSFER_CASH'; } +if (!empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) { + $list_account[] = 'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY'; +} if (isModEnabled('don')) { $list_account[] = 'DONATION_ACCOUNTINGACCOUNT'; } diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 385c105451e..3a7be3e073e 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -261,6 +261,20 @@ if ($action == 'setenablelettering') { } } +if ($action == 'setenableautolettering') { + $setenableautolettering = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "ACCOUNTING_ENABLE_AUTOLETTERING", $setenableautolettering, 'yesno', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } + + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'mesgs'); + } +} + /* * View @@ -430,7 +444,7 @@ foreach ($list_binding as $key) { print $form->selectDate((!empty($conf->global->$key) ? $db->idate($conf->global->$key) : -1), $key, 0, 0, 1); } elseif ($key == 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER') { $array = array(0=>$langs->trans("PreviousMonth"), 1=>$langs->trans("CurrentMonth"), 2=>$langs->trans("Fiscalyear")); - print $form->selectarray($key, $array, (isset($conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER) ? $conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER : 0)); + print $form->selectarray($key, $array, (isset($conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER) ? $conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER : 0), 0, 0, 0, '', 0, 0, 0, '', 'onrightofpage'); } else { print ''; } @@ -479,6 +493,7 @@ if (!empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS)) { print '
'; +print '
'; // Lettering params print ''; @@ -499,6 +514,21 @@ if (!empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { } print ''; +if (!empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { + print ''; + print ''; + if (!empty($conf->global->ACCOUNTING_ENABLE_AUTOLETTERING)) { + print ''; + } else { + print ''; + } + print ''; +} + print '
' . $langs->trans("ACCOUNTING_ENABLE_AUTOLETTERING") . ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print '
'; print '
'; diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index e1a07fef5fc..ba2d867ebd6 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -587,7 +587,8 @@ if ($id) { foreach ($fieldlist as $field => $value) { $showfield = 1; $class = "left"; - $valuetoshow = $obj->{$fieldlist[$field]}; + $tmpvar = $fieldlist[$field]; + $valuetoshow = $obj->$tmpvar; if ($valuetoshow == 'all') { $valuetoshow = $langs->trans('All'); } elseif ($fieldlist[$field] == 'nature' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') { diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 01d89f1168d..fd8cd8ad688 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -1,7 +1,7 @@ * Copyright (C) 2016 Florian Henry - * Copyright (C) 2016-2022 Alexandre Spangaro + * Copyright (C) 2016-2023 Alexandre Spangaro * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -42,22 +42,13 @@ $langs->loadLangs(array("accountancy", "compta")); $action = GETPOST('action', 'aZ09'); $optioncss = GETPOST('optioncss', 'alpha'); -$contextpage = GETPOST('contextpage', 'aZ09'); - -// Load variable for pagination -$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); -$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { - $page = 0; -} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action -$offset = $limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; -//if (! $sortfield) $sortfield="p.date_fin"; -//if (! $sortorder) $sortorder="DESC"; - +$type = GETPOST('type', 'alpha'); +if ($type == 'sub') { + $context_default = 'balancesubaccountlist'; +} else { + $context_default = 'balancelist'; +} +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : $context_default; $show_subgroup = GETPOST('show_subgroup', 'alpha'); $search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int')); $search_date_end = dol_mktime(23, 59, 59, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int')); @@ -70,10 +61,29 @@ $search_accountancy_code_end = GETPOST('search_accountancy_code_end', 'alpha'); if ($search_accountancy_code_end == - 1) { $search_accountancy_code_end = ''; } +$search_not_reconciled = GETPOST('search_not_reconciled', 'alpha'); + +// Load variable for pagination +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { + $page = 0; +} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if ($sortorder == "") { + $sortorder = "ASC"; +} +if ($sortfield == "") { + $sortfield = "t.numero_compte"; +} // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new BookKeeping($db); -$hookmanager->initHooks(array('balancelist')); // Note that conf->hooks_modules contains array +$hookmanager->initHooks(array($contextpage)); // Note that conf->hooks_modules contains array $formaccounting = new FormAccounting($db); $formother = new FormOther($db); @@ -84,6 +94,7 @@ if (empty($search_date_start) && !GETPOSTISSET('formfilteraction')) { $sql .= " WHERE date_start < '".$db->idate(dol_now())."' AND date_end > '".$db->idate(dol_now())."'"; $sql .= $db->plimit(1); $res = $db->query($sql); + if ($res->num_rows > 0) { $fiscalYear = $db->fetch_object($res); $search_date_start = strtotime($fiscalYear->date_start); @@ -104,45 +115,6 @@ if (empty($search_date_start) && !GETPOSTISSET('formfilteraction')) { $search_date_end = dol_get_last_day($year_end, $month_end); } } -if ($sortorder == "") { - $sortorder = "ASC"; -} -if ($sortfield == "") { - $sortfield = "t.numero_compte"; -} - - -$param = ''; -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); -} -if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); -} - -$filter = array(); -if (!empty($search_date_start)) { - $filter['t.doc_date>='] = $search_date_start; - $param .= '&date_startmonth='.GETPOST('date_startmonth', 'int').'&date_startday='.GETPOST('date_startday', 'int').'&date_startyear='.GETPOST('date_startyear', 'int'); -} -if (!empty($search_date_end)) { - $filter['t.doc_date<='] = $search_date_end; - $param .= '&date_endmonth='.GETPOST('date_endmonth', 'int').'&date_endday='.GETPOST('date_endday', 'int').'&date_endyear='.GETPOST('date_endyear', 'int'); -} -if (!empty($search_accountancy_code_start)) { - $filter['t.numero_compte>='] = $search_accountancy_code_start; - $param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start); -} -if (!empty($search_accountancy_code_end)) { - $filter['t.numero_compte<='] = $search_accountancy_code_end; - $param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end); -} -if (!empty($search_ledger_code)) { - $filter['t.code_journal'] = $search_ledger_code; - foreach ($search_ledger_code as $code) { - $param .= '&search_ledger_code[]='.urlencode($code); - } -} if (!isModEnabled('accounting')) { accessforbidden(); @@ -154,14 +126,13 @@ if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } - - /* * Action */ -$parameters = array(); -$arrayfields = array(); +$param = ''; + +$parameters = array('socid'=>$socid); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -172,16 +143,67 @@ if (empty($reshook)) { $show_subgroup = ''; $search_date_start = ''; $search_date_end = ''; + $search_date_startyear = ''; + $search_date_startmonth = ''; + $search_date_startday = ''; + $search_date_endyear = ''; + $search_date_endmonth = ''; + $search_date_endday = ''; $search_accountancy_code_start = ''; $search_accountancy_code_end = ''; + $search_not_reconciled = ''; $search_ledger_code = array(); $filter = array(); } -} -/* - * View - */ + // Must be after the remove filter action, before the export. + $filter = array(); + + if (!empty($search_date_start)) { + $filter['t.doc_date>='] = $search_date_start; + $param .= '&date_startmonth=' . GETPOST('date_startmonth', 'int') . '&date_startday=' . GETPOST('date_startday', 'int') . '&date_startyear=' . GETPOST('date_startyear', 'int'); + } + if (!empty($search_date_end)) { + $filter['t.doc_date<='] = $search_date_end; + $param .= '&date_endmonth=' . GETPOST('date_endmonth', 'int') . '&date_endday=' . GETPOST('date_endday', 'int') . '&date_endyear=' . GETPOST('date_endyear', 'int'); + } + if (!empty($search_doc_date)) { + $filter['t.doc_date'] = $search_doc_date; + $param .= '&doc_datemonth=' . GETPOST('doc_datemonth', 'int') . '&doc_dateday=' . GETPOST('doc_dateday', 'int') . '&doc_dateyear=' . GETPOST('doc_dateyear', 'int'); + } + if (!empty($search_accountancy_code_start)) { + if ($type == 'sub') { + $filter['t.subledger_account>='] = $search_accountancy_code_start; + } else { + $filter['t.numero_compte>='] = $search_accountancy_code_start; + } + $param .= '&search_accountancy_code_start=' . urlencode($search_accountancy_code_start); + } + if (!empty($search_accountancy_code_end)) { + if ($type == 'sub') { + $filter['t.subledger_account<='] = $search_accountancy_code_end; + } else { + $filter['t.numero_compte<='] = $search_accountancy_code_end; + } + $param .= '&search_accountancy_code_end=' . urlencode($search_accountancy_code_end); + } + if (!empty($search_ledger_code)) { + $filter['t.code_journal'] = $search_ledger_code; + foreach ($search_ledger_code as $code) { + $param .= '&search_ledger_code[]=' . urlencode($code); + } + } + if (!empty($search_not_reconciled)) { + $filter['t.reconciled_option'] = $search_not_reconciled; + $param .= '&search_not_reconciled='.urlencode($search_not_reconciled); + } + + // param with type of list + $url_param = substr($param, 1); // remove first "&" + if (!empty($type)) { + $param = '&type=' . $type . $param; + } +} if ($action == 'export_csv') { $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; @@ -190,14 +212,23 @@ if ($action == 'export_csv') { $type_export = 'balance'; include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; - $result = $object->fetchAllBalance($sortorder, $sortfield, $limit, 0, $filter); + if ($type == 'sub') { + $result = $object->fetchAllBalance($sortorder, $sortfield, $limit, 0, $filter, 'AND', 1); + } else { + $result = $object->fetchAllBalance($sortorder, $sortfield, $limit, 0, $filter); + } if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } foreach ($object->lines as $line) { - print '"'.length_accountg($line->numero_compte).'"'.$sep; - print '"'.$object->get_compte_desc($line->numero_compte).'"'.$sep; + if ($type == 'sub') { + print '"' . length_accounta($line->subledger_account) . '"' . $sep; + print '"' . $line->subledger_label . '"' . $sep; + } else { + print '"' . length_accountg($line->numero_compte) . '"' . $sep; + print '"' . $object->get_compte_desc($line->numero_compte) . '"' . $sep; + } print '"'.price($line->debit).'"'.$sep; print '"'.price($line->credit).'"'.$sep; print '"'.price($line->debit - $line->credit).'"'.$sep; @@ -207,8 +238,15 @@ if ($action == 'export_csv') { exit; } +/* + * View + */ -$title_page = $langs->trans("AccountBalance"); +if ($type == 'sub') { + $title_page = $langs->trans("AccountBalanceSubAccount"); +} else { + $title_page = $langs->trans("AccountBalance"); +} llxHeader('', $title_page); @@ -217,39 +255,52 @@ if ($action != 'export_csv') { // List $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter); + if ($type == 'sub') { + $nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter, 'AND', 1); + } else { + $nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter); + } + if ($nbtotalofrecords < 0) { setEventMessages($object->error, $object->errors, 'errors'); } } - $result = $object->fetchAllBalance($sortorder, $sortfield, $limit, $offset, $filter); + if ($type == 'sub') { + $result = $object->fetchAllBalance($sortorder, $sortfield, $limit, $offset, $filter, 'AND', 1); + } else { + $result = $object->fetchAllBalance($sortorder, $sortfield, $limit, $offset, $filter); + } + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } print ''; + print ''; + print ''; if ($optioncss != '') { print ''; } - print ''; print ''; - print ''; + print ''; print ''; print ''; + print ''; print ''; $parameters = array(); - $reshook = $hookmanager->executeHooks('addMoreActionsButtonsList', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } - $button = empty($hookmanager->resPrint) ? '' : $hookmanager->resPrint; + $newcardbutton = empty($hookmanager->resPrint) ? '' : $hookmanager->resPrint; if (empty($reshook)) { - $button .= 'global->ACCOUNTING_EXPORT_FORMAT.')" />'; + $newcardbutton = 'global->ACCOUNTING_EXPORT_FORMAT.')" />'; print ''; + + if ($type == 'sub') { + $newcardbutton .= dolGetButtonTitle($langs->trans('AccountBalance')." - ".$langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/balance.php?' . $url_param, '', 1, array('morecss' => 'marginleftonly')); + $newcardbutton .= dolGetButtonTitle($langs->trans('AccountBalance')." - ".$langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/balance.php?type=sub&' . $url_param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); + } else { + $newcardbutton .= dolGetButtonTitle($langs->trans('AccountBalance')." - ".$langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/balance.php?' . $url_param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); + $newcardbutton .= dolGetButtonTitle($langs->trans('AccountBalance')." - ".$langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/balance.php?type=sub&' . $url_param, '', 1, array('morecss' => 'marginleftonly')); + } + $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create'); + } + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); } - print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $button, $result, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); + print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); $selectedfields = ''; + // Warning to explain why list of record is not consistent with the other list view (missing a lot of lines) + if ($type == 'sub') { + print info_admin($langs->trans("WarningRecordWithoutSubledgerAreExcluded")); + } + $moreforfilter = ''; $moreforfilter .= '
'; @@ -275,18 +346,38 @@ if ($action != 'export_csv') { $moreforfilter .= $form->selectDate($search_date_start ? $search_date_start : -1, 'date_start', 0, 0, 1, '', 1, 0); $moreforfilter .= $langs->trans('DateEnd').': '; $moreforfilter .= $form->selectDate($search_date_end ? $search_date_end : -1, 'date_end', 0, 0, 1, '', 1, 0); - - $moreforfilter .= ' - '; - $moreforfilter .= ': '; - $moreforfilter .= ''; - $moreforfilter .= '
'; $moreforfilter .= '
'; + $moreforfilter .= ': '; + $moreforfilter .= ''; + $moreforfilter .= '
'; - $moreforfilter .= $langs->trans("Journal"); + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans("Journals").': '; $moreforfilter .= $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1); + $moreforfilter .= '
'; + $moreforfilter .= '
'; + $moreforfilter .= '
'; + // Accountancy account + $moreforfilter .= $langs->trans('AccountAccounting').': '; + if ($type == 'sub') { + $moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), 'maxwidth200'); + } else { + $moreforfilter .= $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, 'maxwidth200', 'accounts'); + } + $moreforfilter .= ' '; + if ($type == 'sub') { + $moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), 'maxwidth200'); + } else { + $moreforfilter .= $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, 'maxwidth200', 'accounts'); + } + $moreforfilter .= '
'; + + $moreforfilter .= '
'; + $moreforfilter .= ': '; + $moreforfilter .= ''; $moreforfilter .= '
'; if (!empty($moreforfilter)) { @@ -305,9 +396,6 @@ if ($action != 'export_csv') { print ''; print ''; - print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, '', 'accounts'); - print ' '; - print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, '', 'accounts'); print ''; // Fields from hook @@ -324,6 +412,10 @@ if ($action != 'export_csv') { print ''; print_liste_field_titre("AccountAccounting", $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder); + // TODO : Retrieve the type of third party: Customer / Supplier / Employee + //if ($type == 'sub') { + // print_liste_field_titre("Type", $_SERVER['PHP_SELF'], "t.type", "", $param, "", $sortfield, $sortorder); + //} if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) { print_liste_field_titre("OpeningBalance", $_SERVER['PHP_SELF'], "", $param, "", 'class="right"', $sortfield, $sortorder); } @@ -359,7 +451,7 @@ if ($action != 'export_csv') { $sql .= " GROUP BY t.numero_compte"; $resql = $db->query($sql); - $nrows = $db->num_rows($resql); + $nrows = $resql->num_rows; $opening_balances = array(); for ($i = 0; $i < $nrows; $i++) { $arr = $resql->fetch_array(); @@ -372,11 +464,13 @@ if ($action != 'export_csv') { $accountingaccountstatic->id = 0; $accountingaccountstatic->account_number = ''; - $accountingaccountstatic->fetch(null, $line->numero_compte, true); - if (!empty($accountingaccountstatic->account_number)) { - $accounting_account = $accountingaccountstatic->getNomUrl(0, 1, 0, '', 0, -1, 0, 'accountcard'); - } else { - $accounting_account = length_accountg($line->numero_compte); + if ($type != 'sub') { + $accountingaccountstatic->fetch(null, $line->numero_compte, true); + if (!empty($accountingaccountstatic->account_number)) { + $accounting_account = $accountingaccountstatic->getNomUrl(0, 1, 1); + } else { + $accounting_account = length_accountg($line->numero_compte); + } } $link = ''; @@ -427,7 +521,7 @@ if ($action != 'export_csv') { // Show first line of a break print ''; - print ''.$line->numero_compte.($root_account_description ? ' - '.$root_account_description : '').''; + print ''.$line->numero_compte.($root_account_description ? ' - '.$root_account_description : '').''; print ''; $displayed_account = $root_account_number; @@ -438,19 +532,43 @@ if ($action != 'export_csv') { } print ''; - print ''.$accounting_account.''; + // Accounting account + if ($type == 'sub') { + print ''.$line->subledger_account.' ('.$line->subledger_label.')'; + } else { + print ''.$accounting_account.''; + } + + // Type + // TODO Retrieve the type of third party: Customer / Supplier / Employee + //if ($type == 'sub') { + // print ''; + //} + if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) { print ''.price(price2num($opening_balance, 'MT')).''; } $urlzoom = ''; - if ($line->numero_compte) { - $urlzoom = DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?search_accountancy_code_start='.urlencode($line->numero_compte).'&search_accountancy_code_end='.urlencode($line->numero_compte); - if (GETPOSTISSET('date_startmonth')) { - $urlzoom .= '&search_date_startmonth='.GETPOST('date_startmonth', 'int').'&search_date_startday='.GETPOST('date_startday', 'int').'&search_date_startyear='.GETPOST('date_startyear', 'int'); + if ($type == 'sub') { + if ($line->subledger_account) { + $urlzoom = DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?type=sub&search_accountancy_code_start=' . urlencode($line->subledger_account) . '&search_accountancy_code_end=' . urlencode($line->subledger_account); + if (GETPOSTISSET('date_startmonth')) { + $urlzoom .= '&search_date_startmonth=' . GETPOST('date_startmonth', 'int') . '&search_date_startday=' . GETPOST('date_startday', 'int') . '&search_date_startyear=' . GETPOST('date_startyear', 'int'); + } + if (GETPOSTISSET('date_endmonth')) { + $urlzoom .= '&search_date_endmonth=' . GETPOST('date_endmonth', 'int') . '&search_date_endday=' . GETPOST('date_endday', 'int') . '&search_date_endyear=' . GETPOST('date_endyear', 'int'); + } } - if (GETPOSTISSET('date_endmonth')) { - $urlzoom .= '&search_date_endmonth='.GETPOST('date_endmonth', 'int').'&search_date_endday='.GETPOST('date_endday', 'int').'&search_date_endyear='.GETPOST('date_endyear', 'int'); + } else { + if ($line->numero_compte) { + $urlzoom = DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?search_accountancy_code_start=' . urlencode($line->numero_compte) . '&search_accountancy_code_end=' . urlencode($line->numero_compte); + if (GETPOSTISSET('date_startmonth')) { + $urlzoom .= '&search_date_startmonth=' . GETPOST('date_startmonth', 'int') . '&search_date_startday=' . GETPOST('date_startday', 'int') . '&search_date_startyear=' . GETPOST('date_startyear', 'int'); + } + if (GETPOSTISSET('date_endmonth')) { + $urlzoom .= '&search_date_endmonth=' . GETPOST('date_endmonth', 'int') . '&search_date_endday=' . GETPOST('date_endday', 'int') . '&search_date_endyear=' . GETPOST('date_endyear', 'int'); + } } } // Debit diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 4620bf37e4e..42ac08383ea 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -4,6 +4,7 @@ * Copyright (C) 2013-2022 Alexandre Spangaro * Copyright (C) 2017 Laurent Destailleur * Copyright (C) 2018-2020 Frédéric France + * Copyright (C) 2022 Waël Almoman * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -44,7 +45,7 @@ $cancel = GETPOST('cancel', 'aZ09'); $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') $id = GETPOST('id', 'int'); // id of record -$mode = GETPOST('mode', 'aZ09'); // '' or '_tmp' +$mode = $mode = $action == 'create' ? "_tmp" : GETPOST('mode', 'aZ09'); // '' or '_tmp' $piece_num = GETPOST("piece_num", 'int'); // id of transaction (several lines share the same transaction id) $accountingaccount = new AccountingAccount($db); @@ -54,10 +55,15 @@ $accountingaccount_number = GETPOST('accountingaccount_number', 'alphanohtml'); $accountingaccount->fetch(null, $accountingaccount_number, true); $accountingaccount_label = $accountingaccount->label; -$journal_code = GETPOST('code_journal', 'alpha'); +$journal_code = GETPOST('code_journal', 'alpha') ? GETPOST('code_journal', 'alpha') : "NULL"; $accountingjournal->fetch(null, $journal_code); $journal_label = $accountingjournal->label; +$next_num_mvt = (int) GETPOST('next_num_mvt', 'alpha'); +$doc_ref = (string) GETPOST('doc_ref', 'alpha'); +$doc_date = (string) GETPOST('doc_date', 'alpha'); +$doc_date = $doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int')); + $subledger_account = GETPOST('subledger_account', 'alphanohtml'); if ($subledger_account == -1) { $subledger_account = null; @@ -72,6 +78,10 @@ $save = GETPOST('save', 'alpha'); if (!empty($save)) { $action = 'add'; } +$valid = GETPOST('validate', 'alpha'); +if (!empty($valid)) { + $action = 'valid'; +} $update = GETPOST('update', 'alpha'); if (!empty($update)) { $action = 'confirm_update'; @@ -156,64 +166,79 @@ if ($action == "confirm_update") { } } } -} elseif ($action == "add") { +} elseif ($action == 'add' || $action == 'valid') { $error = 0; - if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) { - $error++; - setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); - $action = ''; - } - if (empty($accountingaccount_number) || $accountingaccount_number == '-1') { - $error++; - setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors'); - $action = ''; + if (array_sum($debit) != array_sum($credit)) { + $action = 'add'; } - if (!$error) { - $object = new BookKeeping($db); + foreach ($accountingaccount_number as $key => $value) { + $accountingaccount->fetch(null, $accountingaccount_number[$key], true); + $accountingaccount_label[$key] = $accountingaccount->label[$key]; - $object->numero_compte = $accountingaccount_number; - $object->subledger_account = $subledger_account; - $object->subledger_label = $subledger_label; - $object->label_compte = $accountingaccount_label; - $object->label_operation = $label_operation; - $object->debit = $debit; - $object->credit = $credit; - $object->doc_date = (string) GETPOST('doc_date', 'alpha'); - $object->doc_type = (string) GETPOST('doc_type', 'alpha'); - $object->piece_num = $piece_num; - $object->doc_ref = (string) GETPOST('doc_ref', 'alpha'); - $object->code_journal = $journal_code; - $object->journal_label = $journal_label; - $object->fk_doc = GETPOSTINT('fk_doc'); - $object->fk_docdet = GETPOSTINT('fk_docdet'); - - if (floatval($debit) != 0.0) { - $object->montant = $debit; // deprecated - $object->amount = $debit; - $object->sens = 'D'; + // if one added row is empty remove it before continue + if ($key < 1 && (empty($accountingaccount_number[$key]) || $accountingaccount_number[$key] == '-1') || (floatval($debit[$key]) == 0.0) && (floatval($credit[$key]) == 0.0)) { + continue; } - if (floatval($credit) != 0.0) { - $object->montant = $credit; // deprecated - $object->amount = $credit; - $object->sens = 'C'; - } - - $result = $object->createStd($user, false, $mode); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } else { - if ($mode != '_tmp') { - setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); - } - - $debit = 0; - $credit = 0; - + if ((floatval($debit[$key]) != 0.0) && (floatval($credit[$key]) != 0.0)) { + $error++; + setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); $action = ''; } + + if (empty($accountingaccount_number[$key]) || $accountingaccount_number[$key] == '-1') { + $error++; + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors'); + $action = ''; + } + + if (!$error) { + $object = new BookKeeping($db); + $object->numero_compte = $accountingaccount_number[$key]; + $object->subledger_account = $subledger_account[$key]; + $object->subledger_label = $subledger_label[$key]; + $object->label_compte = $accountingaccount_label[$key]; + $object->label_operation = $label_operation[$key]; + $object->debit = price2num($debit[$key]); + $object->credit = price2num($credit[$key]); + $object->doc_date = $doc_date; + $object->doc_type = (string) GETPOST('doc_type', 'alpha'); + $object->piece_num = $piece_num; + $object->doc_ref = $doc_ref; + $object->code_journal = $journal_code; + $object->journal_label = $journal_label; + $object->fk_doc = GETPOSTINT('fk_doc'); + $object->fk_docdet = GETPOSTINT('fk_docdet'); + + if (floatval($debit[$key]) != 0.0) { + $object->montant = $object->debit; // deprecated + $object->amount = $object->debit; + $object->sens = 'D'; + } + + if (floatval($credit[$key]) != 0.0) { + $object->montant = $object->credit; // deprecated + $object->amount = $object->credit; + $object->sens = 'C'; + } + + $result = $object->createStd($user, false, $mode); + if ($result < 0) { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + if (empty($error)) { + if ($mode != '_tmp') { + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); + } + $debit = 0; + $credit = 0; + + $action = $action == 'add' ? '' : $action ; // stay in valid mode when not adding line } } elseif ($action == "confirm_delete") { $object = new BookKeeping($db); @@ -230,17 +255,28 @@ if ($action == "confirm_update") { } } $action = ''; -} elseif ($action == "confirm_create") { +} elseif ($action == 'create') { $error = 0; $object = new BookKeeping($db); + $next_num_mvt = !empty($next_num_mvt) ? $next_num_mvt : $object->getNextNumMvt('_tmp'); + $doc_ref = !empty($doc_ref) ? $doc_ref : $next_num_mvt; + + if (empty($doc_date)) { + $tmp_date = dol_getdate(dol_now()); + $_POST['doc_dateday'] = $tmp_date['mday']; + $_POST['doc_datemonth'] = $tmp_date['mon']; + $_POST['doc_dateyear'] = $tmp_date['year']; + unset($tmp_date); + } + if (!$journal_code || $journal_code == '-1') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Journal")), null, 'errors'); $action = 'create'; $error++; } - if (!GETPOST('doc_ref', 'alpha')) { + if (empty($doc_ref)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Piece")), null, 'errors'); $action = 'create'; $error++; @@ -252,8 +288,8 @@ if ($action == "confirm_update") { $object->credit = 0; $object->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int')); $object->doc_type = GETPOST('doc_type', 'alpha'); - $object->piece_num = GETPOST('next_num_mvt', 'alpha'); - $object->doc_ref = GETPOST('doc_ref', 'alpha'); + $object->piece_num = $next_num_mvt; + $object->doc_ref = $doc_ref; $object->code_journal = $journal_code; $object->journal_label = $journal_label; $object->fk_doc = 0; @@ -302,7 +338,7 @@ if ($action == 'setjournal') { } if ($action == 'setdocref') { - $refdoc = GETPOST('doc_ref', 'alpha'); + $refdoc = $doc_ref; $result = $object->updateByMvt($piece_num, 'doc_ref', $refdoc, $mode); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -333,7 +369,7 @@ if ($action == 'valid') { $html = new Form($db); $formaccounting = new FormAccounting($db); -$title = $langs->trans("CreateMvts"); +$title = $langs->trans($mode =="_tmp" ? "CreateMvts": "UpdateMvts"); llxHeader('', $title); @@ -343,28 +379,37 @@ if ($action == 'delete') { print $formconfirm; } -if ($action == 'create') { - print load_fiche_titre($title); - $object = new BookKeeping($db); - $next_num_mvt = $object->getNextNumMvt('_tmp'); +$object = new BookKeeping($db); +$result = $object->fetchPerMvt($piece_num, $mode); +if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); +} - if (empty($next_num_mvt)) { - dol_print_error('', 'Failed to get next piece number'); +if (!empty($object->piece_num)) { + $backlink = ''.$langs->trans('BackToList').''; + + print load_fiche_titre($langs->trans($mode =="_tmp" ? "CreateMvts": "UpdateMvts"), $backlink); + + print ''; if ($optioncss != '') { + print ''; } + $head = array(); + $h = 0; + $head[$h][0] = $_SERVER['PHP_SELF'].'?piece_num='.$object->piece_num.($mode ? '&mode='.$mode : ''); + $head[$h][1] = $langs->trans("Transaction"); + $head[$h][2] = 'transaction'; + $h++; - print ''; - if ($optioncss != '') { - print ''; - } - print ''; - print ''."\n"; - print ''."\n"; - print ''."\n"; + print dol_get_fiche_head($head, 'transaction', '', -1); - print dol_get_fiche_head(); + //dol_banner_tab($object, '', $backlink); - print ''; + print '
'; + print '
'; + + print '
'; + print '
'; /*print ''; print ''; @@ -374,7 +419,7 @@ if ($action == 'create') { print ''; print ''; print ''; print ''; @@ -385,294 +430,218 @@ if ($action == 'create') { print ''; print ''; - print ''; + print ''; print ''; /* print ''; print ''; - print ''; + print ''; print ''; */ print '
' . $langs->trans("NumPiece") . '
'.$langs->trans("Docdate").''; - print $html->selectDate('', 'doc_date', '', '', '', "create_mvt", 1, 1); + print $html->selectDate($doc_date, 'doc_date', '', '', '', "create_mvt", 1, 1); print '
'.$langs->trans("Piece").'
' . $langs->trans("Doctype") . '
'; - print dol_get_fiche_end(); + print ''; - print $form->buttonsSaveCancel("Create"); + print '
'; - print ''; -} else { - $object = new BookKeeping($db); - $result = $object->fetchPerMvt($piece_num, $mode); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); + print '
'; + print ''; + + // Doc type + if (!empty($object->doc_type)) { + print ''; + print ''; + print ''; + print ''; } - if (!empty($object->piece_num)) { - $backlink = ''.$langs->trans('BackToList').''; + // Date document creation + print ''; + print ''; + print ''; + print ''; - print load_fiche_titre($langs->trans("UpdateMvts"), $backlink); - - $head = array(); - $h = 0; - $head[$h][0] = $_SERVER['PHP_SELF'].'?piece_num='.$object->piece_num.($mode ? '&mode='.$mode : ''); - $head[$h][1] = $langs->trans("Transaction"); - $head[$h][2] = 'transaction'; - $h++; - - print dol_get_fiche_head($head, 'transaction', '', -1); - - //dol_banner_tab($object, '', $backlink); - - print '
'; - print '
'; - - print '
'; - print '
'.$langs->trans("Doctype").''.$object->doc_type.'
'.$langs->trans("DateCreation").''; + print $object->date_creation ? dol_print_date($object->date_creation, 'day') : ' '; + print '
'; - - // Account movement + // Don't show in tmp mode, inevitably empty + if ($mode != "_tmp") { + // Date document export print ''; - print ''; - print ''; - print ''; - - // Date - print ''; - print ''; - - // Journal - print ''; - print ''; - - // Ref document - print ''; - print ''; - - print '
'.$langs->trans("NumMvts").''.($mode == '_tmp' ? ''.$langs->trans("Draft").'' : $object->piece_num).'
'; - print ''; - if ($action != 'editdate') { - print ''; - } - print '
'; - print $langs->trans('Docdate'); - print 'piece_num).'&mode='.urlencode($mode).'">'.img_edit($langs->transnoentitiesnoconv('SetDate'), 1).'
'; - print '
'; - if ($action == 'editdate') { - print '
'; - if ($optioncss != '') { - print ''; - } - print ''; - print ''; - print ''; - print $form->selectDate($object->doc_date ? $object->doc_date : - 1, 'doc_date', '', '', '', "setdate"); - print ''; - print '
'; - } else { - print $object->doc_date ? dol_print_date($object->doc_date, 'day') : ' '; - } - print '
'; - print ''; - if ($action != 'editjournal') { - print ''; - } - print '
'; - print $langs->trans('Codejournal'); - print 'piece_num).'&mode='.urlencode($mode).'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'
'; - print '
'; - if ($action == 'editjournal') { - print '
'; - if ($optioncss != '') { - print ''; - } - print ''; - print ''; - print ''; - print $formaccounting->select_journal($object->code_journal, 'code_journal', 0, 0, array(), 1, 1); - print ''; - print '
'; - } else { - print $object->code_journal; - } - print '
'; - print ''; - if ($action != 'editdocref') { - print ''; - } - print '
'; - print $langs->trans('Piece'); - print 'piece_num).'&mode='.urlencode($mode).'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'
'; - print '
'; - if ($action == 'editdocref') { - print '
'; - if ($optioncss != '') { - print ''; - } - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - } else { - print $object->doc_ref; - } - print '
'; - - print '
'; - - print '
'; - - print '
'; - print ''; - - // Doc type - if (!empty($object->doc_type)) { - print ''; - print ''; - print ''; - print ''; - } - - // Date document creation - print ''; - print ''; + print ''; print ''; print ''; - // Don't show in tmp mode, inevitably empty - if ($mode != "_tmp") { - // Date document export - print ''; - print ''; - print ''; - print ''; - - // Date document validation - print ''; - print ''; - print ''; - print ''; - } - - // Validate - /* + // Date document validation print ''; - print ''; + print ''; print ''; + print $object->date_validation ? dol_print_date($object->date_validation, 'dayhour') : ' '; + print ''; print ''; - */ + } + // Validate + /* + print ''; + print ''; + print ''; + print ''; + */ // check data - /* - print ''; - print ''; - if ($object->doc_type == 'customer_invoice') - { - $sqlmid = 'SELECT rowid as ref'; - $sqlmid .= " FROM ".MAIN_DB_PREFIX."facture as fac"; - $sqlmid .= " WHERE fac.rowid=" . ((int) $object->fk_doc); - dol_syslog("accountancy/bookkeeping/card.php::sqlmid=" . $sqlmid, LOG_DEBUG); - $resultmid = $db->query($sqlmid); - if ($resultmid) { - $objmid = $db->fetch_object($resultmid); - $invoicestatic = new Facture($db); - $invoicestatic->fetch($objmid->ref); - $ref=$langs->trans("Invoice").' '.$invoicestatic->getNomUrl(1); - } - else dol_print_error($db); - } - print ''; - print ''; - */ - print "
'.$langs->trans("Doctype").''.$object->doc_type.'
'.$langs->trans("DateCreation").''.$langs->trans("DateExport").''; - print $object->date_creation ? dol_print_date($object->date_creation, 'day') : ' '; + print $object->date_export ? dol_print_date($object->date_export, 'dayhour') : ' '; print '
' . $langs->trans("DateExport") . ''; - print $object->date_export ? dol_print_date($object->date_export, 'dayhour') : ' '; - print '
' . $langs->trans("DateValidation") . ''; - print $object->date_validation ? dol_print_date($object->date_validation, 'dayhour') : ' '; - print '
' . $langs->trans("Status") . ''.$langs->trans("DateValidation").''; - if (empty($object->validated)) { - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; - } else { - print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; - } - print '
' . $langs->trans("Status") . ''; + if (empty($object->validated)) { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; + } else { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; + } + print '
' . $langs->trans("Control") . '' . $ref .'
\n"; - - print '
'; - - print dol_get_fiche_end(); - - print '
'; - - print '
'; - - $result = $object->fetchAllPerMvt($piece_num, $mode); // This load $object->linesmvt - - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); + /* + print ''; + print '' . $langs->trans("Control") . ''; + if ($object->doc_type == 'customer_invoice') { + $sqlmid = 'SELECT rowid as ref'; + $sqlmid .= " FROM ".MAIN_DB_PREFIX."facture as fac"; + $sqlmid .= " WHERE fac.rowid=" . ((int) $object->fk_doc); + dol_syslog("accountancy/bookkeeping/card.php::sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $invoicestatic = new Facture($db); + $invoicestatic->fetch($objmid->ref); + $ref=$langs->trans("Invoice").' '.$invoicestatic->getNomUrl(1); } else { - // List of movements - print load_fiche_titre($langs->trans("ListeMvts"), '', ''); + dol_print_error($db); + } + } + print '' . $ref .''; + print ''; + */ + print "\n"; - print '
'; - if ($optioncss != '') { - print ''; + print dol_get_fiche_end(); + + print '
'; + + print '
'; + + $result = $object->fetchAllPerMvt($piece_num, $mode); // This load $object->linesmvt + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } else { + // List of movements + print load_fiche_titre($langs->trans("ListeMvts"), '', ''); + + if ($optioncss != '') { + print ''; + } + + print ''; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + + if (count($object->linesmvt) > 0) { + print '
'; + print ''; + + $total_debit = 0; + $total_credit = 0; + + // Don't show in tmp mode, inevitably empty + if ($mode != "_tmp") { + // Date document export + print ''; + print ''; + print ''; + print ''; + + // Date document validation + print ''; + print ''; + print ''; + print ''; } - print ''; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - if (count($object->linesmvt) > 0) { - print '
'; - print '
' . $langs->trans("DateExport") . ''; + print $object->date_export ? dol_print_date($object->date_export, 'dayhour') : ' '; + print '
' . $langs->trans("DateValidation") . ''; + print $object->date_validation ? dol_print_date($object->date_validation, 'dayhour') : ' '; + print '
'; + print ''; - $total_debit = 0; - $total_credit = 0; + print_liste_field_titre("AccountAccountingShort"); + print_liste_field_titre("SubledgerAccount"); + print_liste_field_titre("LabelOperation"); + print_liste_field_titre("AccountingDebit", "", "", "", "", 'class="right"'); + print_liste_field_titre("AccountingCredit", "", "", "", "", 'class="right"'); + if (empty($object->date_validation)) { + print_liste_field_titre("Action", "", "", "", "", 'width="60"', "", "", 'center '); + } else { + print_liste_field_titre(""); + } - print ''; + print "\n"; - print_liste_field_titre("AccountAccountingShort"); - print_liste_field_titre("SubledgerAccount"); - print_liste_field_titre("LabelOperation"); - print_liste_field_titre("AccountingDebit", "", "", "", "", 'class="right"'); - print_liste_field_titre("AccountingCredit", "", "", "", "", 'class="right"'); - if (empty($object->date_validation)) { - print_liste_field_titre("Action", "", "", "", "", 'width="60"', "", "", 'center '); - } else { - print_liste_field_titre(""); - } + // In _tmp mode the first line is empty so we remove it + if ($mode == "_tmp") { + array_shift($object->linesmvt); + } - print "\n"; + // Add an empty line at the end to be able to add transaction + $line = new BookKeepingLine(); + $object->linesmvt[] = $line; - // Add an empty line if there is not yet - if (!empty($object->linesmvt[0])) { - $tmpline = $object->linesmvt[0]; - if (!empty($tmpline->numero_compte)) { - $line = new BookKeepingLine(); - $object->linesmvt[] = $line; + // Add a second line empty line if there is not yet + if (empty($object->linesmvt[1])) { + $line = new BookKeepingLine(); + $object->linesmvt[] = $line; + } + + $count_line = count($object->linesmvt); + $num_line = 0; + foreach ($object->linesmvt as $key => $line) { + $num_line++; + print ''; + $total_debit += $line->debit; + $total_credit += $line->credit; + + if ($action == 'update' && $line->id == $id) { + print ''; + print ''; + print ''; - $total_debit += $line->debit; - $total_credit += $line->credit; - - if ($action == 'update' && $line->id == $id) { - print ''; + // Add also input for subledger label + print '
subledger_label).'" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccountLabel")).'" />'; + print ''; + print ''; + print ''; + print ''; + print ''; + } elseif (empty($line->numero_compte) || (empty($line->debit) && empty($line->credit))) { + if ($action == "" || $action == 'add') { + print ''; print ''; print ''; - print ''; - print ''; - print ''; - print ''; - } elseif (empty($line->numero_compte) || (empty($line->debit) && empty($line->credit))) { - if ($action == "" || $action == 'add') { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } - } else { - print ''; - $resultfetch = $accountingaccount->fetch(null, $line->numero_compte, true); - print ''; + print ''; + print ''; + // Add button should not appear twice + if ($num_line === $count_line) { + print ''; } else { - print $line->numero_compte.' ('.$langs->trans("AccountRemovedFromCurrentChartOfAccount").')'; + print ''; } - print ''; - print ''; - print ''; - print ''; - print ''; - - print ''; } - print "\n"; - } - - $total_debit = price2num($total_debit, 'MT'); - $total_credit = price2num($total_credit, 'MT'); - - if ($total_debit != $total_credit) { - setEventMessages(null, array($langs->trans('MvtNotCorrectlyBalanced', $total_debit, $total_credit)), 'warnings'); - } - - print '
'; + print $formaccounting->select_account((GETPOSTISSET("accountingaccount_number") ? GETPOST("accountingaccount_number", "alpha") : $line->numero_compte), 'accountingaccount_number', 1, array(), 1, 1, ''); + print ''; + // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because: + // It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases. + // Also, it is not possible to use a value that is not in the list. + // Also, the label is not automatically filled when a value is selected. + if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { + print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1, 'maxwidth250', '', 'subledger_label'); + } else { + print 'subledger_account).'" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccount")).'" />'; } - } - - foreach ($object->linesmvt as $line) { - print '
label_operation).'" />debit)).'" />credit)).'" />'; + print ''."\n"; + print ''; + print ''; - print $formaccounting->select_account((GETPOSTISSET("accountingaccount_number") ? GETPOST("accountingaccount_number", "alpha") : $line->numero_compte), 'accountingaccount_number', 1, array(), 1, 1, 'minwidth200 maxwidth500'); + print $formaccounting->select_account((is_array($accountingaccount_number) ? $accountingaccount_number[$key] : $accountingaccount_number ), 'accountingaccount_number['.$key.']', 1, array(), 1, 1, ''); print ''; // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because: @@ -680,124 +649,102 @@ if ($action == 'create') { // Also, it is not possible to use a value that is not in the list. // Also, the label is not automatically filled when a value is selected. if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { - print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1, 'maxwidth250', '', 'subledger_label'); + print $formaccounting->select_auxaccount((is_array($subledger_account) ? $subledger_account[$key] : $subledger_account ), 'subledger_account['.$key.']', 1, 'maxwidth250', '', 'subledger_label'); } else { - print 'subledger_account).'" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccount")).'">'; + print ''; } - // Add also input for subledger label - print '
subledger_label).'" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccountLabel")).'">'; + print '
'; print '
label_operation).'">debit)).'">credit)).'">'; - print ''."\n"; - print ''; - print ''; - print $formaccounting->select_account('', 'accountingaccount_number', 1, array(), 1, 1, 'minwidth200 maxwidth500'); - print ''; - // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because: - // It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases. - // Also, it is not possible to use a value that is not in the list. - // Also, the label is not automatically filled when a value is selected. - if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { - print $formaccounting->select_auxaccount('', 'subledger_account', 1, 'maxwidth250', '', 'subledger_label'); - } else { - print ''; - } - print '
'; - print '
'; - if ($resultfetch > 0) { - print $accountingaccount->getNomUrl(0, 1, 1, '', 0); + print ''.length_accounta($line->subledger_account); - if ($line->subledger_label) { - print ' - '.$line->subledger_label.''; - } - print ''.$line->label_operation.''.($line->debit != 0 ? price($line->debit) : '').''.($line->credit != 0 ? price($line->credit) : '').''; - if (empty($line->date_export) && empty($line->date_validation)) { - print 'id . '&piece_num=' . urlencode($line->piece_num) . '&mode=' . urlencode($mode) . '&token=' . urlencode(newToken()) . '">'; - print img_edit('', 0, 'class="marginrightonly"'); - print '  '; - } else { - print ''; - print img_edit($langs->trans("ForbiddenTransactionAlreadyExported"), 0, 'class="marginrightonly"'); - print '  '; - } - - if (empty($line->date_validation)) { - $actiontodelete = 'delete'; - if ($mode == '_tmp' || $action != 'delmouv') { - $actiontodelete = 'confirm_delete'; - } - - print ''; - print img_delete(); - print ''; - } else { - print ''; - print img_delete($langs->trans("ForbiddenTransactionAlreadyValidated")); - print ''; - } - - print '
'; - print '
'; - - if ($mode == '_tmp' && $action == '') { - print '
'; - print '
'; - if ($total_debit == $total_credit) { - print ''.$langs->trans("ValidTransaction").''; + } else { + print ''; + $resultfetch = $accountingaccount->fetch(null, $line->numero_compte, true); + print ''; + if ($resultfetch > 0) { + print $accountingaccount->getNomUrl(0, 1, 1, '', 0); } else { - print ''; + print $line->numero_compte.' ('.$langs->trans("AccountRemovedFromCurrentChartOfAccount").')'; + } + print ''; + print ''.length_accounta($line->subledger_account); + if ($line->subledger_label) { + print ' - '.$line->subledger_label.''; + } + print ''; + print ''.$line->label_operation.''; + print ''.($line->debit != 0 ? price($line->debit) : '').''; + print ''.($line->credit != 0 ? price($line->credit) : '').''; + + print ''; + if (empty($line->date_export) && empty($line->date_validation)) { + print 'id . '&piece_num=' . urlencode($line->piece_num) . '&mode=' . urlencode($mode) . '&token=' . urlencode(newToken()) . '">'; + print img_edit('', 0, 'class="marginrightonly"'); + print '  '; + } else { + print ''; + print img_edit($langs->trans("ForbiddenTransactionAlreadyExported"), 0, 'class="marginrightonly"'); + print '  '; } - print '   '; - print ''.$langs->trans("Cancel").''; + if (empty($line->date_validation)) { + $actiontodelete = 'delete'; + if ($mode == '_tmp' || $action != 'delmouv') { + $actiontodelete = 'confirm_delete'; + } - print "
"; + print ''; + print img_delete(); + print ''; + } else { + print ''; + print img_delete($langs->trans("ForbiddenTransactionAlreadyValidated")); + print ''; + } + + print ''; } + print "\n"; } - print '
'; + $total_debit = price2num($total_debit, 'MT'); + $total_credit = price2num($total_credit, 'MT'); + + if ($total_debit != $total_credit) { + setEventMessages(null, array($langs->trans('MvtNotCorrectlyBalanced', $total_debit, $total_credit)), 'warnings'); + } + + print ''; + print ''; + + if ($mode == '_tmp' && $action == '') { + print '
'; + print '
'; + if ($total_debit == $total_credit) { + print ''; + } else { + print ''; + } + + print '   '; + print ''.$langs->trans("Cancel").''; + + print "
"; + } } - } else { - print load_fiche_titre($langs->trans("NoRecords")); + + print ''; } +} else { + print load_fiche_titre($langs->trans("NoRecords")); } print dol_get_fiche_end(); diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 9590c3551cf..ecd5668beb5 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -2,8 +2,10 @@ /* Copyright (C) 2013-2016 Olivier Geffroy * Copyright (C) 2013-2016 Florian Henry * Copyright (C) 2013-2022 Alexandre Spangaro + * Copyright (C) 2022 Lionel Vessiller * Copyright (C) 2016-2017 Laurent Destailleur * Copyright (C) 2018-2021 Frédéric France + * Copyright (C) 2022 Progiseize * * 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 @@ -102,7 +104,9 @@ if (GETPOST("button_export_file_x") || GETPOST("button_export_file.x") || GETPOS $action = 'export_file'; } -$search_accountancy_code = GETPOST("search_accountancy_code"); +$search_account_category = GETPOST('search_account_category', 'int'); + +$search_accountancy_code = GETPOST("search_accountancy_code", 'alpha'); $search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha'); if ($search_accountancy_code_start == - 1) { $search_accountancy_code_start = ''; @@ -253,6 +257,7 @@ if (empty($reshook)) { $search_doc_type = ''; $search_doc_ref = ''; $search_doc_date = ''; + $search_account_category = ''; $search_accountancy_code = ''; $search_accountancy_code_start = ''; $search_accountancy_code_end = ''; @@ -335,6 +340,20 @@ if (empty($reshook)) { $filter['t.doc_ref'] = $search_doc_ref; $param .= '&search_doc_ref='.urlencode($search_doc_ref); } + if ($search_account_category != '-1' && !empty($search_account_category)) { + require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancycategory.class.php'; + $accountingcategory = new AccountancyCategory($db); + + $listofaccountsforgroup = $accountingcategory->getCptsCat(0, 'fk_accounting_category = '.((int) $search_account_category)); + $listofaccountsforgroup2 = array(); + if (is_array($listofaccountsforgroup)) { + foreach ($listofaccountsforgroup as $tmpval) { + $listofaccountsforgroup2[] = "'".$db->escape($tmpval['id'])."'"; + } + } + $filter['t.search_accounting_code_in'] = join(',', $listofaccountsforgroup2); + $param .= '&search_account_category='.urlencode($search_account_category); + } if (!empty($search_accountancy_code)) { $filter['t.numero_compte'] = $search_accountancy_code; $param .= '&search_accountancy_code='.urlencode($search_accountancy_code); @@ -642,6 +661,9 @@ $sql .= " t.tms as date_modification,"; $sql .= " t.date_export,"; $sql .= " t.date_validated as date_validation,"; $sql .= " t.import_key"; + +$sqlfields = $sql; // $sql fields to remove for count total + $sql .= ' FROM '.MAIN_DB_PREFIX.$object->table_element.' as t'; // Manage filter $sqlwhere = array(); @@ -672,7 +694,13 @@ if (count($filter) > 0) { } elseif ($key == 't.reconciled_option') { $sqlwhere[] = 't.lettering_code IS NULL'; } elseif ($key == 't.code_journal' && !empty($value)) { - $sqlwhere[] = natural_search("t.code_journal", join(',', $value), 3, 1); + if (is_array($value)) { + $sqlwhere[] = natural_search("t.code_journal", join(',', $value), 3, 1); + } else { + $sqlwhere[] = natural_search("t.code_journal", $value, 3, 1); + } + } elseif ($key == 't.search_accounting_code_in' && !empty($value)) { + $sqlwhere[] = 't.numero_compte IN ('.$db->sanitize($value, 1).')'; } else { $sqlwhere[] = natural_search($key, $value, 0, 1); } @@ -685,9 +713,6 @@ if (empty($conf->global->ACCOUNTING_REEXPORT)) { if (count($sqlwhere) > 0) { $sql .= ' AND '.implode(' AND ', $sqlwhere); } -if (!empty($sortfield)) { - $sql .= $db->order($sortfield, $sortorder); -} //print $sql; @@ -715,58 +740,62 @@ if ($action == 'export_fileconfirm' && $user->hasRight('accounting', 'mouvements } } - $mimetype = $accountancyexport->getMimeType($formatexportset); - - top_httphead($mimetype, 1); - - // Output data on screen - $accountancyexport->export($object->lines, $formatexportset); - $notifiedexportdate = GETPOST('notifiedexportdate', 'alpha'); $notifiedvalidationdate = GETPOST('notifiedvalidationdate', 'alpha'); + $withAttachment = !empty(trim(GETPOST('notifiedexportfull', 'alphanohtml'))) ? 1 : 0; - if (!empty($accountancyexport->errors)) { - dol_print_error('', '', $accountancyexport->errors); - } elseif (!empty($notifiedexportdate) || !empty($notifiedvalidationdate)) { - // Specify as export : update field date_export or date_validated - $error = 0; - $db->begin(); + // Output data on screen or download + $result = $accountancyexport->export($object->lines, $formatexportset, $withAttachment); - if (is_array($object->lines)) { - foreach ($object->lines as $movement) { - $now = dol_now(); + $error = 0; + if ($result < 0) { + $error++; + } else { + if (!empty($notifiedexportdate) || !empty($notifiedvalidationdate)) { + if (is_array($object->lines)) { + // Specify as export : update field date_export or date_validated + $db->begin(); - $sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping"; - $sql .= " SET"; - if (!empty($notifiedexportdate) && !empty($notifiedvalidationdate)) { - $sql .= " date_export = '".$db->idate($now)."'"; - $sql .= ", date_validated = '".$db->idate($now)."'"; - } elseif (!empty($notifiedexportdate)) { - $sql .= " date_export = '".$db->idate($now)."'"; - } elseif (!empty($notifiedvalidationdate)) { - $sql .= " date_validated = '".$db->idate($now)."'"; + foreach ($object->lines as $movement) { + $now = dol_now(); + + $sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping"; + $sql .= " SET"; + if (!empty($notifiedexportdate) && !empty($notifiedvalidationdate)) { + $sql .= " date_export = '".$db->idate($now)."'"; + $sql .= ", date_validated = '".$db->idate($now)."'"; + } elseif (!empty($notifiedexportdate)) { + $sql .= " date_export = '".$db->idate($now)."'"; + } elseif (!empty($notifiedvalidationdate)) { + $sql .= " date_validated = '".$db->idate($now)."'"; + } + $sql .= " WHERE rowid = ".((int) $movement->id); + + dol_syslog("/accountancy/bookkeeping/list.php Function export_file Specify movements as exported", LOG_DEBUG); + + $result = $db->query($sql); + if (!$result) { + $error++; + break; + } } - $sql .= " WHERE rowid = ".((int) $movement->id); - dol_syslog("/accountancy/bookkeeping/list.php Function export_file Specify movements as exported", LOG_DEBUG); - - $result = $db->query($sql); - if (!$result) { + if (!$error) { + $db->commit(); + } else { $error++; - break; + $accountancyexport->errors[] = $langs->trans('NotAllExportedMovementsCouldBeRecordedAsExportedOrValidated'); + $db->rollback(); } } } - - if (!$error) { - $db->commit(); - } else { - $error++; - $db->rollback(); - dol_print_error('', $langs->trans("NotAllExportedMovementsCouldBeRecordedAsExportedOrValidated")); - } } - exit; + + if ($error) { + setEventMessages('', $accountancyexport->errors, 'errors'); + header('Location: '.$_SERVER['PHP_SELF']); + } + exit(); // download or show errors } } @@ -783,28 +812,38 @@ $title_page = $langs->trans("Operations").' - '.$langs->trans("Journals"); // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $resql = $db->query($sql); - $nbtotalofrecords = $db->num_rows($resql); - if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 + /* The fast and low memory method to get and count full list converts the sql into a sql count */ + $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); + $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); + $resql = $db->query($sqlforcount); + if ($resql) { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + } else { + dol_print_error($db); + } + + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } + $db->free($resql); } -// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. -if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) { - $num = $nbtotalofrecords; -} else { + +// Complete request and execute it with limit +$sql .= $db->order($sortfield, $sortorder); +if ($limit) { $sql .= $db->plimit($limit + 1, $offset); - - $resql = $db->query($sql); - if (!$resql) { - dol_print_error($db); - exit; - } - - $num = $db->num_rows($resql); } +$resql = $db->query($sql); +if (!$resql) { + dol_print_error($db); + exit; +} + +$num = $db->num_rows($resql); + $arrayofselected = is_array($toselect) ? $toselect : array(); // Output page @@ -854,7 +893,17 @@ if ($action == 'export_file') { $form_question['separator3'] = array('name'=>'separator3', 'type'=>'separator'); } - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', $langs->trans('ConfirmExportFile'), 'export_fileconfirm', $form_question, '', 1, 350, 600); + // add documents in an archive for accountancy export (Quadratus) + if (getDolGlobalString('ACCOUNTING_EXPORT_MODELCSV') == AccountancyExport::$EXPORT_TYPE_QUADRATUS) { + $form_question['notifiedexportfull'] = array( + 'name' => 'notifiedexportfull', + 'type' => 'checkbox', + 'label' => $langs->trans('NotifiedExportFull'), + 'value' => 'false', + ); + } + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', $langs->trans('ConfirmExportFile'), 'export_fileconfirm', $form_question, '', 1, 400, 600); } //if ($action == 'delbookkeepingyear') { @@ -997,6 +1046,12 @@ if ($massactionbutton && $contextpage != 'poslist') { } $moreforfilter = ''; +$moreforfilter .= '
'; +$moreforfilter .= $langs->trans('AccountingCategory').': '; +$moreforfilter .= '
'; +$moreforfilter .= $formaccounting->select_accounting_category($search_account_category, 'search_account_category', 1, 0, 0, 0); +$moreforfilter .= '
'; +$moreforfilter .= '
'; $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -1006,6 +1061,10 @@ if (empty($reshook)) { $moreforfilter = $hookmanager->resPrint; } +print '
'; +print $moreforfilter; +print '
'; + print '
'; print ''; @@ -1511,6 +1570,16 @@ while ($i < min($num, $limit)) { // 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 ''; +} $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 4a6e37ceb29..78aea811a5d 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -79,7 +79,8 @@ $search_date_validation_start = dol_mktime(0, 0, 0, $search_date_validation_star $search_date_validation_end = dol_mktime(23, 59, 59, $search_date_validation_endmonth, $search_date_validation_endday, $search_date_validation_endyear); $search_import_key = GETPOST("search_import_key", 'alpha'); -$search_accountancy_code = GETPOST("search_accountancy_code"); +$search_account_category = GETPOST('search_account_category', 'int'); + $search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha'); if ($search_accountancy_code_start == - 1) { $search_accountancy_code_start = ''; @@ -198,6 +199,8 @@ if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } +$error = 0; + /* * Action @@ -224,7 +227,7 @@ if (empty($reshook)) { if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers $search_doc_date = ''; - $search_accountancy_code = ''; + $search_account_category = ''; $search_accountancy_code_start = ''; $search_accountancy_code_end = ''; $search_label_account = ''; @@ -280,6 +283,20 @@ if (empty($reshook)) { $filter['t.doc_date'] = $search_doc_date; $param .= '&doc_datemonth='.GETPOST('doc_datemonth', 'int').'&doc_dateday='.GETPOST('doc_dateday', 'int').'&doc_dateyear='.GETPOST('doc_dateyear', 'int'); } + if ($search_account_category != '-1' && !empty($search_account_category)) { + require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancycategory.class.php'; + $accountingcategory = new AccountancyCategory($db); + + $listofaccountsforgroup = $accountingcategory->getCptsCat(0, 'fk_accounting_category = '.((int) $search_account_category)); + $listofaccountsforgroup2 = array(); + if (is_array($listofaccountsforgroup)) { + foreach ($listofaccountsforgroup as $tmpval) { + $listofaccountsforgroup2[] = "'".$db->escape($tmpval['id'])."'"; + } + } + $filter['t.search_accounting_code_in'] = join(',', $listofaccountsforgroup2); + $param .= '&search_account_category='.urlencode($search_account_category); + } if (!empty($search_accountancy_code_start)) { if ($type == 'sub') { $filter['t.subledger_account>='] = $search_accountancy_code_start; @@ -358,7 +375,6 @@ if (empty($reshook)) { $filter['t.import_key'] = $search_import_key; $param .= '&search_import_key='.urlencode($search_import_key); } - // param with type of list $url_param = substr($param, 1); // remove first "&" if (!empty($type)) { @@ -544,25 +560,29 @@ llxHeader('', $title_page); // List $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + // TODO Perf Replace this by a count if ($type == 'sub') { - $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter, 'AND', 1); + $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter, 'AND', 1, 1); } else { - $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter); + $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter, 'AND', 0, 1); } if ($nbtotalofrecords < 0) { setEventMessages($object->error, $object->errors, 'errors'); + $error++; } } -if ($type == 'sub') { - $result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter, 'AND', 1); -} else { - $result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter); -} +if (!$error) { + if ($type == 'sub') { + $result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter, 'AND', 1); + } else { + $result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter, 'AND', 0); + } -if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } $arrayofselected = is_array($toselect) ? $toselect : array(); @@ -711,7 +731,7 @@ if ($type == 'sub') { $moreforfilter = ''; -// Accountancy account +// Search on accountancy custom groups or account $moreforfilter .= '
'; $moreforfilter .= $langs->trans('AccountAccounting').': '; $moreforfilter .= '
'; @@ -729,6 +749,13 @@ if ($type == 'sub') { $moreforfilter .= '
'; $moreforfilter .= '
'; +$moreforfilter .= '
'; +$moreforfilter .= $langs->trans('AccountingCategory').': '; +$moreforfilter .= '
'; +$moreforfilter .= $formaccounting->select_accounting_category($search_account_category, 'search_account_category', 1, 0, 0, 0); +$moreforfilter .= '
'; +$moreforfilter .= '
'; + $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) { @@ -935,8 +962,8 @@ while ($i < min($num, $limit)) { } else { print ''; } - print ''; - print ''; + print ''; + print ''; print ''; print ''; // Show balance of last shown account @@ -945,13 +972,13 @@ while ($i < min($num, $limit)) { print ''; if ($balance > 0) { print ''; print ''; } else { print ''; print ''; } print ''; @@ -1206,8 +1233,8 @@ while ($i < min($num, $limit)) { if ($num > 0 && $colspan > 0) { print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; // Show balance of last shown account @@ -1216,22 +1243,42 @@ if ($num > 0 && $colspan > 0) { print ''; if ($balance > 0) { print ''; print ''; } else { print ''; print ''; } print ''; print ''; } + +// Clean total values to round them +if (!empty($totalarray['val']['totaldebit'])) { + $totalarray['val']['totaldebit'] = price2num($totalarray['val']['totaldebit'], 'MT'); +} +if (!empty($totalarray['val']['totalcredit'])) { + $totalarray['val']['totalcredit'] = price2num($totalarray['val']['totalcredit'], 'MT'); +} + + // 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 ''; +} $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 2f6c71dde7f..d68f4e79f5e 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -446,7 +446,7 @@ class AccountancyCategory // extends CommonObject } else { $this->error = "Error ".$this->db->lasterror(); $this->errors[] = $this->error; - dol_syslog(__METHOD__." ".implode(','.$this->errors), LOG_ERR); + dol_syslog(__METHOD__." ".implode(',', $this->errors), LOG_ERR); return -1; } @@ -488,7 +488,7 @@ class AccountancyCategory // extends CommonObject } else { $this->error = "Error ".$this->db->lasterror(); $this->errors[] = $this->error; - dol_syslog(__METHOD__." ".implode(','.$this->errors), LOG_ERR); + dol_syslog(__METHOD__." ".implode(',', $this->errors), LOG_ERR); return -1; } @@ -605,60 +605,6 @@ class AccountancyCategory // extends CommonObject } } - /** - * Function to know all custom groupd from an accounting account - * - * @return array|integer Result in table (array), -1 if KO - */ - public function getCatsCpts() - { - global $mysoc, $conf; - - if (empty($mysoc->country_id)) { - dol_print_error('', 'Call to select_accounting_account with mysoc country not yet defined'); - exit(); - } - - $sql = "SELECT t.rowid, t.account_number, t.label as account_label, cat.code, cat.position, cat.label as name_cat, cat.sens "; - $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t, ".MAIN_DB_PREFIX."c_accounting_category as cat"; - $sql .= " WHERE t.fk_accounting_category IN ( SELECT c.rowid "; - $sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c"; - $sql .= " WHERE c.active = 1"; - $sql .= " AND c.entity = ".$conf->entity; - $sql .= " AND (c.fk_country = ".((int) $mysoc->country_id)." OR c.fk_country = 0)"; - $sql .= " AND cat.rowid = t.fk_accounting_category"; - $sql .= " AND t.entity = ".$conf->entity; - $sql .= " ORDER BY cat.position ASC"; - - $resql = $this->db->query($sql); - if ($resql) { - $i = 0; - $obj = ''; - $num = $this->db->num_rows($resql); - $data = array(); - if ($num) { - while ($obj = $this->db->fetch_object($resql)) { - $name_cat = $obj->name_cat; - $data[$name_cat][$i] = array( - 'id' => $obj->rowid, - 'code' => $obj->code, - 'position' => $obj->position, - 'account_number' => $obj->account_number, - 'account_label' => $obj->account_label, - 'sens' => $obj->sens - ); - $i++; - } - } - return $data; - } else { - $this->error = "Error ".$this->db->lasterror(); - dol_syslog(__METHOD__." ".$this->error, LOG_ERR); - - return -1; - } - } - /** * Function to show result of an accounting account from the ledger with a direction and a period * @@ -678,6 +624,22 @@ class AccountancyCategory // extends CommonObject $this->sdc = 0; $this->sdcpermonth = array(); + if (is_array($cpt)) { + $listofaccount = ''; + foreach ($cpt as $cptcursor) { + if (! is_null($cptcursor)) { + if ($listofaccount) { + $listofaccount .= ","; + } + $listofaccount .= "'".$cptcursor."'"; + } + } + if (empty($listofaccount)) { + // List of account is empty, so we do no try sql request, we can say result is empty. + return 0; + } + } + $sql = "SELECT SUM(t.debit) as debit, SUM(t.credit) as credit"; if (is_array($cpt)) { $sql .= ", t.numero_compte as accountancy_account"; @@ -686,13 +648,6 @@ class AccountancyCategory // extends CommonObject //if (in_array($this->db->type, array('mysql', 'mysqli'))) $sql.=' USE INDEX idx_accounting_bookkeeping_doc_date'; $sql .= " WHERE t.entity = ".$conf->entity; if (is_array($cpt)) { - $listofaccount = ''; - foreach ($cpt as $cptcursor) { - if ($listofaccount) { - $listofaccount .= ","; - } - $listofaccount .= "'".$cptcursor."'"; - } $sql .= " AND t.numero_compte IN (".$this->db->sanitize($listofaccount, 1).")"; } else { $sql .= " AND t.numero_compte = '".$this->db->escape($cpt)."'"; @@ -709,22 +664,28 @@ class AccountancyCategory // extends CommonObject if (is_array($cpt)) { $sql .= " GROUP BY t.numero_compte"; } - //print $sql; $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); if ($num) { - $obj = $this->db->fetch_object($resql); - if ($sens == 1) { - $this->sdc = $obj->debit - $obj->credit; - } else { - $this->sdc = $obj->credit - $obj->debit; - } - if (is_array($cpt)) { - $this->sdcperaccount[$obj->accountancy_account] = $this->sdc; + $i = 0; + while ($i < $num) { + $obj = $this->db->fetch_object($resql); + if ($obj) { + if ($sens == 1) { + $this->sdc = $obj->debit - $obj->credit; + } else { + $this->sdc = $obj->credit - $obj->debit; + } + if (is_array($cpt)) { + $this->sdcperaccount[$obj->accountancy_account] = $this->sdc; + } + } + $i++; } } + return $num; } else { $this->error = "Error ".$this->db->lasterror(); @@ -734,12 +695,75 @@ class AccountancyCategory // extends CommonObject } } + /** + * Function to get an array of all active custom groups (llx_c_accunting_categories) with their accounts from the chart of account (ll_accounting_acount) + * + * @param int $catid Custom group ID + * @return array|integer Result in table (array), -1 if KO + * @see getCats(), getCptsCat() + */ + public function getCatsCpts($catid = 0) + { + global $mysoc, $conf; + + if (empty($mysoc->country_id)) { + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(__METHOD__." ".$this->error, LOG_ERR); + return -1; + } + + $sql = "SELECT t.rowid, t.account_number, t.label as account_label,"; + $sql .= " cat.code, cat.position, cat.label as name_cat, cat.sens, cat.category_type, cat.formula"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t, ".MAIN_DB_PREFIX."c_accounting_category as cat"; + $sql .= " WHERE t.fk_accounting_category IN (SELECT c.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c"; + $sql .= " WHERE c.active = 1"; + $sql .= " AND c.entity = ".$conf->entity; + $sql .= " AND (c.fk_country = ".((int) $mysoc->country_id)." OR c.fk_country = 0)"; + $sql .= " AND cat.rowid = t.fk_accounting_category"; + $sql .= " AND t.entity = ".$conf->entity; + if ($catid > 0) { + $sql .= " AND cat.rowid = ".((int) $catid); + } + $sql .= " ORDER BY cat.position ASC"; + + $resql = $this->db->query($sql); + if ($resql) { + $obj = ''; + $num = $this->db->num_rows($resql); + $data = array(); + if ($num) { + while ($obj = $this->db->fetch_object($resql)) { + $name_cat = $obj->name_cat; + $data[$name_cat][$obj->rowid] = array( + 'id' => $obj->rowid, + 'code' => $obj->code, + 'label' => $obj->label, + 'position' => $obj->position, + 'category_type' => $obj->category_type, + 'formula' => $obj->formula, + 'sens' => $obj->sens, + 'account_number' => $obj->account_number, + 'account_label' => $obj->account_label + ); + } + } + return $data; + } else { + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(__METHOD__." ".$this->error, LOG_ERR); + return -1; + } + } + /** * Return list of custom groups. + * For list + detail of accounting account, see getCatsCpt() * * @param int $categorytype -1=All, 0=Only non computed groups, 1=Only computed groups * @param int $active 1= active, 0=not active * @return array|int Array of groups or -1 if error + * @see getCatsCpts(), getCptsCat() */ public function getCats($categorytype = -1, $active = 1) { @@ -774,9 +798,10 @@ class AccountancyCategory // extends CommonObject 'rowid' => $obj->rowid, 'code' => $obj->code, 'label' => $obj->label, - 'formula' => $obj->formula, 'position' => $obj->position, 'category_type' => $obj->category_type, + 'formula' => $obj->formula, + 'sens' => $obj->sens, 'bc' => $obj->sens ); $i++; @@ -794,12 +819,15 @@ class AccountancyCategory // extends CommonObject /** - * Get all accounting account of a custom group (or a list of custom groups). + * Get all accounting account of a given custom group (or a list of custom groups). * You must choose between first parameter (personalized group) or the second (free criteria filter) * * @param int $cat_id Id if personalized accounting group/category - * @param string $predefinedgroupwhere Sql criteria filter to select accounting accounts. This value must not come from an input of a user. + * @param string $predefinedgroupwhere Sql criteria filter to select accounting accounts. This value must be sanitized and not come from an input of a user. + * Example: "pcg_type = 'EXPENSE' AND fk_pcg_version = 'xx'" + * Example: "fk_accounting_category = 99" * @return array|int Array of accounting accounts or -1 if error + * @see getCats(), getCatsCpts() */ public function getCptsCat($cat_id, $predefinedgroupwhere = '') { diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 3c45315ffa9..4c6e2d09838 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -5,13 +5,15 @@ * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2016 Pierre-Henry Favre - * Copyright (C) 2016-2021 Alexandre Spangaro + * Copyright (C) 2016-2022 Alexandre Spangaro + * Copyright (C) 2022 Lionel Vessiller * Copyright (C) 2013-2017 Olivier Geffroy * Copyright (C) 2017 Elarifr. Ari Elbaz * Copyright (C) 2017-2019 Frédéric France * Copyright (C) 2017 André Schild * Copyright (C) 2020 Guillaume Alexandre * Copyright (C) 2022 Joachim Kueter + * Copyright (C) 2022 Progiseize * * 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 @@ -36,6 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; /** @@ -313,9 +316,10 @@ class AccountancyExport * * @param array $TData Array with data * @param int $formatexportset Id of export format - * @return void + * @param int $withAttachment [=0] Not add files or 1 to have attached in an archive (ex : Quadratus) + * @return int <0 if KO, >0 OK */ - public function export(&$TData, $formatexportset) + public function export(&$TData, $formatexportset, $withAttachment = 0) { global $conf, $langs; global $search_date_end; // Used into /accountancy/tpl/export_journal.tpl.php @@ -325,8 +329,44 @@ class AccountancyExport $type_export = 'general_ledger'; global $db; // The tpl file use $db + $completefilename = ''; + $exportFile = null; + $exportFileName = ''; + $exportFilePath = ''; + $archiveFileList = array(); + if ($withAttachment == 1) { + // PHP ZIP extension must be enabled + if (!extension_loaded('zip')) { + $langs->load('install'); + $this->errors[] = $langs->trans('ErrorPHPDoesNotSupport', 'ZIP'); + return -1; + } + } else { + $mimetype = $this->getMimeType($formatexportset); + top_httphead($mimetype, 1); + } include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; + if ($withAttachment == 1 && !empty($completefilename)) { + // create export file + $tmpDir = !empty($conf->accounting->multidir_temp[$conf->entity]) ? $conf->accounting->multidir_temp[$conf->entity] : $conf->accounting->dir_temp; + $exportFileFullName = $completefilename; + $exportFileBaseName = basename($exportFileFullName); + $exportFileName = pathinfo($exportFileBaseName, PATHINFO_FILENAME); + $exportFilePath = $tmpDir.'/'.$exportFileFullName; + $exportFile = fopen($exportFilePath, 'w'); + if (!$exportFile) { + $this->errors[] = $langs->trans('ErrorFileNotFound', $exportFilePath); + return -1; + } + $archiveFileList[0] = array( + 'path' => $exportFilePath, + 'name' => $exportFileFullName, + ); + // archive name and path + $archiveFullName = $exportFileName.'.zip'; + $archivePath = $tmpDir.'/'.$archiveFullName; + } switch ($formatexportset) { case self::$EXPORT_TYPE_CONFIGURABLE: @@ -345,7 +385,7 @@ class AccountancyExport $this->exportCiel($TData); break; case self::$EXPORT_TYPE_QUADRATUS: - $this->exportQuadratus($TData); + $archiveFileList = $this->exportQuadratus($TData, $exportFile, $archiveFileList, $withAttachment); break; case self::$EXPORT_TYPE_WINFIC: $this->exportWinfic($TData); @@ -399,6 +439,69 @@ class AccountancyExport } break; } + + // create and download export file or archive + if ($withAttachment == 1) { + $error = 0; + + // close export file + if ($exportFile) { + fclose($exportFile); + } + + if (!empty($archiveFullName) && !empty($archivePath) && !empty($archiveFileList)) { + // archive files + $downloadFileMimeType = 'application/zip'; + $downloadFileFullName = $archiveFullName; + $downloadFilePath = $archivePath; + + // create archive + $archive = new ZipArchive(); + $res = $archive->open($archivePath, ZipArchive::OVERWRITE | ZipArchive::CREATE); + if ($res !== true) { + $error++; + $this->errors[] = $langs->trans('ErrorFileNotFound', $archivePath); + } + if (!$error) { + // add files + foreach ($archiveFileList as $archiveFileArr) { + $res = $archive->addFile($archiveFileArr['path'], $archiveFileArr['name']); + if (!$res) { + $error++; + $this->errors[] = $langs->trans('ErrorArchiveAddFile', $archiveFileArr['name']); + break; + } + } + } + if (!$error) { + // close archive + $archive->close(); + } + } elseif (!empty($exportFileFullName) && !empty($exportFilePath)) { + // only one file to download + $downloadFileMimeType = 'text/csv'; + $downloadFileFullName = $exportFileFullName; + $downloadFilePath = $exportFilePath; + } + + if (!$error) { + // download export file + if (!empty($downloadFileMimeType) && !empty($downloadFileFullName) && !empty($downloadFilePath)) { + header('Content-Type: '.$downloadFileMimeType); + header('Content-Disposition: attachment; filename='.$downloadFileFullName); + header('Cache-Control: Public, must-revalidate'); + header('Pragma: public'); + header('Content-Length: '.dol_filesize($downloadFilePath)); + readfileLowMemory($downloadFilePath); + } + } + + if ($error) { + return -1; + } + } + + return 1; } @@ -444,14 +547,14 @@ class AccountancyExport print $date.$separator; print $line->piece_num.$separator; print length_accountg($line->numero_compte).$separator; - print ''.$separator; + print $separator; print $line->label_operation.$separator; print $date.$separator; if ($line->sens == 'D') { print price($line->debit).$separator; - print ''.$separator; + print $separator; } elseif ($line->sens == 'C') { - print ''.$separator; + print $separator; print price($line->credit).$separator; } print $line->doc_ref.$separator; @@ -584,10 +687,13 @@ class AccountancyExport * Help : https://docplayer.fr/20769649-Fichier-d-entree-ascii-dans-quadracompta.html * In QuadraCompta | Use menu : "Outils" > "Suivi des dossiers" > "Import ASCII(Compta)" * - * @param array $TData data - * @return void + * @param array $TData Data + * @param resource $exportFile [=null] File resource to export or print if null + * @param array $archiveFileList [=array()] Archive file list : array of ['path', 'name'] + * @param bool $withAttachment [=0] Not add files or 1 to have attached in an archive + * @return array Archive file list : array of ['path', 'name'] */ - public function exportQuadratus(&$TData) + public function exportQuadratus(&$TData, $exportFile = null, $archiveFileList = array(), $withAttachment = 0) { global $conf, $db; @@ -637,7 +743,11 @@ class AccountancyExport $Tab['end_line'] = $end_line; - print implode($Tab); + if ($exportFile) { + fwrite($exportFile, implode($Tab)); + } else { + print implode($Tab); + } } $Tab = array(); @@ -708,12 +818,63 @@ class AccountancyExport // We need to keep the 10 lastest number of invoice doc_ref not the beginning part that is the unusefull almost same part // $Tab['num_piece3'] = str_pad(self::trunc($data->piece_num, 10), 10); $Tab['num_piece3'] = substr(self::trunc($data->doc_ref, 20), -10); - $Tab['filler4'] = str_repeat(' ', 73); + $Tab['reserved'] = str_repeat(' ', 10); // position 159 + $Tab['currency_amount'] = str_repeat(' ', 13); // position 169 + // get document file + $attachmentFileName = ''; + if ($withAttachment == 1) { + $attachmentFileKey = trim($data->piece_num); + if (!isset($archiveFileList[$attachmentFileKey])) { + $objectDirPath = ''; + $objectFileName = dol_sanitizeFileName($data->doc_ref); + if ($data->doc_type == 'customer_invoice') { + $objectDirPath = !empty($conf->facture->multidir_output[$conf->entity]) ? $conf->facture->multidir_output[$conf->entity] : $conf->facture->dir_output; + } elseif ($data->doc_type == 'expense_report') { + $objectDirPath = !empty($conf->expensereport->multidir_output[$conf->entity]) ? $conf->expensereport->multidir_output[$conf->entity] : $conf->factureexpensereport->dir_output; + } elseif ($data->doc_type == 'supplier_invoice') { + $objectDirPath = !empty($conf->fournisseur->facture->multidir_output[$conf->entity]) ? $conf->fournisseur->facture->multidir_output[$conf->entity] : $conf->fournisseur->facture->dir_output; + } + $arrayofinclusion = array(); + $arrayofinclusion[] = '^'.preg_quote($objectFileName, '/').'\.pdf$'; + $fileFoundList = dol_dir_list($objectDirPath.'/'.$objectFileName, 'files', 0, implode('|', $arrayofinclusion), '(\.meta|_preview.*\.png)$', 'date', SORT_DESC, 0, true); + if (!empty($fileFoundList)) { + $attachmentFileNameTrunc = str_pad(self::trunc($data->piece_num, 8), 8, '0', STR_PAD_LEFT); + foreach ($fileFoundList as $fileFound) { + if (strstr($fileFound['name'], $objectFileName)) { + $fileFoundPath = $objectDirPath.'/'.$objectFileName.'/'.$fileFound['name']; + if (file_exists($fileFoundPath)) { + $archiveFileList[$attachmentFileKey] = array( + 'path' => $fileFoundPath, + 'name' => $attachmentFileNameTrunc.'.pdf', + ); + break; + } + } + } + } + } + + if (isset($archiveFileList[$attachmentFileKey])) { + $attachmentFileName = $archiveFileList[$attachmentFileKey]['name']; + } + } + if (dol_strlen($attachmentFileName) == 12) { + $Tab['attachment'] = $attachmentFileName; // position 182 + } else { + $Tab['attachment'] = str_repeat(' ', 12); // position 182 + } + $Tab['filler4'] = str_repeat(' ', 38); $Tab['end_line'] = $end_line; - print implode($Tab); + if ($exportFile) { + fwrite($exportFile, implode($Tab)); + } else { + print implode($Tab); + } } + + return $archiveFileList; } /** diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 4accf66e154..f56932d4985 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -454,27 +454,12 @@ class AccountingJournal extends CommonObject } $sql = ""; - - // FIXME sql error with Mysql 5.7 - /*if ($in_bookkeeping == 'already' || $in_bookkeeping == 'notyet') { - $sql .= "WITH in_accounting_bookkeeping(fk_docdet) AS ("; - $sql .= " SELECT DISTINCT fk_docdet"; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping"; - $sql .= " WHERE doc_type = 'asset'"; - $sql .= ") "; - }*/ - $sql .= "SELECT ad.fk_asset AS rowid, a.ref AS asset_ref, a.label AS asset_label, a.acquisition_value_ht AS asset_acquisition_value_ht"; $sql .= ", a.disposal_date AS asset_disposal_date, a.disposal_amount_ht AS asset_disposal_amount_ht, a.disposal_subject_to_vat AS asset_disposal_subject_to_vat"; $sql .= ", ad.rowid AS depreciation_id, ad.depreciation_mode, ad.ref AS depreciation_ref, ad.depreciation_date, ad.depreciation_ht, ad.accountancy_code_debit, ad.accountancy_code_credit"; $sql .= " FROM " . MAIN_DB_PREFIX . "asset_depreciation as ad"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "asset as a ON a.rowid = ad.fk_asset"; - // FIXME sql error with Mysql 5.7 - /*if ($in_bookkeeping == 'already' || $in_bookkeeping == 'notyet') { - $sql .= " LEFT JOIN in_accounting_bookkeeping as iab ON iab.fk_docdet = ad.rowid"; - }*/ $sql .= " WHERE a.entity IN (" . getEntity('asset', 0) . ')'; // We don't share object for accountancy, we use source object sharing - // Compatibility with Mysql 5.7 if ($in_bookkeeping == 'already') { $sql .= " AND EXISTS (SELECT iab.fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS iab WHERE iab.fk_docdet = ad.rowid AND doc_type = 'asset')"; } elseif ($in_bookkeeping == 'notyet') { @@ -488,11 +473,6 @@ class AccountingJournal extends CommonObject if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { $sql .= " AND ad.depreciation_date >= '" . $this->db->idate($conf->global->ACCOUNTING_DATE_START_BINDING) . "'"; } - // Already in bookkeeping or not - // FIXME sql error with Mysql 5.7 - /*if ($in_bookkeeping == 'already' || $in_bookkeeping == 'notyet') { - $sql .= " AND iab.fk_docdet IS" . ($in_bookkeeping == 'already' ? " NOT" : "") . " NULL"; - }*/ $sql .= " ORDER BY ad.depreciation_date"; dol_syslog(__METHOD__, LOG_DEBUG); @@ -755,7 +735,7 @@ class AccountingJournal extends CommonObject } } - $journal_data[$pre_data_id] = $element; + $journal_data[(int) $pre_data_id] = $element; } unset($pre_data); diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 95ba38d20bb..897f60e8aaa 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -817,56 +817,61 @@ class BookKeeping extends CommonObject /** - * Load object in memory from the database + * Load object in memory from the database in ->lines. Or just make a simple count if $countonly=1. * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit offset limit - * @param int $offset offset limit - * @param array $filter filter array - * @param string $filtermode filter mode (AND or OR) - * @param int $option option (0: general account or 1: subaccount) - * - * @return int <0 if KO, >=0 if OK + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit offset limit + * @param int $offset offset limit + * @param array $filter filter array + * @param string $filtermode filter mode (AND or OR) + * @param int $option option (0: general account or 1: subaccount) + * @param int $countonly Do not fill the $object->lines, return only the count. + * @return int <0 if KO, Number of lines if OK */ - public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND', $option = 0) + public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND', $option = 0, $countonly = 0) { global $conf; dol_syslog(__METHOD__, LOG_DEBUG); $this->lines = array(); + $num = 0; $sql = 'SELECT'; - $sql .= ' t.rowid,'; - $sql .= " t.doc_date,"; - $sql .= " t.doc_type,"; - $sql .= " t.doc_ref,"; - $sql .= " t.fk_doc,"; - $sql .= " t.fk_docdet,"; - $sql .= " t.thirdparty_code,"; - $sql .= " t.subledger_account,"; - $sql .= " t.subledger_label,"; - $sql .= " t.numero_compte,"; - $sql .= " t.label_compte,"; - $sql .= " t.label_operation,"; - $sql .= " t.debit,"; - $sql .= " t.credit,"; - $sql .= " t.montant as amount,"; - $sql .= " t.sens,"; - $sql .= " t.multicurrency_amount,"; - $sql .= " t.multicurrency_code,"; - $sql .= " t.lettering_code,"; - $sql .= " t.date_lettering,"; - $sql .= " t.fk_user_author,"; - $sql .= " t.import_key,"; - $sql .= " t.code_journal,"; - $sql .= " t.journal_label,"; - $sql .= " t.piece_num,"; - $sql .= " t.date_creation,"; - $sql .= " t.date_export,"; - $sql .= " t.date_validated as date_validation,"; - $sql .= " t.import_key"; + if ($countonly) { + $sql .= ' COUNT(t.rowid) as nb'; + } else { + $sql .= ' t.rowid,'; + $sql .= " t.doc_date,"; + $sql .= " t.doc_type,"; + $sql .= " t.doc_ref,"; + $sql .= " t.fk_doc,"; + $sql .= " t.fk_docdet,"; + $sql .= " t.thirdparty_code,"; + $sql .= " t.subledger_account,"; + $sql .= " t.subledger_label,"; + $sql .= " t.numero_compte,"; + $sql .= " t.label_compte,"; + $sql .= " t.label_operation,"; + $sql .= " t.debit,"; + $sql .= " t.credit,"; + $sql .= " t.montant as amount,"; + $sql .= " t.sens,"; + $sql .= " t.multicurrency_amount,"; + $sql .= " t.multicurrency_code,"; + $sql .= " t.lettering_code,"; + $sql .= " t.date_lettering,"; + $sql .= " t.fk_user_author,"; + $sql .= " t.import_key,"; + $sql .= " t.code_journal,"; + $sql .= " t.journal_label,"; + $sql .= " t.piece_num,"; + $sql .= " t.date_creation,"; + $sql .= " t.date_export,"; + $sql .= " t.date_validated as date_validation,"; + $sql .= " t.import_key"; + } // Manage filter $sqlwhere = array(); if (count($filter) > 0) { @@ -880,7 +885,7 @@ class BookKeeping extends CommonObject } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { $sqlwhere[] = $key.'='.$value; } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { - $sqlwhere[] = $key.' LIKE \''.$this->db->escape($value).'%\''; + $sqlwhere[] = $key.' LIKE \''.$this->db->escapeforlike($this->db->escape($value)).'%\''; } elseif ($key == 't.date_creation>=' || $key == 't.date_creation<=') { $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; } elseif ($key == 't.date_export>=' || $key == 't.date_export<=') { @@ -897,18 +902,19 @@ class BookKeeping extends CommonObject } else { $sqlwhere[] = natural_search("t.code_journal", $value, 3, 1); } + } elseif ($key == 't.search_accounting_code_in' && !empty($value)) { + $sqlwhere[] = 't.numero_compte IN ('.$this->db->sanitize($value, 1).')'; } else { $sqlwhere[] = natural_search($key, $value, 0, 1); } } } $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql .= ' WHERE 1 = 1'; - $sql .= " AND entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features + $sql .= ' WHERE entity = ' . ((int) $conf->entity); // Do not use getEntity for accounting features if (count($sqlwhere) > 0) { $sql .= " AND ".implode(" ".$filtermode." ", $sqlwhere); } - // Affichage par compte comptable + // Filter by ledger account or subledger account if (!empty($option)) { $sql .= " AND t.subledger_account IS NOT NULL"; $sql .= " AND t.subledger_account <> ''"; @@ -919,54 +925,63 @@ class BookKeeping extends CommonObject $sortorder = 'ASC'.($sortorder ? ','.$sortorder : ''); } - $sql .= $this->db->order($sortfield, $sortorder); - if (!empty($limit)) { - $sql .= $this->db->plimit($limit + 1, $offset); + if (!$countonly) { + $sql .= $this->db->order($sortfield, $sortorder); + if (!empty($limit)) { + $sql .= $this->db->plimit($limit + 1, $offset); + } } $resql = $this->db->query($sql); if ($resql) { - $num = $this->db->num_rows($resql); + if ($countonly) { + $obj = $this->db->fetch_object($resql); + if ($obj) { + $num = $obj->nb; + } + } else { + $num = $this->db->num_rows($resql); - $i = 0; - while (($obj = $this->db->fetch_object($resql)) && (empty($limit) || $i < min($limit, $num))) { - $line = new BookKeepingLine(); + $i = 0; + while (($obj = $this->db->fetch_object($resql)) && (empty($limit) || $i < min($limit, $num))) { + $line = new BookKeepingLine(); - $line->id = $obj->rowid; + $line->id = $obj->rowid; - $line->doc_date = $this->db->jdate($obj->doc_date); - $line->doc_type = $obj->doc_type; - $line->doc_ref = $obj->doc_ref; - $line->fk_doc = $obj->fk_doc; - $line->fk_docdet = $obj->fk_docdet; - $line->thirdparty_code = $obj->thirdparty_code; - $line->subledger_account = $obj->subledger_account; - $line->subledger_label = $obj->subledger_label; - $line->numero_compte = $obj->numero_compte; - $line->label_compte = $obj->label_compte; - $line->label_operation = $obj->label_operation; - $line->debit = $obj->debit; - $line->credit = $obj->credit; - $line->montant = $obj->amount; // deprecated - $line->amount = $obj->amount; - $line->sens = $obj->sens; - $line->multicurrency_amount = $obj->multicurrency_amount; - $line->multicurrency_code = $obj->multicurrency_code; - $line->lettering_code = $obj->lettering_code; - $line->date_lettering = $obj->date_lettering; - $line->fk_user_author = $obj->fk_user_author; - $line->import_key = $obj->import_key; - $line->code_journal = $obj->code_journal; - $line->journal_label = $obj->journal_label; - $line->piece_num = $obj->piece_num; - $line->date_creation = $this->db->jdate($obj->date_creation); - $line->date_export = $this->db->jdate($obj->date_export); - $line->date_validation = $this->db->jdate($obj->date_validation); - $line->import_key = $obj->import_key; + $line->doc_date = $this->db->jdate($obj->doc_date); + $line->doc_type = $obj->doc_type; + $line->doc_ref = $obj->doc_ref; + $line->fk_doc = $obj->fk_doc; + $line->fk_docdet = $obj->fk_docdet; + $line->thirdparty_code = $obj->thirdparty_code; + $line->subledger_account = $obj->subledger_account; + $line->subledger_label = $obj->subledger_label; + $line->numero_compte = $obj->numero_compte; + $line->label_compte = $obj->label_compte; + $line->label_operation = $obj->label_operation; + $line->debit = $obj->debit; + $line->credit = $obj->credit; + $line->montant = $obj->amount; // deprecated + $line->amount = $obj->amount; + $line->sens = $obj->sens; + $line->multicurrency_amount = $obj->multicurrency_amount; + $line->multicurrency_code = $obj->multicurrency_code; + $line->lettering_code = $obj->lettering_code; + $line->date_lettering = $obj->date_lettering; + $line->fk_user_author = $obj->fk_user_author; + $line->import_key = $obj->import_key; + $line->code_journal = $obj->code_journal; + $line->journal_label = $obj->journal_label; + $line->piece_num = $obj->piece_num; + $line->date_creation = $this->db->jdate($obj->date_creation); + $line->date_export = $this->db->jdate($obj->date_export); + $line->date_validation = $this->db->jdate($obj->date_validation); + $line->import_key = $obj->import_key; - $this->lines[] = $line; + $this->lines[] = $line; - $i++; + $i++; + } } $this->db->free($resql); @@ -1139,9 +1154,10 @@ class BookKeeping extends CommonObject * @param int $offset offset limit * @param array $filter filter array * @param string $filtermode filter mode (AND or OR) + * @param int $option option (0: general account or 1: subaccount) * @return int <0 if KO, >0 if OK */ - public function fetchAllBalance($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + public function fetchAllBalance($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND', $option = 0) { global $conf; @@ -1151,6 +1167,11 @@ class BookKeeping extends CommonObject $sql = 'SELECT'; $sql .= " t.numero_compte,"; + $sql .= " t.label_compte,"; + if (!empty($option)) { + $sql .= " t.subledger_account,"; + $sql .= " t.subledger_label,"; + } $sql .= " SUM(t.debit) as debit,"; $sql .= " SUM(t.credit) as credit"; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; @@ -1176,6 +1197,8 @@ class BookKeeping extends CommonObject } else { $sqlwhere[] = natural_search("t.code_journal", $value, 3, 1); } + } elseif ($key == 't.reconciled_option') { + $sqlwhere[] = 't.lettering_code IS NULL'; } else { $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'"; } @@ -1186,7 +1209,17 @@ class BookKeeping extends CommonObject $sql .= " AND ".implode(" ".$filtermode." ", $sqlwhere); } - $sql .= ' GROUP BY t.numero_compte'; + if (!empty($option)) { + $sql .= ' AND t.subledger_account IS NOT NULL'; + $sql .= ' AND t.subledger_account != ""'; + $sql .= ' GROUP BY t.numero_compte, t.label_compte, t.subledger_account, t.subledger_label'; + $sortfield = 't.subledger_account'.($sortfield ? ','.$sortfield : ''); + $sortorder = 'ASC'.($sortfield ? ','.$sortfield : ''); + } else { + $sql .= ' GROUP BY t.numero_compte, t.label_compte'; + $sortfield = 't.numero_compte'.($sortfield ? ','.$sortfield : ''); + $sortorder = 'ASC'.($sortorder ? ','.$sortorder : ''); + } if (!empty($sortfield)) { $sql .= $this->db->order($sortfield, $sortorder); @@ -1204,6 +1237,9 @@ class BookKeeping extends CommonObject $line = new BookKeepingLine(); $line->numero_compte = $obj->numero_compte; + $line->label_compte = $obj->label_compte; + $line->subledger_account = $obj->subledger_account; + $line->subledger_label = $obj->subledger_label; $line->debit = $obj->debit; $line->credit = $obj->credit; diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 393629ae505..5f603a973c2 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -121,26 +121,12 @@ if (($action == 'clean' || $action == 'validatehistory') && $user->hasRight('acc if ($action == 'validatehistory') { $error = 0; $nbbinddone = 0; + $nbbindfailed = 0; $notpossible = 0; $db->begin(); // Now make the binding. Bind automatically only for product with a dedicated account that exists into chart of account, others need a manual bind - /*if ($db->type == 'pgsql') { - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet"; - $sql1 .= " SET fk_code_ventilation = accnt.rowid"; - $sql1 .= " FROM " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; - $sql1 .= " WHERE " . MAIN_DB_PREFIX . "facturedet.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . ((int) $conf->global->CHARTOFACCOUNTS).' AND accnt.entity = '.((int) $conf->entity); - $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_sell=accnt.account_number"; - $sql1 .= " AND " . MAIN_DB_PREFIX . "facturedet.fk_code_ventilation = 0"; - } else { - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd, " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; - $sql1 .= " SET fk_code_ventilation = accnt.rowid"; - $sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . ((int) $conf->global->CHARTOFACCOUNTS).' AND accnt.entity = '.((int) $conf->entity); - $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_sell=accnt.account_number"; - $sql1 .= " AND fd.fk_code_ventilation = 0"; - }*/ - // Customer Invoice lines (must be same request than into page list.php for manual binding) $sql = "SELECT f.rowid as facid, f.ref as ref, f.datef, f.type as ftype, f.fk_facture_source,"; $sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; @@ -281,12 +267,14 @@ if ($action == 'validatehistory') { if (!$resqlupdate) { $error++; setEventMessages($db->lasterror(), null, 'errors'); + $nbbindfailed++; break; } else { $nbbinddone++; } } else { $notpossible++; + $nbbindfailed++; } $i++; @@ -300,7 +288,10 @@ if ($action == 'validatehistory') { $db->rollback(); } else { $db->commit(); - setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone, $notpossible), null, 'mesgs'); + setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone, $notpossible), null, ($notpossible ? 'warnings' : 'mesgs')); + if ($nbbindfailed) { + setEventMessages($langs->trans('DoManualBindingForFailedRecord', $nbbindfailed), null, 'warnings'); + } } } @@ -324,7 +315,7 @@ print '
'; $y = $year_current; -$buttonbind = ''.$langs->trans("ValidateHistory").''; +$buttonbind = ''.img_picto($langs->trans("ValidateHistory"), 'link', 'class="pictofixedwidth fa-color-unset"').$langs->trans("ValidateHistory").''; print_barre_liste(img_picto('', 'unlink', 'class="paddingright fa-color-unset"').$langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1); //print load_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, ''); @@ -405,7 +396,17 @@ if ($resql) { print ''; print '
'; } print ''; @@ -558,7 +565,7 @@ print "
'.$langs->trans("NoRecordFound").'
' . $langs->trans("TotalForAccount") . ' ' . length_accountg($displayed_account_number) . ':'.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_debit, 'MT')).''.price(price2num($sous_total_credit, 'MT')).'
'.$langs->trans("Balance").':'; - print price($sous_total_debit - $sous_total_credit); + print price(price2num($sous_total_debit - $sous_total_credit, 'MT')); print ''; - print price($sous_total_credit - $sous_total_debit); + print price(price2num($sous_total_credit - $sous_total_debit, 'MT')); print '
'.$langs->trans("TotalForAccount").' '.$accountg.':'.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_debit, 'MT')).''.price(price2num($sous_total_credit, 'MT')).'
'.$langs->trans("Balance").':'; - print price($sous_total_debit - $sous_total_credit); + print price(price2num($sous_total_debit - $sous_total_credit, 'MT')); print ''; - print price($sous_total_credit - $sous_total_debit); + print price(price2num($sous_total_credit - $sous_total_debit, 'MT')); print '
'.$langs->trans("NoRecordFound").'
'; if ($row[0] == 'tobind') { - print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_year='.((int) $y), $langs->transnoentitiesnoconv("ToBind")); + $startmonth = ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1); + if ($startmonth > 12) { + $startmonth -= 12; + } + $startyear = ($startmonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y; + $endmonth = ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) + 11; + if ($endmonth > 12) { + $endmonth -= 12; + } + $endyear = ($endmonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y; + print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_date_startday=1&search_date_startmonth='.((int) $startmonth).'&search_date_startyear='.((int) $startyear).'&search_date_endday=&search_date_endmonth='.((int) $endmonth).'&search_date_endyear='.((int) $endyear), $langs->transnoentitiesnoconv("ToBind")); } else { print $row[1]; } @@ -420,6 +421,12 @@ if ($resql) { print ''; print price($row[$i]); + // Add link to make binding + if (!empty(price2num($row[$i]))) { + print ''; + print img_picto($langs->trans("ValidateHistory").' ('.$langs->trans('Month'.str_pad($cursormonth, 2, '0', STR_PAD_LEFT)).' '.$cursoryear.')', 'link', 'class="marginleft2"'); + print ''; + } print ''.price($row[14]).'
\n"; print '
'; -if ($conf->global->MAIN_FEATURES_LEVEL > 0) { // This part of code looks strange. Why showing a report that should rely on result of this step ? +if (getDolGlobalString('SHOW_TOTAL_OF_PREVIOUS_LISTS_IN_LIN_PAGE')) { // This part of code looks strange. Why showing a report that should rely on result of this step ? print '
'; print '
'; diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index 5064003c7ff..0929c9c9e24 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -101,6 +101,7 @@ if (($action == 'clean' || $action == 'validatehistory') && $user->rights->accou if ($action == 'validatehistory') { $error = 0; $nbbinddone = 0; + $nbbindfailed = 0; $notpossible = 0; $db->begin(); @@ -143,12 +144,14 @@ if ($action == 'validatehistory') { if (!$resqlupdate) { $error++; setEventMessages($db->lasterror(), null, 'errors'); + $nbbindfailed++; break; } else { $nbbinddone++; } } else { $notpossible++; + $nbbindfailed++; } $i++; @@ -162,7 +165,10 @@ if ($action == 'validatehistory') { $db->rollback(); } else { $db->commit(); - setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone, $notpossible), null, 'mesgs'); + setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone, $notpossible), null, ($notpossible ? 'warnings' : 'mesgs')); + if ($nbbindfailed) { + setEventMessages($langs->trans('DoManualBindingForFailedRecord', $nbbindfailed), null, 'warnings'); + } } } @@ -185,7 +191,7 @@ print '
'; $y = $year_current; -$buttonbind = ''.$langs->trans("ValidateHistory").''; +$buttonbind = ''.img_picto('', 'link', 'class="paddingright fa-color-unset"').$langs->trans("ValidateHistory").''; print_barre_liste(img_picto('', 'unlink', 'class="paddingright fa-color-unset"').$langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1); @@ -263,20 +269,49 @@ if ($resql) { print ''; print ''; if ($row[0] == 'tobind') { - print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.((int) $y), $langs->transnoentitiesnoconv("ToBind")); + $startmonth = ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1); + if ($startmonth > 12) { + $startmonth -= 12; + } + $startyear = ($startmonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y; + $endmonth = ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) + 11; + if ($endmonth > 12) { + $endmonth -= 12; + } + $endyear = ($endmonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y; + print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_date_startday=1&search_date_startmonth='.((int) $startmonth).'&search_date_startyear='.((int) $startyear).'&search_date_endday=&search_date_endmonth='.((int) $endmonth).'&search_date_endyear='.((int) $endyear), $langs->transnoentitiesnoconv("ToBind")); } else { print $row[1]; } print ''; for ($i = 2; $i <= 13; $i++) { + $cursormonth = (($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) + $i - 2); + if ($cursormonth > 12) { + $cursormonth -= 12; + } + $cursoryear = ($cursormonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y; + $tmp = dol_getdate(dol_get_last_day($cursoryear, $cursormonth, 'gmt'), false, 'gmt'); + print ''; print price($row[$i]); + // Add link to make binding + if (!empty(price2num($row[$i]))) { + print ''; + print img_picto($langs->trans("ValidateHistory").' ('.$langs->trans('Month'.str_pad($cursormonth, 2, '0', STR_PAD_LEFT)).' '.$cursoryear.')', 'link', 'class="marginleft2"'); + print ''; + } print ''; } print ''.price($row[14]).''; print ''; } $db->free($resql); + + if ($num == 0) { + print ''; + print ''.$langs->trans("NoRecordFound").''; + print ''; + } } else { print $db->lasterror(); // Show last sql error } @@ -359,6 +394,12 @@ if ($resql) { print ''; } $db->free($resql); + + if ($num == 0) { + print ''; + print ''.$langs->trans("NoRecordFound").''; + print ''; + } } else { print $db->lasterror(); // Show last sql error } @@ -367,7 +408,7 @@ print ''; -if ($conf->global->MAIN_FEATURES_LEVEL > 0) { // This part of code looks strange. Why showing a report where results depends on next step (so not yet available) ? +if (getDolGlobalString('SHOW_TOTAL_OF_PREVIOUS_LISTS_IN_LIN_PAGE')) { // This part of code looks strange. Why showing a report that should rely on result of this step ? print '
'; print '
'; diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 4aba6bfeda4..699002395ab 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -793,7 +793,7 @@ if (!$error && $action == 'writebookkeeping') { setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } } else { - if ($lettering && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) { + if ($lettering && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && getDolGlobalInt('ACCOUNTING_ENABLE_AUTOLETTERING')) { require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; $lettering_static = new Lettering($db); $nb_lettering = $lettering_static->bookkeepingLetteringAll(array($bookkeeping->id)); diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index a5b82e7b2d0..746383fef0b 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -376,7 +376,7 @@ if ($action == 'writebookkeeping') { setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } } else { - if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) { + if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && getDolGlobalInt('ACCOUNTING_ENABLE_AUTOLETTERING')) { require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; $lettering_static = new Lettering($db); $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id)); diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 0519762baef..666024833d0 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -4,7 +4,7 @@ * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2012 Regis Houssin * Copyright (C) 2013 Christophe Battarel - * Copyright (C) 2013-2021 Alexandre Spangaro + * Copyright (C) 2013-2022 Alexandre Spangaro * Copyright (C) 2013-2016 Florian Henry * Copyright (C) 2013-2016 Olivier Geffroy * Copyright (C) 2014 Raphaël Doursenaud @@ -106,7 +106,7 @@ if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end)) $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); } -$sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.ref_client, f.date_lim_reglement as dlr, f.close_code,"; +$sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.ref_client, f.date_lim_reglement as dlr, f.close_code, f.retained_warranty,"; $sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code,"; $sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur,"; if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { @@ -168,6 +168,7 @@ if ($result) { $tabht = array(); $tabtva = array(); $def_tva = array(); + $tabwarranty = array(); $tabttc = array(); $tablocaltax1 = array(); $tablocaltax2 = array(); @@ -248,7 +249,13 @@ if ($result) { $tablocaltax2[$obj->rowid][$compta_localtax2] = 0; } - $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc * $situation_ratio; + $total_ttc = $obj->total_ttc * $situation_ratio; + if (!empty($conf->global->INVOICE_USE_RETAINED_WARRANTY) && $obj->retained_warranty > 0) { + $retained_warranty = (double) price2num($total_ttc * $obj->retained_warranty / 100, 'MT'); + $tabwarranty[$obj->rowid][$compta_soc] += $retained_warranty; + $total_ttc -= $retained_warranty; + } + $tabttc[$obj->rowid][$compta_soc] += $total_ttc; $tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio; if (empty($line->tva_npr)) { $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio; // We ignore line if VAT is a NPR @@ -300,6 +307,10 @@ if ($action == 'writebookkeeping') { $accountingaccountcustomer->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, true); + $accountingaccountcustomerwarranty = new AccountingAccount($db); + + $accountingaccountcustomerwarranty->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY, true); + foreach ($tabfac as $key => $val) { // Loop on each invoice $errorforline = 0; @@ -344,6 +355,55 @@ if ($action == 'writebookkeeping') { setEventMessages($langs->trans('ErrorInvoiceContainsLinesNotYetBounded', $val['ref']), null, 'errors'); } + // Warranty + if (!$errorforline) { + foreach ($tabwarranty[$key] as $k => $mt) { + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->date_lim_reglement = $val["datereg"]; + $bookkeeping->doc_ref = $val["ref"]; + $bookkeeping->date_creation = $now; + $bookkeeping->doc_type = 'customer_invoice'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add + $bookkeeping->thirdparty_code = $companystatic->code_client; + + $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; + $bookkeeping->subledger_label = $tabcompany[$key]['name']; + + $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY; + $bookkeeping->label_compte = $accountingaccountcustomerwarranty->label; + + $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref.' - '.$langs->trans("Retainedwarranty"); + $bookkeeping->montant = $mt; + $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; + $bookkeeping->debit = ($mt >= 0) ? $mt : 0; + $bookkeeping->credit = ($mt < 0) ? -$mt : 0; + $bookkeeping->code_journal = $journal; + $bookkeeping->journal_label = $langs->transnoentities($journal_label); + $bookkeeping->fk_user_author = $user->id; + $bookkeeping->entity = $conf->entity; + + $totaldebit += $bookkeeping->debit; + $totalcredit += $bookkeeping->credit; + + $result = $bookkeeping->create($user); + if ($result < 0) { + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists + $error++; + $errorforline++; + $errorforinvoice[$key] = 'alreadyjournalized'; + //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); + } else { + $error++; + $errorforline++; + $errorforinvoice[$key] = 'other'; + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); + } + } + } + } + // Thirdparty if (!$errorforline) { foreach ($tabttc[$key] as $k => $mt) { @@ -390,7 +450,7 @@ if ($action == 'writebookkeeping') { setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } } else { - if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) { + if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && getDolGlobalInt('ACCOUNTING_ENABLE_AUTOLETTERING')) { require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; $lettering_static = new Lettering($db); $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id)); @@ -624,6 +684,25 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! continue; } + // Warranty + foreach ($tabwarranty[$key] as $k => $mt) { + //if ($mt) { + print '"'.$key.'"'.$sep; + print '"'.$date.'"'.$sep; + print '"'.$val["ref"].'"'.$sep; + print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep; + print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; + print '"'.length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY).'"'.$sep; + print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; + print '"'.$langs->trans("Thirdparty").'"'.$sep; + print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$invoicestatic->ref.' - '.$langs->trans("Retainedwarranty").'"'.$sep; + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; + print '"'.$journal.'"'; + print "\n"; + //} + } + // Third party foreach ($tabttc[$key] as $k => $mt) { //if ($mt) { @@ -849,6 +928,36 @@ if (empty($action) || $action == 'view') { print ""; } + // Warranty + foreach ($tabwarranty[$key] as $k => $mt) { + print ''; + print ""; + print "".$date.""; + print "".$invoicestatic->getNomUrl(1).""; + // Account + print ""; + $accountoshow = length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY); + if (($accountoshow == "") || $accountoshow == 'NotDefined') { + print ''.$langs->trans("MainAccountForCustomersNotDefined").''; + } else { + print $accountoshow; + } + print ''; + // Subledger account + print ""; + $accountoshow = length_accounta($k); + if (($accountoshow == "") || $accountoshow == 'NotDefined') { + print ''.$langs->trans("ThirdpartyAccountNotDefined").''; + } else { + print $accountoshow; + } + print ''; + print "".$companystatic->getNomUrl(0, 'customer', 16).' - '.$invoicestatic->ref.' - '.$langs->trans("Retainedwarranty").""; + print ''.($mt >= 0 ? price($mt) : '').""; + print ''.($mt < 0 ? price(-$mt) : '').""; + print ""; + } + // Third party foreach ($tabttc[$key] as $k => $mt) { print ''; diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index b214b89734c..87e67bbfcb6 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -119,26 +119,12 @@ if (($action == 'clean' || $action == 'validatehistory') && $user->rights->accou if ($action == 'validatehistory') { $error = 0; $nbbinddone = 0; + $nbbindfailed = 0; $notpossible = 0; $db->begin(); // Now make the binding. Bind automatically only for product with a dedicated account that exists into chart of account, others need a manual bind - /*if ($db->type == 'pgsql') { - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; - $sql1 .= " SET fk_code_ventilation = accnt.rowid"; - $sql1 .= " FROM " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; - $sql1 .= " WHERE " . MAIN_DB_PREFIX . "facture_fourn_det.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . ((int) $conf->global->CHARTOFACCOUNTS).' AND accnt.entity = '.$conf->entity; - $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_buy=accnt.account_number"; - $sql1 .= " AND " . MAIN_DB_PREFIX . "facture_fourn_det.fk_code_ventilation = 0"; - } else { - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd, " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; - $sql1 .= " SET fk_code_ventilation = accnt.rowid"; - $sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . ((int) $conf->global->CHARTOFACCOUNTS).' AND accnt.entity = '.$conf->entity; - $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_buy=accnt.account_number"; - $sql1 .= " AND fd.fk_code_ventilation = 0"; - }*/ - // Supplier Invoice Lines (must be same request than into page list.php for manual binding) $sql = "SELECT f.rowid as facid, f.ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.type as ftype, f.fk_facture_source,"; $sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; @@ -279,12 +265,14 @@ if ($action == 'validatehistory') { if (!$resqlupdate) { $error++; setEventMessages($db->lasterror(), null, 'errors'); + $nbbindfailed++; break; } else { $nbbinddone++; } } else { $notpossible++; + $nbbindfailed++; } $i++; @@ -298,7 +286,10 @@ if ($action == 'validatehistory') { $db->rollback(); } else { $db->commit(); - setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone, $notpossible), null, 'mesgs'); + setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone, $notpossible), null, ($notpossible ? 'warnings' : 'mesgs')); + if ($nbbindfailed) { + setEventMessages($langs->trans('DoManualBindingForFailedRecord', $nbbindfailed), null, 'warnings'); + } } } @@ -320,7 +311,7 @@ print '
'; $y = $year_current; -$buttonbind = ''.$langs->trans("ValidateHistory").''; +$buttonbind = ''.img_picto('', 'link', 'class="paddingright fa-color-unset"').$langs->trans("ValidateHistory").''; print_barre_liste(img_picto('', 'unlink', 'class="paddingright fa-color-unset"').$langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1); @@ -402,14 +393,37 @@ if ($resql) { print ''; print ''; if ($row[0] == 'tobind') { - print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/supplier/list.php?search_year='.((int) $y), $langs->transnoentitiesnoconv("ToBind")); + $startmonth = ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1); + if ($startmonth > 12) { + $startmonth -= 12; + } + $startyear = ($startmonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y; + $endmonth = ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) + 11; + if ($endmonth > 12) { + $endmonth -= 12; + } + $endyear = ($endmonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y; + print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/supplier/list.php?search_date_startday=1&search_date_startmonth='.((int) $startmonth).'&search_date_startyear='.((int) $startyear).'&search_date_endday=&search_date_endmonth='.((int) $endmonth).'&search_date_endyear='.((int) $endyear), $langs->transnoentitiesnoconv("ToBind")); } else { print $row[1]; } print ''; for ($i = 2; $i <= 13; $i++) { + $cursormonth = (($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) + $i - 2); + if ($cursormonth > 12) { + $cursormonth -= 12; + } + $cursoryear = ($cursormonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y; + $tmp = dol_getdate(dol_get_last_day($cursoryear, $cursormonth, 'gmt'), false, 'gmt'); + print ''; print price($row[$i]); + // Add link to make binding + if (!empty(price2num($row[$i]))) { + print ''; + print img_picto($langs->trans("ValidateHistory").' ('.$langs->trans('Month'.str_pad($cursormonth, 2, '0', STR_PAD_LEFT)).' '.$cursoryear.')', 'link', 'class="marginleft2"'); + print ''; + } print ''; } print ''.price($row[14]).''; @@ -541,7 +555,7 @@ print "\n"; print ''; -if ($conf->global->MAIN_FEATURES_LEVEL > 0) { // This part of code looks strange. Why showing a report that should rely on result of this step ? +if (getDolGlobalString('SHOW_TOTAL_OF_PREVIOUS_LISTS_IN_LIN_PAGE')) { // This part of code looks strange. Why showing a report that should rely on result of this step ? print '
'; print '
'; diff --git a/htdocs/accountancy/tpl/export_journal.tpl.php b/htdocs/accountancy/tpl/export_journal.tpl.php index 22537a60a39..8e3c914a6f5 100644 --- a/htdocs/accountancy/tpl/export_journal.tpl.php +++ b/htdocs/accountancy/tpl/export_journal.tpl.php @@ -1,6 +1,8 @@ + * Copyright (C) 2022 Lionel Vessiller * Copyright (C) 2016 Charlie Benke + * Copyright (C) 2022 Progiseize * * 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 @@ -33,7 +35,9 @@ $siren = getDolGlobalString('MAIN_INFO_SIREN'); $date_export = "_".dol_print_date(dol_now(), '%Y%m%d%H%M%S'); $endaccountingperiod = dol_print_date(dol_now(), '%Y%m%d'); -header('Content-Type: text/csv'); +if (empty($withAttachment)) { + header('Content-Type: text/csv'); +} include_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php'; $accountancyexport = new AccountancyExport($db); @@ -66,4 +70,6 @@ if (($accountancyexport->getFormatCode($formatexportset) == 'fec' || $accountanc $completefilename = ($code ? $code."_" : "").($prefix ? $prefix."_" : "").$filename.($nodateexport ? "" : $date_export).".".$format; } -header('Content-Disposition: attachment;filename='.$completefilename); +if (empty($withAttachment)) { + header('Content-Disposition: attachment;filename=' . $completefilename); +} diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index 08e9f617750..14379166247 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -178,7 +178,7 @@ if (!empty($conf->global->MEMBER_ENABLE_PUBLIC)) { //print $langs->trans('FollowingLinksArePublic').'
'; print img_picto('', 'globe').' '.$langs->trans('BlankSubscriptionForm').'
'; if (isModEnabled('multicompany')) { - $entity_qr = '?entity='.$conf->entity; + $entity_qr = '?entity='.((int) $conf->entity); } else { $entity_qr = ''; } diff --git a/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php b/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php index 18b778fc346..b6f0489108a 100644 --- a/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php +++ b/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php @@ -116,30 +116,5 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("DeleteAdherent"), $langs->trans("ConfirmDeleteAdherent"), "confirm_delete", '', 0, 1); } } - - if ($action == 'list') { - $this->LoadListDatas($limit, $offset, $sortfield, $sortorder); - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Fetch datas list and save into ->list_datas - * - * @param int $limit Limit number of responses - * @param int $offset Offset for first response - * @param string $sortfield Sort field - * @param string $sortorder Sort order ('ASC' or 'DESC') - * @return void - */ - public function LoadListDatas($limit, $offset, $sortfield, $sortorder) - { - // phpcs:enable - global $conf, $langs; - - //$this->getFieldList(); - - $this->list_datas = array(); } } diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 273f79b8ac8..f72682ce22a 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -565,7 +565,7 @@ if (empty($reshook)) { } if (!empty($object->url) && !isValidUrl($object->url)) { $langs->load("errors"); - setEventMessages('', $langs->trans("ErrorBadUrl", $object->url), 'errors'); + setEventMessages($langs->trans("ErrorBadUrl", $object->url), null, 'errors'); } $public = 0; if (isset($public)) { @@ -1046,7 +1046,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Website print ''.$form->editfieldkey('Web', 'member_url', GETPOST('member_url', 'alpha'), $object, 0).''; - print ''.img_picto('', 'globe').' '; + print ''.img_picto('', 'globe').' '; // Address print ''.$langs->trans("Address").''; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 6aaac503060..225261e8f9f 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2907,8 +2907,8 @@ class Adherent extends CommonObject * Adds it to non existing supplied categories. * Existing categories are left untouch. * - * @param int[]|int $categories Category or categories IDs - * @return void + * @param int[]|int $categories Category or categories IDs + * @return int <0 if KO, >0 if OK */ public function setCategories($categories) { @@ -3203,4 +3203,40 @@ class Adherent extends CommonObject return $nbko; } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + + $return = '
'; + $return .= '
'; + $return .= ''; + + if (property_exists($this, 'photo') || !empty($this->photo)) { + $return.= Form::showphoto('memberphoto', $this, 0, 60, 0, 'photokanban photoref photowithmargin photologintooltip', 'small', 0, 1); + } else { + $return .= img_picto('', 'user'); + } + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + if (property_exists($this, 'type')) { + $return .= '
'.$this->type.''; + } + if (method_exists($this, 'getmorphylib')) { + $return .= '
'.$this->getmorphylib('', 2).''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 6ab65697745..0a4663f8149 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -472,7 +472,7 @@ class AdherentType extends CommonObject } /** - * Function that retrieves the status of the member + * Function that retrieves the properties of a membership type * * @param int $rowid Id of member type to load * @return int <0 if KO, >0 if OK @@ -927,4 +927,46 @@ class AdherentType extends CommonObject return ''; } + + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + global $langs,$user; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + if ($user->rights->adherent->configurer) { + $return .= 'ref.'">'.img_edit().''; + } else { + $return .= ' '; + } + if (property_exists($this, 'vote')) { + $return .= '
'.$langs->trans("VoteAllowed").' : '.yn($this->vote).''; + } + if (property_exists($this, 'amount')) { + if (is_null($this->amount) || $this->amount === '') { + $return .= '
'; + } else { + $return .= '
'.$langs->trans("Amount").''; + $return .= ' : '.price($this->amount).''; + } + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index b3cfe027197..12e19fd9c3a 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -505,4 +505,36 @@ class Subscription extends CommonObject dol_print_error($this->db); } } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + + $return .= '
'; + $return .= ''.(property_exists($this, 'fk_adherent')? $this->fk_adherent: $this->ref ).''; + if (property_exists($this, 'dateh') || property_exists($this, 'datef')) { + $return .= '
'.dol_print_date($this->dateh, 'day').' - '.dol_print_date($this->datef, 'day').''; + } + + if (property_exists($this, 'fk_bank')) { + $return .= '
'.$this->fk_bank.''; + } + if (property_exists($this, 'amount')) { + $return .= '
'.price($this->amount).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php index 4517bee15c6..d3aa8cc2211 100644 --- a/htdocs/adherents/document.php +++ b/htdocs/adherents/document.php @@ -80,7 +80,7 @@ if ($id > 0 || !empty($ref)) { // Define variables to know what current user can do on properties of user linked to edited member if ($object->user_id) { // $User is the user who edits, $object->user_id is the id of the related user in the edited member - $caneditfielduser = ((($user->id == $object->user_id) && $$user->hasRight('user', 'self', 'creer')) + $caneditfielduser = ((($user->id == $object->user_id) && $user->hasRight('user', 'self', 'creer')) || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'creer'))); $caneditpassworduser = ((($user->id == $object->user_id) && $user->hasRight('user', 'self', 'password')) || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'password'))); diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index a1d929ec3e9..b9cbb252144 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -47,6 +47,7 @@ $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'memberslist'; // To manage different context of search +$mode = GETPOST('mode', 'alpha'); // Search fields @@ -126,7 +127,6 @@ $fieldstosearchall = array( 'd.login'=>'Login', 'd.lastname'=>'Lastname', 'd.firstname'=>'Firstname', - 'd.login'=>'Login', 'd.societe'=>"Company", 'd.email'=>'EMail', 'd.address'=>'Address', @@ -535,6 +535,9 @@ if ($search_type > 0) { } $param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -636,6 +639,8 @@ if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'pr $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); if ($user->hasRight('adherent', 'creer')) { $newcardbutton .= dolGetButtonTitle($langs->trans('NewMember'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/card.php?action=create'); } @@ -650,6 +655,8 @@ print ''; print ''; print ''; print ''; +print ''; + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -836,14 +843,14 @@ if (!empty($arrayfields['d.tms']['checked'])) { } // Status if (!empty($arrayfields['d.statut']['checked'])) { - print ''; + print ''; $liststatus = array( Adherent::STATUS_DRAFT => $langs->trans("Draft"), Adherent::STATUS_VALIDATED => $langs->trans("Validated"), Adherent::STATUS_RESILIATED => $langs->trans("MemberStatusResiliatedShort"), Adherent::STATUS_EXCLUDED =>$langs->trans("MemberStatusExcludedShort") ); - print $form->selectarray('search_status', $liststatus, $search_status, -3, 0, 0, '', 0, 0, 0, '', 'onrightofpage'); + print $form->selectarray('search_status', $liststatus, $search_status, -3, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage'); print ''; } if (!empty($arrayfields['d.import_key']['checked'])) { @@ -988,276 +995,293 @@ while ($i < min($num, $limit)) { } $memberstatic->company = $companyname; - print ''; - - // Action column - if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; - } - print ''; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + print '
'; } - print ''; - } - - if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { - print ''.$obj->rowid.''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Ref - if (!empty($arrayfields['d.ref']['checked'])) { - print ""; - print $memberstatic->getNomUrl(-1, 0, 'card', 'ref', '', -1, 0, 1); - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Civility - if (!empty($arrayfields['d.civility']['checked'])) { - print ""; - print $obj->civility; - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Firstname - if (!empty($arrayfields['d.firstname']['checked'])) { - print ''; - print $memberstatic->getNomUrl(0, 0, 'card', 'firstname'); - //print $obj->firstname; - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Lastname - if (!empty($arrayfields['d.lastname']['checked'])) { - print ''; - print $memberstatic->getNomUrl(0, 0, 'card', 'lastname'); - //print $obj->lastname; - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Gender - if (!empty($arrayfields['d.gender']['checked'])) { - print ''; - if ($obj->gender) { - print $langs->trans("Gender".$obj->gender); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Company - if (!empty($arrayfields['d.company']['checked'])) { - print ''; - print $companynametoshow; - print "\n"; - } - // Login - if (!empty($arrayfields['d.login']['checked'])) { - print ''.$obj->login."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Nature (Moral/Physical) - if (!empty($arrayfields['d.morphy']['checked'])) { - print ''; - print $memberstatic->getmorphylib('', 2); - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Type label - if (!empty($arrayfields['t.libelle']['checked'])) { $membertypestatic->id = $obj->type_id; $membertypestatic->label = $obj->type; - print ''; - print $membertypestatic->getNomUrl(1, 32); - print ''; - if (!$i) { - $totalarray['nbfield']++; + $memberstatic->type = $membertypestatic->label; + $memberstatic->photo = $obj->photo; + // Output Kanban + print $memberstatic->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print '
'; + print ''; } - } - // Address - if (!empty($arrayfields['d.address']['checked'])) { - print ''; - print $obj->address; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Zip - if (!empty($arrayfields['d.zip']['checked'])) { - print ''; - print $obj->zip; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Town - if (!empty($arrayfields['d.town']['checked'])) { - print ''; - print $obj->town; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // State - if (!empty($arrayfields['state.nom']['checked'])) { - print "".$obj->state_name."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Country - if (!empty($arrayfields['country.code_iso']['checked'])) { - $tmparray = getCountry($obj->country, 'all'); - print ''; - print dol_escape_htmltag($tmparray['label']); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Phone pro - if (!empty($arrayfields['d.phone']['checked'])) { - print ''; - print $obj->phone; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Phone perso - if (!empty($arrayfields['d.phone_perso']['checked'])) { - print ''; - print $obj->phone_perso; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Phone mobile - if (!empty($arrayfields['d.phone_mobile']['checked'])) { - print ''; - print $obj->phone_mobile; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // EMail - if (!empty($arrayfields['d.email']['checked'])) { - print ''; - print dol_print_email($obj->email, 0, 0, 1, 64, 1, 1); - print "\n"; - } - // End of subscription date - $datefin = $db->jdate($obj->datefin); - if (!empty($arrayfields['d.datefin']['checked'])) { - print ''; - if ($datefin) { - print dol_print_date($datefin, 'day'); - if ($memberstatic->hasDelay()) { - $textlate = ' ('.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24) >= 0 ? '+' : '').ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24).' '.$langs->trans("days").')'; - print " ".img_warning($langs->trans("SubscriptionLate").$textlate); + } else { + print ''; + + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; } - } else { - if (!empty($obj->subscription)) { - print ''.$langs->trans("SubscriptionNotReceived").''; - if ($obj->statut > 0) { - print " ".img_warning(); + print ''; + } + + if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { + print ''.$obj->rowid.''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Ref + if (!empty($arrayfields['d.ref']['checked'])) { + print ""; + print $memberstatic->getNomUrl(-1, 0, 'card', 'ref', '', -1, 0, 1); + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Civility + if (!empty($arrayfields['d.civility']['checked'])) { + print ""; + print $obj->civility; + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Firstname + if (!empty($arrayfields['d.firstname']['checked'])) { + print ''; + print $memberstatic->getNomUrl(0, 0, 'card', 'firstname'); + //print $obj->firstname; + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Lastname + if (!empty($arrayfields['d.lastname']['checked'])) { + print ''; + print $memberstatic->getNomUrl(0, 0, 'card', 'lastname'); + //print $obj->lastname; + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Gender + if (!empty($arrayfields['d.gender']['checked'])) { + print ''; + if ($obj->gender) { + print $langs->trans("Gender".$obj->gender); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Company + if (!empty($arrayfields['d.company']['checked'])) { + print ''; + print $companynametoshow; + print "\n"; + } + // Login + if (!empty($arrayfields['d.login']['checked'])) { + print ''.$obj->login."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Nature (Moral/Physical) + if (!empty($arrayfields['d.morphy']['checked'])) { + print ''; + print $memberstatic->getmorphylib('', 2); + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Type label + if (!empty($arrayfields['t.libelle']['checked'])) { + $membertypestatic->id = $obj->type_id; + $membertypestatic->label = $obj->type; + print ''; + print $membertypestatic->getNomUrl(1, 32); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Address + if (!empty($arrayfields['d.address']['checked'])) { + print ''; + print $obj->address; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Zip + if (!empty($arrayfields['d.zip']['checked'])) { + print ''; + print $obj->zip; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Town + if (!empty($arrayfields['d.town']['checked'])) { + print ''; + print $obj->town; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // State + if (!empty($arrayfields['state.nom']['checked'])) { + print "".$obj->state_name."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) { + $tmparray = getCountry($obj->country, 'all'); + print ''; + print dol_escape_htmltag($tmparray['label']); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Phone pro + if (!empty($arrayfields['d.phone']['checked'])) { + print ''; + print $obj->phone; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Phone perso + if (!empty($arrayfields['d.phone_perso']['checked'])) { + print ''; + print $obj->phone_perso; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Phone mobile + if (!empty($arrayfields['d.phone_mobile']['checked'])) { + print ''; + print $obj->phone_mobile; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // EMail + if (!empty($arrayfields['d.email']['checked'])) { + print ''; + print dol_print_email($obj->email, 0, 0, 1, 64, 1, 1); + print "\n"; + } + // End of subscription date + $datefin = $db->jdate($obj->datefin); + if (!empty($arrayfields['d.datefin']['checked'])) { + print ''; + if ($datefin) { + print dol_print_date($datefin, 'day'); + if ($memberstatic->hasDelay()) { + $textlate = ' ('.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24) >= 0 ? '+' : '').ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24).' '.$langs->trans("days").')'; + print " ".img_warning($langs->trans("SubscriptionLate").$textlate); } } else { - print ' '; + if (!empty($obj->subscription)) { + print ''.$langs->trans("SubscriptionNotReceived").''; + if ($obj->statut > 0) { + print " ".img_warning(); + } + } else { + print ' '; + } + } + print ''; + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['d.datec']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; } } - print ''; - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['d.datec']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Birth - if (!empty($arrayfields['d.birth']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->birth), 'day', 'tzuser'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['d.tms']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Status - if (!empty($arrayfields['d.statut']['checked'])) { - print ''; - print $memberstatic->LibStatut($obj->statut, $obj->subscription, $datefin, 5); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['d.import_key']['checked'])) { - print ''; - print dol_escape_htmltag($obj->import_key); - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Action column - if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; + // Birth + if (!empty($arrayfields['d.birth']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->birth), 'day', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; } - print ''; } - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } + // Date modification + if (!empty($arrayfields['d.tms']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Status + if (!empty($arrayfields['d.statut']['checked'])) { + print ''; + print $memberstatic->LibStatut($obj->statut, $obj->subscription, $datefin, 5); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['d.import_key']['checked'])) { + print ''; + print dol_escape_htmltag($obj->import_key); + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Action column + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } - print ''."\n"; + print ''."\n"; + } $i++; } diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index fd37f1bd814..3c17fc64852 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -37,6 +37,8 @@ $massaction = GETPOST('massaction', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'subscriptionlist'; // To manage different context of search +$mode = GETPOST('mode', 'alpha'); + $statut = (GETPOSTISSET("statut") ?GETPOST("statut", "alpha") : 1); $search_ref = GETPOST('search_ref', 'alpha'); @@ -253,6 +255,9 @@ llxHeader('', $title, $help_url); $i = 0; $param = ''; +if (!empty($mode)) { + $param .='&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -298,6 +303,9 @@ if (in_array($massaction, array('presend', 'predelete'))) { $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); + if ($user->hasRight('adherent', 'cotisation', 'creer')) { $newcardbutton .= dolGetButtonTitle($langs->trans('NewSubscription'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/list.php?status=-1,1'); } @@ -313,6 +321,8 @@ print ''; print ''; print ''; print ''; +print ''; + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $subscription->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -507,143 +517,166 @@ while ($i < min($num, $limit)) { $adherent->need_subscription = $adht->subscription; - print ''; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + print '
'; + } - // Ref - if (!empty($arrayfields['d.ref']['checked'])) { - print ''.$subscription->getNomUrl(1).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Type - if (!empty($arrayfields['d.fk_type']['checked'])) { - print ''; - if ($typeid > 0) { - print $adht->getNomUrl(1); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Lastname - if (!empty($arrayfields['d.lastname']['checked'])) { - print ''.$adherent->getNomUrl(-1, 0, 'card', 'lastname').''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Firstname - if (!empty($arrayfields['d.firstname']['checked'])) { - print ''.$adherent->firstname.''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Login - if (!empty($arrayfields['d.login']['checked'])) { - print ''.$adherent->login.''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Label - if (!empty($arrayfields['t.libelle']['checked'])) { - print ''; - print $obj->note; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Banque - if (!empty($arrayfields['d.bank']['checked'])) { - print ''; + //fetch informations needs on this mode + $subscription->fk_adherent = $adherent->getNomUrl(1); + $subscription->fk_type = $adht->getNomUrl(1); + $subscription->amount = $obj->subscription; if ($obj->fk_account > 0) { $accountstatic->id = $obj->fk_account; $accountstatic->fetch($obj->fk_account); - //$accountstatic->label=$obj->label; - print $accountstatic->getNomUrl(1); + $subscription->fk_bank = $accountstatic->getNomUrl(1); } - print "\n"; - if (!$i) { - $totalarray['nbfield']++; + // Output Kanban + print $subscription->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print '
'; + print ''; } - } + } else { + print ''; - // Date start - if (!empty($arrayfields['c.dateadh']['checked'])) { - print ''.dol_print_date($db->jdate($obj->dateadh), 'day')."\n"; - if (!$i) { - $totalarray['nbfield']++; + // Ref + if (!empty($arrayfields['d.ref']['checked'])) { + print ''.$subscription->getNomUrl(1).''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Date end - if (!empty($arrayfields['c.datef']['checked'])) { - print ''.dol_print_date($db->jdate($obj->datef), 'day')."\n"; - if (!$i) { - $totalarray['nbfield']++; + // Type + if (!empty($arrayfields['d.fk_type']['checked'])) { + print ''; + if ($typeid > 0) { + print $adht->getNomUrl(1); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Price - if (!empty($arrayfields['d.amount']['checked'])) { - print ''.price($obj->subscription).''; - if (!$i) { - $totalarray['nbfield']++; + + // Lastname + if (!empty($arrayfields['d.lastname']['checked'])) { + print ''.$adherent->getNomUrl(-1, 0, 'card', 'lastname').''; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'd.amount'; + // Firstname + if (!empty($arrayfields['d.firstname']['checked'])) { + print ''.$adherent->firstname.''; + if (!$i) { + $totalarray['nbfield']++; + } } - if (empty($totalarray['val']['d.amount'])) { - $totalarray['val']['d.amount'] = $obj->subscription; - } else { - $totalarray['val']['d.amount'] += $obj->subscription; + + // Login + if (!empty($arrayfields['d.login']['checked'])) { + print ''.$adherent->login.''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Label + if (!empty($arrayfields['t.libelle']['checked'])) { + print ''; + print $obj->note; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Banque + if (!empty($arrayfields['d.bank']['checked'])) { + print ''; + if ($obj->fk_account > 0) { + $accountstatic->id = $obj->fk_account; + $accountstatic->fetch($obj->fk_account); + //$accountstatic->label=$obj->label; + print $accountstatic->getNomUrl(1); + } + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date start + if (!empty($arrayfields['c.dateadh']['checked'])) { + print ''.dol_print_date($db->jdate($obj->dateadh), 'day')."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date end + if (!empty($arrayfields['c.datef']['checked'])) { + print ''.dol_print_date($db->jdate($obj->datef), 'day')."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Price + if (!empty($arrayfields['d.amount']['checked'])) { + print ''.price($obj->subscription).''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'd.amount'; + } + if (empty($totalarray['val']['d.amount'])) { + $totalarray['val']['d.amount'] = $obj->subscription; + } else { + $totalarray['val']['d.amount'] += $obj->subscription; + } + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['c.datec']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date modification + if (!empty($arrayfields['c.tms']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Action column + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->crowid, $arrayofselected)) { + $selected = 1; + } + print ''; } - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['c.datec']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; if (!$i) { $totalarray['nbfield']++; } - } - // Date modification - if (!empty($arrayfields['c.tms']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Action column - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->crowid, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - print "\n"; + print "\n"; + } $i++; } diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index ea95b7eef1a..f516efdd819 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -44,6 +44,7 @@ $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); +$mode = GETPOST('mode', 'alopha'); $sall = GETPOST("sall", "alpha"); $filter = GETPOST("filter", 'alpha'); @@ -249,6 +250,9 @@ if (!$rowid && $action != 'create' && $action != 'edit') { $i = 0; $param = ''; + if (!empty($mode)) { + $param .= '&mode'.urlencode($mode); + } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.$contextpage; } @@ -257,6 +261,10 @@ if (!$rowid && $action != 'create' && $action != 'edit') { } $newcardbutton = ''; + + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); + if ($user->hasRight('adherent', 'configurer')) { $newcardbutton .= dolGetButtonTitle($langs->trans('NewMemberType'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/type.php?action=create'); } @@ -270,6 +278,8 @@ if (!$rowid && $action != 'create' && $action != 'edit') { print ''; print ''; print ''; + print ''; + print_barre_liste($langs->trans("MembersTypes"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'members', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -292,7 +302,13 @@ if (!$rowid && $action != 'create' && $action != 'edit') { $membertype = new AdherentType($db); - while ($i < $num) { + $i = 0; + /*$savnbfield = $totalarray['nbfield']; + $totalarray = array(); + $totalarray['nbfield'] = 0;*/ + + $imaxinloop = ($limit ? min($num, $limit) : $num); + while ($i < $imaxinloop) { $objp = $db->fetch_object($result); $membertype->id = $objp->rowid; @@ -303,32 +319,46 @@ if (!$rowid && $action != 'create' && $action != 'edit') { $membertype->amount = $objp->amount; $membertype->caneditamount = $objp->caneditamount; - print ''; - print ''; - print $membertype->getNomUrl(1); - //'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.' - print ''; - print ''.dol_escape_htmltag($objp->label).''; - print ''; - if ($objp->morphy == 'phy') { - print $langs->trans("Physical"); - } elseif ($objp->morphy == 'mor') { - print $langs->trans("Moral"); + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + print '
'; + } + //output kanban + $membertype->label = $objp->label; + print $membertype->getKanbanView(''); + if ($i == ($imaxinloop - 1)) { + print '
'; + print ''; + } } else { - print $langs->trans("MorAndPhy"); + print ''; + print ''; + print $membertype->getNomUrl(1); + //'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.' + print ''; + print ''.dol_escape_htmltag($objp->label).''; + print ''; + if ($objp->morphy == 'phy') { + print $langs->trans("Physical"); + } elseif ($objp->morphy == 'mor') { + print $langs->trans("Moral"); + } else { + print $langs->trans("MorAndPhy"); + } + print ''; + print ''.yn($objp->subscription).''; + print ''.(is_null($objp->amount) || $objp->amount === '' ? '' : price($objp->amount)).''; + print ''.yn($objp->caneditamount).''; + print ''.yn($objp->vote).''; + print ''.$membertype->getLibStatut(5).''; + if ($user->rights->adherent->configurer) { + print 'rowid.'">'.img_edit().''; + } else { + print ' '; + } + print ""; } - print ''; - print ''.yn($objp->subscription).''; - print ''.(is_null($objp->amount) || $objp->amount === '' ? '' : price($objp->amount)).''; - print ''.yn($objp->caneditamount).''; - print ''.yn($objp->vote).''; - print ''.$membertype->getLibStatut(5).''; - if ($user->hasRight('adherent', 'configurer')) { - print 'rowid.'">'.img_edit().''; - } else { - print ' '; - } - print ""; $i++; } diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index 5003593905e..aef46db26ef 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -54,6 +54,9 @@ $type = 'action'; * Actions */ +$error = 0; +$errors = array(); + include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; $reg = array(); @@ -193,10 +196,9 @@ print dol_get_fiche_head($head, 'other', $langs->trans("Agenda"), -1, 'action'); /* - * Documents models for supplier orders + * Miscellaneous */ - // Define array def of models $def = array(); @@ -308,8 +310,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { } } print '
'; + + print load_fiche_titre($langs->trans('MiscellaneousOptions'), '', ''); } + print '
'; print ''; print ''; @@ -395,13 +400,12 @@ print ''."\n"; print ''; -print dol_get_fiche_end(); - print $form->buttonsSaveCancel("Save", ''); print '
'; -print "
"; + +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/agenda_reminder.php b/htdocs/admin/agenda_reminder.php index 76c717b669d..42967b4f275 100644 --- a/htdocs/admin/agenda_reminder.php +++ b/htdocs/admin/agenda_reminder.php @@ -150,7 +150,6 @@ $linkback = 'trans("Agenda"), -1, 'action'); diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index 96dd7affdba..176816c0f88 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -52,7 +52,7 @@ if ($action == 'setbarcodeproducton') { $barcodenumberingmodule = GETPOST('value', 'alpha'); $res = dolibarr_set_const($db, "BARCODE_PRODUCT_ADDON_NUM", $barcodenumberingmodule, 'chaine', 0, '', $conf->entity); if ($barcodenumberingmodule == 'mod_barcode_product_standard' && empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) { - $res = dolibarr_set_const($db, "BARCODE_STANDARD_PRODUCT_MASK", '020{000000000}', 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "BARCODE_STANDARD_PRODUCT_MASK", '04{0000000000}', 'chaine', 0, '', $conf->entity); } } elseif ($action == 'setbarcodeproductoff') { $res = dolibarr_del_const($db, "BARCODE_PRODUCT_ADDON_NUM", $conf->entity); @@ -62,7 +62,7 @@ if ($action == 'setbarcodethirdpartyon') { $barcodenumberingmodule = GETPOST('value', 'alpha'); $res = dolibarr_set_const($db, "BARCODE_THIRDPARTY_ADDON_NUM", $barcodenumberingmodule, 'chaine', 0, '', $conf->entity); if ($barcodenumberingmodule == 'mod_barcode_thirdparty_standard' && empty($conf->global->BARCODE_STANDARD_THIRDPARTY_MASK)) { - $res = dolibarr_set_const($db, "BARCODE_STANDARD_THIRDPARTY_MASK", '020{000000000}', 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "BARCODE_STANDARD_THIRDPARTY_MASK", '04{0000000000}', 'chaine', 0, '', $conf->entity); } } elseif ($action == 'setbarcodethirdpartyoff') { $res = dolibarr_del_const($db, "BARCODE_THIRDPARTY_ADDON_NUM", $conf->entity); diff --git a/htdocs/admin/bom.php b/htdocs/admin/bom.php index a35aef780d2..57b4b5aad06 100644 --- a/htdocs/admin/bom.php +++ b/htdocs/admin/bom.php @@ -51,10 +51,10 @@ $type = 'bom'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstbom = GETPOST('maskconstBom', 'alpha'); + $maskconstbom = GETPOST('maskconstBom', 'aZ09'); $maskbom = GETPOST('maskBom', 'alpha'); - if ($maskconstbom) { + if ($maskconstbom && preg_match('/_MASK$/', $maskconstbom)) { $res = dolibarr_set_const($db, $maskconstbom, $maskbom, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/chequereceipts.php b/htdocs/admin/chequereceipts.php index cf93155b814..77994debadb 100644 --- a/htdocs/admin/chequereceipts.php +++ b/htdocs/admin/chequereceipts.php @@ -54,9 +54,9 @@ if (empty($conf->global->CHEQUERECEIPTS_ADDON)) { */ if ($action == 'updateMask') { - $maskconstchequereceipts = GETPOST('maskconstchequereceipts', 'alpha'); + $maskconstchequereceipts = GETPOST('maskconstchequereceipts', 'aZ09'); $maskchequereceipts = GETPOST('maskchequereceipts', 'alpha'); - if ($maskconstchequereceipts) { + if ($maskconstchequereceipts && preg_match('/_MASK$/', $maskconstchequereceipts)) { $res = dolibarr_set_const($db, $maskconstchequereceipts, $maskchequereceipts, 'chaine', 0, '', $conf->entity); } @@ -211,7 +211,7 @@ foreach ($dirmodels as $reldir) { print ''; print $form->textwithpicto('', $htmltooltip, 1, 0); - if ($conf->global->CHEQUERECEIPTS_ADDON.'.php' == $file) { // If module is the one used, we show existing errors + if (getDolGlobalString('CHEQUERECEIPTS_ADDON').'.php' == $file) { // If module is the one used, we show existing errors if (!empty($module->error)) { dol_htmloutput_mesg($module->error, '', 'error', 1); } diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 34a5e281fac..79c42f6e2db 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -61,10 +61,10 @@ $type = 'order'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstorder = GETPOST('maskconstorder', 'alpha'); + $maskconstorder = GETPOST('maskconstorder', 'aZ09'); $maskorder = GETPOST('maskorder', 'alpha'); - if ($maskconstorder) { + if ($maskconstorder && preg_match('/_MASK$/', $maskconstorder)) { $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index 48247bf0b8e..c5a4d1a3463 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -58,9 +58,9 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; $error=0; if ($action == 'updateMask') { - $maskconst = GETPOST('maskconstcontract', 'alpha'); + $maskconst = GETPOST('maskconstcontract', 'aZ09'); $maskvalue = GETPOST('maskcontract', 'alpha'); - if ($maskconst) { + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index 59c826413aa..55259ecfff3 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -325,7 +325,7 @@ if (empty($conf->global->MAIN_DISABLE_METEO) || $conf->global->MAIN_DISABLE_METE if (!empty($conf->global->MAIN_METEO_LEVEL0)) { $level0 = $conf->global->MAIN_METEO_LEVEL0; } - $level1 = $offset + 1 * $cursor; + $level1 = $offset + $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL1)) { $level1 = $conf->global->MAIN_METEO_LEVEL1; } @@ -459,7 +459,7 @@ if ($action == 'edit') { print ''; } else { print '

'; } diff --git a/htdocs/admin/delivery.php b/htdocs/admin/delivery.php index a1fef4091ce..9094762f68d 100644 --- a/htdocs/admin/delivery.php +++ b/htdocs/admin/delivery.php @@ -90,9 +90,9 @@ if ($action == 'activate_delivery') { } if ($action == 'updateMask') { - $maskconstdelivery = GETPOST('maskconstdelivery', 'alpha'); + $maskconstdelivery = GETPOST('maskconstdelivery', 'aZ09'); $maskdelivery = GETPOST('maskdelivery', 'alpha'); - if ($maskconstdelivery) { + if ($maskconstdelivery && preg_match('/_MASK$/', $maskconstdelivery)) { $res = dolibarr_set_const($db, $maskconstdelivery, $maskdelivery, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index d928931c9ab..8b63c5842ba 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1944,7 +1944,7 @@ if ($id > 0) { //var_dump($fieldlist); $class = ''; $showfield = 1; - $valuetoshow = empty($obj->{$value}) ? '' : $obj->{$value}; + $valuetoshow = empty($obj->$value) ? '' : $obj->$value; $titletoshow = ''; if ($value == 'entity') { @@ -1985,76 +1985,76 @@ if ($id > 0) { } elseif ($value == 'libelle_facture') { $langs->load("bills"); $key = $langs->trans("PaymentCondition".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "PaymentCondition".strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != "PaymentCondition".strtoupper($obj->code) ? $key : $obj->$value); $valuetoshow = nl2br($valuetoshow); } elseif ($value == 'label' && $tabname[$id] == 'c_country') { $key = $langs->trans("Country".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "Country".strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != "Country".strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'label' && $tabname[$id] == 'c_availability') { $langs->load("propal"); $key = $langs->trans("AvailabilityType".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "AvailabilityType".strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != "AvailabilityType".strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'libelle' && $tabname[$id] == 'c_actioncomm') { $key = $langs->trans("Action".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "Action".strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != "Action".strtoupper($obj->code) ? $key : $obj->$value); } elseif (!empty($obj->code_iso) && $value == 'label' && $tabname[$id] == 'c_currencies') { $key = $langs->trans("Currency".strtoupper($obj->code_iso)); - $valuetoshow = ($obj->code_iso && $key != "Currency".strtoupper($obj->code_iso) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code_iso && $key != "Currency".strtoupper($obj->code_iso) ? $key : $obj->$value); } elseif ($value == 'libelle' && $tabname[$id] == 'c_typent') { $key = $langs->trans(strtoupper($obj->code)); - $valuetoshow = ($key != strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($key != strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'libelle' && $tabname[$id] == 'c_prospectlevel') { $key = $langs->trans(strtoupper($obj->code)); - $valuetoshow = ($key != strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($key != strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'label' && $tabname[$id] == 'c_civility') { $key = $langs->trans("Civility".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "Civility".strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != "Civility".strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'libelle' && $tabname[$id] == 'c_type_contact') { $langs->load('agenda'); $key = $langs->trans("TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'libelle' && $tabname[$id] == 'c_payment_term') { $langs->load("bills"); $key = $langs->trans("PaymentConditionShort".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'libelle' && $tabname[$id] == 'c_paiement') { $langs->load("bills"); $key = $langs->trans("PaymentType".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "PaymentType".strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != "PaymentType".strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'type' && $tabname[$id] == 'c_paiement') { $payment_type_list = array(0=>$langs->trans('PaymentTypeCustomer'), 1=>$langs->trans('PaymentTypeSupplier'), 2=>$langs->trans('PaymentTypeBoth')); $valuetoshow = $payment_type_list[$valuetoshow]; } elseif ($value == 'label' && $tabname[$id] == 'c_input_reason') { $key = $langs->trans("DemandReasonType".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "DemandReasonType".strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != "DemandReasonType".strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'libelle' && $tabname[$id] == 'c_input_method') { $langs->load("orders"); $key = $langs->trans($obj->code); - $valuetoshow = ($obj->code && $key != $obj->code) ? $key : $obj->{$value}; + $valuetoshow = ($obj->code && $key != $obj->code) ? $key : $obj->$value; } elseif ($value == 'libelle' && $tabname[$id] == 'c_shipment_mode') { $langs->load("sendings"); $key = $langs->trans("SendingMethod".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "SendingMethod".strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != "SendingMethod".strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'libelle' && $tabname[$id] == 'c_paper_format') { $key = $langs->trans('PaperFormat'.strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != 'PaperFormat'.strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != 'PaperFormat'.strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'label' && $tabname[$id] == 'c_type_fees') { $langs->load('trips'); $key = $langs->trans(strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'region_id' || $value == 'country_id') { $showfield = 0; } elseif ($value == 'unicode') { $valuetoshow = $langs->getCurrencySymbol($obj->code, 1); } elseif ($value == 'label' && $tabname[GETPOST("id", 'int')] == 'c_units') { $langs->load("products"); - $valuetoshow = $langs->trans($obj->{$value}); + $valuetoshow = $langs->trans($obj->$value); } elseif ($value == 'short_label' && $tabname[GETPOST("id", 'int')] == 'c_units') { $langs->load("products"); - $valuetoshow = $langs->trans($obj->{$value}); + $valuetoshow = $langs->trans($obj->$value); } elseif (($value == 'unit') && ($tabname[$id] == 'c_paper_format')) { $key = $langs->trans('SizeUnit'.strtolower($obj->unit)); - $valuetoshow = ($obj->code && $key != 'SizeUnit'.strtolower($obj->unit) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != 'SizeUnit'.strtolower($obj->unit) ? $key : $obj->$value); } elseif ($value == 'localtax1' || $value == 'localtax2') { $class = "center"; } elseif ($value == 'localtax1_type') { @@ -2357,7 +2357,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') foreach ($fieldlist as $field => $value) { if ($value == 'entity') { - $withentity = $obj->{$value}; + $withentity = $obj->$value; continue; } @@ -2510,11 +2510,11 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') print ''; } elseif ($value == 'block_if_negative') { print ''; - print $form->selectyesno("block_if_negative", (!empty($obj->{$value}) ? $obj->{$value}:''), 1); + print $form->selectyesno("block_if_negative", (empty($obj->block_if_negative) ? '' : $obj->block_if_negative), 1); print ''; } elseif ($value == 'type_duration') { print ''; - print $form->selectTypeDuration('', $obj->{$value}, array('i','h')); + print $form->selectTypeDuration('', (empty($obj->type_duration) ? '' : $obj->type_duration), array('i','h')); print ''; } else { $fieldValue = isset($obj->{$value}) ? $obj->{$value}: ''; diff --git a/htdocs/admin/ecm.php b/htdocs/admin/ecm.php index 3e0c2378742..4b5ccbb133e 100644 --- a/htdocs/admin/ecm.php +++ b/htdocs/admin/ecm.php @@ -31,6 +31,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; // Load translation files required by the page $langs->load("admin"); +$action = GETPOST('action', 'aZ09'); + if (!$user->admin) { accessforbidden(); } @@ -41,6 +43,7 @@ if (!$user->admin) { */ // set +$reg = array(); if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { $code = $reg[1]; if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) { @@ -67,6 +70,8 @@ if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { * View */ +$form = new Form($db); + $help_url = ''; llxHeader('', $langs->trans("ECMSetup"), $help_url); @@ -81,26 +86,21 @@ print dol_get_fiche_head($head, 'ecm', '', -1, ''); print ''; print ''; print ''; -print ''; -print ''."\n"; +print ''."\n"; print ''; -$form = new Form($db); - // Mail required for members print ''; print ''; -print ''; - -print ''; diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 8dfafb19b63..b3d6e045470 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -668,6 +668,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $arrayoftypes = array( 'loadthirdparty' => $langs->trans('LoadThirdPartyFromName', $langs->transnoentities("ThirdPartyName")), 'loadandcreatethirdparty' => $langs->trans('LoadThirdPartyFromNameOrCreate', $langs->transnoentities("ThirdPartyName")), + 'loadandcreatecontact' => $langs->trans('LoadContactFromEmailOrCreate', $langs->transnoentities("Email")), 'recordjoinpiece' => 'AttachJoinedDocumentsToObject', 'recordevent' => 'RecordEvent' ); diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php index 528a6bf2a9c..0d10602b1c4 100644 --- a/htdocs/admin/eventorganization.php +++ b/htdocs/admin/eventorganization.php @@ -86,10 +86,10 @@ if ($cancel) { include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstorder = GETPOST('maskconstorder', 'alpha'); + $maskconstorder = GETPOST('maskconstorder', 'aZ09'); $maskorder = GETPOST('maskorder', 'alpha'); - if ($maskconstorder) { + if ($maskconstorder && preg_match('/_MASK$/', $maskconstorder)) { $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index 485ce901e5c..1db6a9cc9d6 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -62,9 +62,9 @@ if (empty($conf->global->EXPEDITION_ADDON_NUMBER)) { include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconst = GETPOST('maskconstexpedition', 'alpha'); + $maskconst = GETPOST('maskconstexpedition', 'aZ09'); $maskvalue = GETPOST('maskexpedition', 'alpha'); - if (!empty($maskconst)) { + if (!empty($maskconst) && preg_match('/_MASK$/', $maskconst)) { $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index 8c20b493105..25bef9fde22 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -58,9 +58,9 @@ $type = 'expensereport'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconst = GETPOST('maskconst', 'alpha'); + $maskconst = GETPOST('maskconst', 'aZ09'); $maskvalue = GETPOST('maskvalue', 'alpha'); - if ($maskconst) { + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index bbeb25371b9..a364b17cc4b 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -58,24 +58,24 @@ $type = 'invoice'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstinvoice = GETPOST('maskconstinvoice', 'alpha'); - $maskconstreplacement = GETPOST('maskconstreplacement', 'alpha'); - $maskconstcredit = GETPOST('maskconstcredit', 'alpha'); - $maskconstdeposit = GETPOST('maskconstdeposit', 'alpha'); + $maskconstinvoice = GETPOST('maskconstinvoice', 'aZ09'); + $maskconstreplacement = GETPOST('maskconstreplacement', 'aZ09'); + $maskconstcredit = GETPOST('maskconstcredit', 'aZ09'); + $maskconstdeposit = GETPOST('maskconstdeposit', 'aZ09'); $maskinvoice = GETPOST('maskinvoice', 'alpha'); $maskreplacement = GETPOST('maskreplacement', 'alpha'); $maskcredit = GETPOST('maskcredit', 'alpha'); $maskdeposit = GETPOST('maskdeposit', 'alpha'); - if ($maskconstinvoice) { + if ($maskconstinvoice && preg_match('/_MASK_/', $maskconstinvoice)) { $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity); } - if ($maskconstreplacement) { + if ($maskconstreplacement && preg_match('/_MASK_/', $maskconstreplacement)) { $res = dolibarr_set_const($db, $maskconstreplacement, $maskreplacement, 'chaine', 0, '', $conf->entity); } - if ($maskconstcredit) { + if ($maskconstcredit && preg_match('/_MASK_/', $maskconstcredit)) { $res = dolibarr_set_const($db, $maskconstcredit, $maskcredit, 'chaine', 0, '', $conf->entity); } - if ($maskconstdeposit) { + if ($maskconstdeposit && preg_match('/_MASK_/', $maskconstdeposit)) { $res = dolibarr_set_const($db, $maskconstdeposit, $maskdeposit, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index cf637d37329..2e331b3cc80 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -58,9 +58,9 @@ $type = 'ficheinter'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconst = GETPOST('maskconst', 'alpha'); + $maskconst = GETPOST('maskconst', 'aZ09'); $maskvalue = GETPOST('maskvalue', 'alpha'); - if ($maskconst) { + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php index 9a60c6b9b84..b85e257c69e 100644 --- a/htdocs/admin/holiday.php +++ b/htdocs/admin/holiday.php @@ -58,9 +58,9 @@ if (empty($conf->global->HOLIDAY_ADDON)) { include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconst = GETPOST('maskconstholiday', 'alpha'); + $maskconst = GETPOST('maskconstholiday', 'aZ09'); $maskvalue = GETPOST('maskholiday', 'alpha'); - if ($maskconst) { + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/hrm.php b/htdocs/admin/hrm.php index 73931ebf83d..14d6e8b175f 100644 --- a/htdocs/admin/hrm.php +++ b/htdocs/admin/hrm.php @@ -53,7 +53,7 @@ $label = GETPOST('label', 'alpha'); $modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php $scandir = GETPOST('scan_dir', 'alpha'); -$type = 'myobject'; +$type = 'evaluation'; $arrayofparameters = array( 'HRM_MAXRANK'=>array('type'=>'integer','enabled'=>1), @@ -89,11 +89,11 @@ if ($action == 'update') { } } } elseif ($action == 'updateMask') { - $maskconstorder = GETPOST('maskconstorder', 'alpha'); - $maskorder = GETPOST('maskorder', 'alpha'); + $maskconst = GETPOST('maskconstEvaluation', 'aZ09'); + $maskvalue = GETPOST('maskEvaluation', 'alpha'); - if ($maskconstorder) { - $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity); + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { + $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; } @@ -208,10 +208,10 @@ print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, "hrm" $moduledir = 'hrm'; $myTmpObjects = array(); -$myTmpObjects['evaluation'] = array('includerefgeneration'=>1, 'includedocgeneration'=>0); +$myTmpObjects['evaluation'] = array('label'=>'Evaluation', 'includerefgeneration'=>1, 'includedocgeneration'=>0); foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { - if ($myTmpObjectKey == 'MyObject') { + if ($myTmpObjectKey != $type) { continue; } if ($myTmpObjectArray['includerefgeneration']) { @@ -220,7 +220,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { */ $setupnotempty++; - print load_fiche_titre($langs->trans("NumberingModules", $myTmpObjectKey), '', ''); + print load_fiche_titre($langs->trans("NumberingModules").' ('.$myTmpObjectArray['label'].')', '', ''); print '
'.$langs->trans("Description").' '.$langs->trans("Value").''.$langs->trans("Value").'
'.$langs->trans("ECMAutoTree").' '; +print ''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('ECM_AUTO_TREE_ENABLED'); + print ajax_constantonoff('ECM_AUTO_TREE_HIDEN', null, null, 1); } else { - if (empty($conf->global->ECM_AUTO_TREE_ENABLED)) { - print ''.img_picto($langs->trans("Disabled"), 'off').''; - } elseif (!empty($conf->global->USER_MAIL_REQUIRED)) { - print ''.img_picto($langs->trans("Enabled"), 'on').''; + if (empty($conf->global->ECM_AUTO_TREE_HIDEN)) { + print ''.img_picto($langs->trans("Enabled"), 'on').''; + } else { + print ''.img_picto($langs->trans("Disabled"), 'off').''; } } print '
'; print ''; @@ -491,16 +491,16 @@ if ($action == 'edit') { if ($val['type'] == 'textarea') { print '\n"; } elseif ($val['type'] == 'integer') { - print '' . "\n"; + print '' . "\n"; } elseif ($val['type'] == 'html') { require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; - $doleditor = new DolEditor($constname, $conf->global->{$constname}, '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%'); + $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%'); $doleditor->Create(); } elseif ($val['type'] == 'yesno') { - print $form->selectyesno($constname, $conf->global->{$constname}, 1); + print $form->selectyesno($constname, getDolGlobalString($constname), 1); } elseif (preg_match('/emailtemplate:/', $val['type'])) { include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $formmail = new FormMail($db); @@ -575,9 +575,9 @@ if ($action == 'edit') { print ''; } diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index a42c2283d13..1cb418cb6c9 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -69,6 +69,7 @@ $search_type_template = GETPOST('search_type_template', 'alpha'); $search_lang = GETPOST('search_lang', 'alpha'); $search_fk_user = GETPOST('search_fk_user', 'intcomma'); $search_topic = GETPOST('search_topic', 'alpha'); +$search_module = GETPOST('search_module', 'alpha'); $acts = array(); $actl = array(); @@ -108,7 +109,7 @@ $tabname[25] = MAIN_DB_PREFIX."c_email_templates"; // Nom des champs en resultat de select pour affichage du dictionnaire $tabfield = array(); -$tabfield[25] = "label,lang,type_template,fk_user,private,position,topic,joinfiles,content"; +$tabfield[25] = "label,lang,type_template,fk_user,private,position,module,topic,joinfiles,content"; if (!empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { $tabfield[25] .= ',content_lines'; } @@ -290,6 +291,7 @@ if (empty($reshook)) { $search_lang = ''; $search_fk_user = ''; $search_topic = ''; + $search_module = ''; $toselect = array(); $search_array_options = array(); } @@ -598,6 +600,9 @@ if ($search_lang) { if ($search_fk_user != '' && $search_fk_user != '-1') { $sql .= natural_search('fk_user', $search_fk_user, 2); } +if ($search_module) { + $sql .= natural_search('module', $search_module); +} if ($search_topic) { $sql .= natural_search('topic', $search_topic); } @@ -703,6 +708,9 @@ if ($action == 'create') { $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut $valuetoshow = $langs->trans($valuetoshow); // try to translate $align = "left"; + if ($fieldlist[$field] == 'module') { + $valuetoshow = ''; + } if ($fieldlist[$field] == 'fk_user') { $valuetoshow = $langs->trans("Owner"); } @@ -802,9 +810,9 @@ if ($action == 'create') { $fieldsforcontent = array('topic', 'joinfiles', 'content', 'content_lines'); } foreach ($fieldsforcontent as $tmpfieldlist) { - print ''; foreach ($fieldlist as $field => $value) { - if ($value == 'label') { + if ($value == 'module') { + print ''; + } elseif ($value == 'label') { print ''; } elseif ($value == 'lang') { print ''; } elseif ($value == 'fk_user') { print ''; } elseif ($value == 'topic') { print ''; @@ -958,6 +971,9 @@ foreach ($fieldlist as $field => $value) { */ $valuetoshow = ucfirst($fieldlist[$field]); // By defaut $valuetoshow = $langs->trans($valuetoshow); // try to translate + if ($fieldlist[$field] == 'module') { + $align = 'tdoverflowmax100'; + } if ($fieldlist[$field] == 'fk_user') { $valuetoshow = $langs->trans("Owner"); } @@ -1056,7 +1072,7 @@ if ($num) { if ($showfield) { // Show line for topic, joinfiles and content print ''; - print ''; + } elseif ($value == 'fk_user') { print ''; } elseif ($context == 'add' && in_array($value, array('topic', 'joinfiles', 'content', 'content_lines'))) { diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index e18e65e47a0..1af4b25bb27 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -372,13 +372,13 @@ if ($mode == 'feature') { if (count($objMod->depends)) { $text .= join(',', $objMod->depends); } else { - $text .= $langs->trans("None"); + $text .= ''.$langs->trans("None").''; } $text .= '
'.$langs->trans("RequiredBy").': '; if (count($objMod->requiredby)) { $text .= join(',', $objMod->requiredby); } else { - $text .= $langs->trans("None"); + $text .= ''.$langs->trans("None").''; } $text .= '

'; @@ -395,7 +395,7 @@ if ($mode == 'feature') { $i++; } } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -408,7 +408,7 @@ if ($mode == 'feature') { $i++; } } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -418,7 +418,7 @@ if ($mode == 'feature') { if (dol_is_file($filedata)) { $text .= $langs->trans("Yes").' ('.$moduledir.'/sql/data.sql)'; } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -437,7 +437,7 @@ if ($mode == 'feature') { } } } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -446,7 +446,7 @@ if ($mode == 'feature') { if (isset($objMod->module_parts) && isset($objMod->module_parts['models']) && $objMod->module_parts['models']) { $text .= $langs->trans("Yes"); } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -455,7 +455,7 @@ if ($mode == 'feature') { if (isset($objMod->module_parts) && isset($objMod->module_parts['substitutions']) && $objMod->module_parts['substitutions']) { $text .= $langs->trans("Yes"); } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -468,7 +468,7 @@ if ($mode == 'feature') { $i++; } } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -498,11 +498,14 @@ if ($mode == 'feature') { if (isset($objMod->boxes) && is_array($objMod->boxes) && count($objMod->boxes)) { $i = 0; foreach ($objMod->boxes as $val) { - $text .= ($i ? ', ' : '').($val['file'] ? $val['file'] : $val[0]); + $boxstring = (empty($val['file']) ? (empty($val[0]) ? '' : $val[0]) : $val['file']); + if ($boxstring) { + $text .= ($i ? ', ' : '').$boxstring; + } $i++; } } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -531,7 +534,7 @@ if ($mode == 'feature') { $i++; } } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -544,7 +547,7 @@ if ($mode == 'feature') { $i++; } } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -553,7 +556,7 @@ if ($mode == 'feature') { if (isset($objMod->menu) && !empty($objMod->menu)) { // objMod can be an array or just an int 1 $text .= $langs->trans("Yes"); } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -566,7 +569,7 @@ if ($mode == 'feature') { $i++; } } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -579,13 +582,13 @@ if ($mode == 'feature') { $i++; } } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; $text .= '
'.$langs->trans("AddOtherPagesOrServices").': '; - $text .= $langs->trans("DetectionNotPossible"); + $text .= ''.$langs->trans("DetectionNotPossible").''; } @@ -594,7 +597,7 @@ if ($mode == 'changelog') { if ($changelog) { $text .= '
'.$changelog.'
'; } else { - $text .= '
'.$langs->trans("NotAvailable").'
'; + $text .= '
'.$langs->trans("NotAvailable").'
'; } } diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 8c9230d190c..6e0d90499d4 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -282,10 +282,39 @@ if ($action == 'set' && $user->admin) { } header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y ? '&page_y='.$page_y : '')); exit; +} elseif (getDolGlobalInt("MAIN_FEATURES_LEVEL") > 1 && $action == 'reload' && $user->admin && GETPOST('confirm') == 'yes') { + $result = unActivateModule($value, 0); + dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); + if ($result) { + setEventMessages($result, null, 'errors'); + header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y ? '&page_y='.$page_y : '')); + } + $resarray = activateModule($value, 0, 1); + dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); + if (!empty($resarray['errors'])) { + setEventMessages('', $resarray['errors'], 'errors'); + } else { + if ($resarray['nbperms'] > 0) { + $tmpsql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."user WHERE admin <> 1"; + $resqltmp = $db->query($tmpsql); + if ($resqltmp) { + $obj = $db->fetch_object($resqltmp); + if ($obj && $obj->nb > 1) { + $msg = $langs->trans('ModuleEnabledAdminMustCheckRights'); + setEventMessages($msg, null, 'warnings'); + } + } else { + dol_print_error($db); + } + } + } + header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y ? '&page_y='.$page_y : '')); + exit; } + /* * View */ @@ -464,6 +493,19 @@ if ($action == 'reset_confirm' && $user->admin) { } } +if ($action == 'reload_confirm' && $user->admin) { + if (!empty($modules[$value])) { + $objMod = $modules[$value]; + + if (!empty($objMod->langfiles)) { + $langs->loadLangs($objMod->langfiles); + } + + $form = new Form($db); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?value='.$value.'&mode='.$mode.$param, $langs->trans('ConfirmReload'), $langs->trans(GETPOST('confirm_message_code')), 'reload', '', 'no', 1); + } +} + print $formconfirm; asort($orders); @@ -547,6 +589,7 @@ if ($mode == 'common' || $mode == 'commonkanban') { $moreforfilter .= '
'; $moreforfilter .= $form->selectarray('search_nature', $arrayofnatures, dol_escape_htmltag($search_nature), $langs->trans('Origin'), 0, 0, '', 0, 0, 0, '', 'maxwidth250', 1); $moreforfilter .= '
'; + if (getDolGlobalInt('MAIN_FEATURES_LEVEL')) { $array_version = array('stable'=>$langs->transnoentitiesnoconv("Stable")); if ($conf->global->MAIN_FEATURES_LEVEL < 0) { @@ -559,11 +602,12 @@ if ($mode == 'common' || $mode == 'commonkanban') { $array_version['development'] = $langs->trans("Development"); } $moreforfilter .= '
'; - $moreforfilter .= $form->selectarray('search_version', $array_version, $search_version, $langs->trans('Version'), 0, 0, '', 0, 0, 0, '', 'maxwidth150', 1); + $moreforfilter .= $form->selectarray('search_version', $array_version, $search_version, $langs->transnoentitiesnoconv('Version'), 0, 0, '', 0, 0, 0, '', 'maxwidth150', 1); $moreforfilter .= '
'; } + $array_status = array('active'=>$langs->transnoentitiesnoconv("Enabled"), 'disabled'=>$langs->transnoentitiesnoconv("Disabled")); $moreforfilter .= '
'; - $moreforfilter .= $form->selectarray('search_status', array('active'=>$langs->transnoentitiesnoconv("Enabled"), 'disabled'=>$langs->transnoentitiesnoconv("Disabled")), $search_status, $langs->trans('Status'), 0, 0, '', 0, 0, 0, '', 'maxwidth150', 1); + $moreforfilter .= $form->selectarray('search_status', $array_status, $search_status, $langs->transnoentitiesnoconv('Status'), 0, 0, '', 0, 0, 0, '', 'maxwidth150', 1); $moreforfilter .= '
'; $moreforfilter .= ' '; $moreforfilter .= '
'; @@ -734,15 +778,17 @@ if ($mode == 'common' || $mode == 'commonkanban') { // Version (with picto warning or not) $version = $objMod->getVersion(0); $versiontrans = ''; + $warningstring = ''; if (preg_match('/development/i', $version)) { - $versiontrans .= img_warning($langs->trans("Development"), '', 'floatleft paddingright'); + $warningstring = $langs->trans("Development"); } if (preg_match('/experimental/i', $version)) { - $versiontrans .= img_warning($langs->trans("Experimental"), '', 'floatleft paddingright'); + $warningstring = $langs->trans("Experimental"); } if (preg_match('/deprecated/i', $version)) { - $versiontrans .= img_warning($langs->trans("Deprecated"), '', 'floatleft paddingright'); + $warningstring = $langs->trans("Deprecated"); } + if ($objMod->isCoreOrExternalModule() == 'external' || preg_match('/development|experimental|deprecated/i', $version)) { $versiontrans .= $objMod->getVersion(1); } @@ -800,12 +846,24 @@ if ($mode == 'common' || $mode == 'commonkanban') { } else { if (!empty($objMod->warnings_unactivation[$mysoc->country_code]) && method_exists($objMod, 'alreadyUsed') && $objMod->alreadyUsed()) { $codeenabledisable .= 'warnings_unactivation[$mysoc->country_code]).'&value='.$modName.'&mode='.$mode.$param.'">'; - $codeenabledisable .= img_picto($langs->trans("Activated"), 'switch_on'); + $codeenabledisable .= img_picto($langs->trans("Activated").($warningstring ? ' '.$warningstring : ''), 'switch_on'); $codeenabledisable .= ''; + if (getDolGlobalInt("MAIN_FEATURES_LEVEL") > 1) { + $codeenabledisable .= ' '; + $codeenabledisable .= ''; + $codeenabledisable .= img_picto($langs->trans("Reload"), 'refresh', 'class="opacitymedium"'); + $codeenabledisable .= ''; + } } else { $codeenabledisable .= ''; - $codeenabledisable .= img_picto($langs->trans("Activated"), 'switch_on'); + $codeenabledisable .= img_picto($langs->trans("Activated").($warningstring ? ' '.$warningstring : ''), 'switch_on'); $codeenabledisable .= ''; + if (getDolGlobalInt("MAIN_FEATURES_LEVEL") > 1) { + $codeenabledisable .= ' '; + $codeenabledisable .= ''; + $codeenabledisable .= img_picto($langs->trans("Reload"), 'refresh', 'class="opacitymedium"'); + $codeenabledisable .= ''; + } } } @@ -844,10 +902,10 @@ if ($mode == 'common' || $mode == 'commonkanban') { } } } - } elseif (preg_match('/^([^@]+)@([^@]+)$/i', $objMod->config_page_url, $regs)) { + } elseif (preg_match('/^([^@]+)@([^@]+)$/i', (string) $objMod->config_page_url, $regs)) { $codetoconfig .= ''.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', false, 0, 0, '', 'fa-15').''; } else { - $codetoconfig .= ''.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', false, 0, 0, '', 'fa-15').''; + $codetoconfig .= ''.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', false, 0, 0, '', 'fa-15').''; } } else { $codetoconfig .= img_picto($langs->trans("NothingToSetup"), "setup", 'class="opacitytransp" style="padding-right: 6px"', false, 0, 0, '', 'fa-15'); @@ -907,7 +965,7 @@ if ($mode == 'common' || $mode == 'commonkanban') { // Output Kanban print $objMod->getKanbanView($codeenabledisable, $codetoconfig); } else { - print '
'."\n"; + print ''."\n"; if (!empty($conf->global->MAIN_MODULES_SHOW_LINENUMBERS)) { print ''; } @@ -941,7 +999,7 @@ if ($mode == 'common' || $mode == 'commonkanban') { print ''; // Version - print '\n"; // Link enable/disable - print '\n"; @@ -1075,7 +1133,7 @@ if ($mode == 'marketplace') {
'; if ($val['type'] == 'textarea') { - print dol_nl2br($conf->global->{$constname}); + print dol_nl2br(getDolGlobalString($constname)); } elseif ($val['type']== 'html') { - print $conf->global->{$constname}; + print getDolGlobalString($constname); } elseif ($val['type'] == 'yesno') { print ajax_constantonoff($constname); } elseif (preg_match('/emailtemplate:/', $val['type'])) { @@ -586,14 +586,14 @@ if ($action == 'edit') { $tmp = explode(':', $val['type']); - $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, $conf->global->{$constname}); + $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalString($constname)); if ($template<0) { setEventMessages(null, $formmail->errors, 'errors'); } print $langs->trans($template->label); } elseif (preg_match('/category:/', $val['type'])) { $c = new Categorie($db); - $result = $c->fetch($conf->global->{$constname}); + $result = $c->fetch(getDolGlobalString($constname)); if ($result < 0) { setEventMessages(null, $c->errors, 'errors'); } diff --git a/htdocs/admin/knowledgemanagement.php b/htdocs/admin/knowledgemanagement.php index b1710a53839..3fc8ebb3724 100644 --- a/htdocs/admin/knowledgemanagement.php +++ b/htdocs/admin/knowledgemanagement.php @@ -69,11 +69,11 @@ if (!$user->admin) { include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstorder = GETPOST('maskconstorder', 'alpha'); + $maskconst = GETPOST('maskconst', 'aZ09'); $maskorder = GETPOST('maskorder', 'alpha'); - if ($maskconstorder) { - $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity); + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { + $res = dolibarr_set_const($db, $maskconst, $maskorder, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; } @@ -209,14 +209,14 @@ if ($action == 'edit') { if ($val['type'] == 'textarea') { print '\n"; } elseif ($val['type'] == 'html') { require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; - $doleditor = new DolEditor($constname, $conf->global->{$constname}, '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%'); + $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%'); $doleditor->Create(); } elseif ($val['type'] == 'yesno') { - print $form->selectyesno($constname, $conf->global->{$constname}, 1); + print $form->selectyesno($constname, getDolGlobalString($constname), 1); } elseif (preg_match('/emailtemplate:/', $val['type'])) { include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $formmail = new FormMail($db); @@ -275,9 +275,9 @@ if ($action == 'edit') { print ''; if ($val['type'] == 'textarea') { - print dol_nl2br($conf->global->{$constname}); + print dol_nl2br(getDolGlobalString($constname)); } elseif ($val['type']== 'html') { - print $conf->global->{$constname}; + print getDolGlobalString($constname); } elseif ($val['type'] == 'yesno') { print ajax_constantonoff($constname); } elseif (preg_match('/emailtemplate:/', $val['type'])) { @@ -286,7 +286,7 @@ if ($action == 'edit') { $tmp = explode(':', $val['type']); - $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, $conf->global->{$constname}); + $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalString($constname)); if ($template<0) { setEventMessages(null, $formmail->errors, 'errors'); } @@ -304,17 +304,17 @@ if ($action == 'edit') { } print '
    ' . implode(' ', $toprint) . '
'; } elseif (preg_match('/thirdparty_type/', $val['type'])) { - if ($conf->global->{$constname}==2) { + if (getDolGlobalString($constname)==2) { print $langs->trans("Prospect"); - } elseif ($conf->global->{$constname}==3) { + } elseif (getDolGlobalString($constname)==3) { print $langs->trans("ProspectCustomer"); - } elseif ($conf->global->{$constname}==1) { + } elseif (getDolGlobalInt($constname)==1) { print $langs->trans("Customer"); - } elseif ($conf->global->{$constname}==0) { + } elseif (getDolGlobalInt($constname)==0) { print $langs->trans("NorProspectNorCustomer"); } } else { - print $conf->global->{$constname}; + print getDolGlobalString($constname); } print '
'; + print '
'; - // Label + // Topic of email if ($tmpfieldlist == 'topic') { print ''.$form->textwithpicto($langs->trans("Topic"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).' '; } @@ -882,6 +890,9 @@ if ($search_type_template != '-1') { if ($search_fk_user > 0) { $param .= '&search_fk_user='.urlencode($search_fk_user); } +if ($search_module) { + $param .= '&search_module='.urlencode($search_module); +} if ($search_topic) { $param .= '&search_topic='.urlencode($search_topic); } @@ -909,7 +920,9 @@ if ($num > $listlimit) { print '
'; @@ -917,7 +930,7 @@ foreach ($fieldlist as $field => $value) { print ''; - print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'maxwidth125', 1); + print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'maxwidth100', 1); print '
'; + print ''; if ($tmpfieldlist == 'topic') { print ''.$form->textwithpicto($langs->trans("Topic"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).' '; print ''; @@ -1072,7 +1088,6 @@ if ($num) { if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { $okforextended = false; } - $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 500, 'dolibarr_mailings', 'In', 0, $acceptlocallinktomedia, $okforextended, ROWS_6, '90%'); print $doleditor->Create(1); } @@ -1134,7 +1149,8 @@ if ($num) { $align = ""; $class = "tddict"; $title = ''; - $valuetoshow = $obj->{$fieldlist[$field]}; + $tmpvar = $fieldlist[$field]; + $valuetoshow = $obj->$tmpvar; if ($value == 'label' || $value == 'topic') { if ($langs->trans($valuetoshow) != $valuetoshow) { $valuetoshow = $langs->trans($valuetoshow); @@ -1272,29 +1288,31 @@ $db->close(); */ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') { - global $conf, $langs, $user, $db; + global $langs, $user, $db; global $form; global $elementList; $formadmin = new FormAdmin($db); foreach ($fieldlist as $field => $value) { - if ($value == 'fk_user') { + if ($value == 'module') { + print ''; if ($user->admin) { - print $form->select_dolusers(empty($obj->{$value}) ? '' : $obj->{$value}, 'fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'minwidth150 maxwidth200'); + print $form->select_dolusers(empty($obj->$value) ? '' : $obj->$value, 'fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'minwidth75 maxwidth100'); } else { if ($context == 'add') { // I am not admin and we show the add form print $user->getNomUrl(1); // Me $forcedvalue = $user->id; } else { - if ($obj && !empty($obj->{$value}) && $obj->{$value} > 0) { + if ($obj && !empty($obj->$value) && $obj->$value > 0) { $fuser = new User($db); - $fuser->fetch($obj->{$value}); + $fuser->fetch($obj->$value); print $fuser->getNomUrl(1); $forcedvalue = $fuser->id; } else { - $forcedvalue = $obj->{$value}; + $forcedvalue = $obj->$value; } } $keyname = $value; @@ -1308,7 +1326,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') if ($context == 'edit') { $selectedlang = $obj->lang; } - print $formadmin->select_language($selectedlang, 'langcode', 0, null, 1, 0, 0, 'maxwidth150'); + print $formadmin->select_language($selectedlang, 'langcode', 0, null, 1, 0, 0, 'maxwidth100'); } else { if (!empty($obj->lang)) { print $obj->lang.' - '.$langs->trans('Language_'.$obj->lang); @@ -1328,7 +1346,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') print ''; print $obj->type_template; } else { - print $form->selectarray('type_template', $elementList, (!empty($obj->type_template) ? $obj->type_template:''), 1, 0, 0, '', 0, 0, 0, '', 'minwidth150', 1, '', 0, 1); + print $form->selectarray('type_template', $elementList, (!empty($obj->type_template) ? $obj->type_template:''), 1, 0, 0, '', 0, 0, 0, '', 'minwidth75 maxwidth125', 1, '', 0, 1); } print '
'.$linenum.''; + print ''; if ($objMod->needUpdate) { $versionTitle = $langs->trans('ModuleUpdateAvailable').' : '.$objMod->lastVersion; print ''.$versiontrans.''; @@ -951,7 +1009,7 @@ if ($mode == 'common' || $mode == 'commonkanban') { print "'; + print ''; print $codeenabledisable; print "
- get_products(!empty($categorie) ? $categorie: ''); ?> + get_products(); ?>
@@ -1216,10 +1274,10 @@ if ($mode == 'deploy') { print ''."\n"; diff --git a/htdocs/admin/mrp.php b/htdocs/admin/mrp.php index 36a82e965f4..21fff1c45e6 100644 --- a/htdocs/admin/mrp.php +++ b/htdocs/admin/mrp.php @@ -52,10 +52,10 @@ $type = 'mrp'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstmrp = GETPOST('maskconstMo', 'alpha'); + $maskconstmrp = GETPOST('maskconstMo', 'aZ09'); $maskmrp = GETPOST('maskMo', 'alpha'); - if ($maskconstmrp) { + if ($maskconstmrp && preg_match('/_MASK$/', $maskconstmrp)) { $res = dolibarr_set_const($db, $maskconstmrp, $maskmrp, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index 1cf838c08cb..5945ebfb5d5 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -134,7 +134,8 @@ if ($action == 'add_currency') { dolibarr_set_const($db, 'MULTICURRENCY_APP_SOURCE', GETPOST('MULTICURRENCY_APP_SOURCE', 'alpha')); //dolibarr_set_const($db, 'MULTICURRENCY_ALTERNATE_SOURCE', GETPOST('MULTICURRENCY_ALTERNATE_SOURCE', 'alpha')); } else { - $result = MultiCurrency::syncRates($conf->global->MULTICURRENCY_APP_ID); + $multiurrency = new MultiCurrency($db); + $result = $multiurrency->syncRates(getDolGlobalString('MULTICURRENCY_APP_ID')); if ($result > 0) { setEventMessages($langs->trans("CurrencyRateSyncSucceed"), null, "mesgs"); } diff --git a/htdocs/admin/oauth.php b/htdocs/admin/oauth.php index 64968b1a516..217dfd63cc9 100644 --- a/htdocs/admin/oauth.php +++ b/htdocs/admin/oauth.php @@ -285,7 +285,7 @@ if (count($listinsetup) > 0) { // Delete print ''; $label = preg_replace('/_NAME$/', '', $keyforsupportedoauth2array); - print ''; + print ''; print img_picto('', 'delete'); print ''; @@ -298,7 +298,8 @@ if (count($listinsetup) > 0) { $redirect_uri = $urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$keyforsupportedoauth2array]['callbackfile'].'_oauthcallback.php'; print ''; print ''.$langs->trans("UseTheFollowingUrlAsRedirectURI").''; - print ''; + print ''; + print ajax_autoselect('uri'.$keyforsupportedoauth2array.$keyforprovider); print ''; print ''; print ''; @@ -306,7 +307,7 @@ if (count($listinsetup) > 0) { if ($keyforsupportedoauth2array == 'OAUTH_OTHER_NAME') { print ''; print ''.$langs->trans("URLOfServiceForAuthorization").''; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php index f798995d525..9a0532880cd 100644 --- a/htdocs/admin/oauthlogintokens.php +++ b/htdocs/admin/oauthlogintokens.php @@ -213,7 +213,13 @@ if ($mode == 'setup' && $user->admin) { $urltocheckperms = ''; } - $urltorenew .= '&keyforprovider='.urlencode($keyforprovider); + if ($urltorenew) { + $urltorenew .= '&keyforprovider='.urlencode($keyforprovider); + } + if ($urltodelete) { + $urltodelete .= '&keyforprovider='.urlencode($keyforprovider); + } + // Show value of token $tokenobj = null; diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index 59da712b266..7b0d0acbf06 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -51,9 +51,9 @@ if (empty($conf->global->PAYMENT_ADDON)) { */ if ($action == 'updateMask') { - $maskconstpayment = GETPOST('maskconstpayment', 'alpha'); + $maskconstpayment = GETPOST('maskconstpayment', 'aZ09'); $maskpayment = GETPOST('maskpayment', 'alpha'); - if ($maskconstpayment) { + if ($maskconstpayment && preg_match('/_MASK$/', $maskconstpayment)) { $res = dolibarr_set_const($db, $maskconstpayment, $maskpayment, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 7883cc7da20..10044e33b5b 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -58,9 +58,9 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; $error = 0; if ($action == 'updateMask') { - $maskconstpropal = GETPOST('maskconstpropal', 'alpha'); + $maskconstpropal = GETPOST('maskconstpropal', 'aZ09'); $maskpropal = GETPOST('maskpropal', 'alpha'); - if ($maskconstpropal) { + if ($maskconstpropal && preg_match('/_MASK$/', $maskconstpropal)) { $res = dolibarr_set_const($db, $maskconstpropal, $maskpropal, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/reception_setup.php b/htdocs/admin/reception_setup.php index c86db66e464..32f6c5b226e 100644 --- a/htdocs/admin/reception_setup.php +++ b/htdocs/admin/reception_setup.php @@ -65,9 +65,9 @@ if (empty($conf->global->RECEPTION_ADDON_NUMBER)) { include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconst = GETPOST('maskconstreception', 'alpha'); + $maskconst = GETPOST('maskconstreception', 'aZ09'); $maskvalue = GETPOST('maskreception', 'alpha'); - if (!empty($maskconst)) { + if (!empty($maskconst) && preg_match('/_MASK$/', $maskconst)) { $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/stocktransfer.php b/htdocs/admin/stocktransfer.php index 3bcd00c1fe8..02c73bb2a76 100644 --- a/htdocs/admin/stocktransfer.php +++ b/htdocs/admin/stocktransfer.php @@ -64,10 +64,10 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconststocktransfer = GETPOST('maskconststocktransfer', 'alpha'); + $maskconststocktransfer = GETPOST('maskconststocktransfer', 'aZ09'); $maskstocktransfer = GETPOST('maskStockTransfer', 'alpha'); - if ($maskconststocktransfer) { + if ($maskconststocktransfer && preg_match('/_MASK$/', $maskconststocktransfer)) { $res = dolibarr_set_const($db, $maskconststocktransfer, $maskstocktransfer, 'chaine', 0, '', $conf->entity); if ($res <= 0) $error++; } diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php index ef26b80b69a..bbb97e293fe 100644 --- a/htdocs/admin/supplier_invoice.php +++ b/htdocs/admin/supplier_invoice.php @@ -38,10 +38,6 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "other", "orders")); -if (!$user->admin) { - accessforbidden(); -} - $type = GETPOST('type', 'alpha'); $value = GETPOST('value', 'alpha'); $action = GETPOST('action', 'aZ09'); @@ -52,6 +48,12 @@ $scandir = GETPOST('scan_dir', 'alpha'); $specimenthirdparty = new Societe($db); $specimenthirdparty->initAsSpecimen(); +$error = 0; + +if (!$user->admin) { + accessforbidden(); +} + /* * Actions @@ -60,20 +62,20 @@ $specimenthirdparty->initAsSpecimen(); include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstinvoice = GETPOST('maskconstinvoice', 'alpha'); - $maskconstcredit = GETPOST('maskconstcredit', 'alpha'); - $maskconstdeposit = GETPOST('maskconstdeposit', 'alpha'); + $maskconstinvoice = GETPOST('maskconstinvoice', 'aZ09'); + $maskconstcredit = GETPOST('maskconstcredit', 'aZ09'); + $maskconstdeposit = GETPOST('maskconstdeposit', 'aZ09'); $maskinvoice = GETPOST('maskinvoice', 'alpha'); $maskcredit = GETPOST('maskcredit', 'alpha'); $maskdeposit = GETPOST('maskdeposit', 'alpha'); - if ($maskconstinvoice) { + if ($maskconstinvoice && preg_match('/_MASK$/', $maskconstinvoice)) { $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity); } - if ($maskconstcredit) { + if ($maskconstcredit && preg_match('/_MASK$/', $maskconstcredit)) { $res = dolibarr_set_const($db, $maskconstcredit, $maskcredit, 'chaine', 0, '', $conf->entity); } - if ($maskconstdeposit) { + if ($maskconstdeposit && preg_match('/_MASK$/', $maskconstdeposit)) { $res = dolibarr_set_const($db, $maskconstdeposit, $maskdeposit, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index bb1b94d4385..abee8200cef 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -61,10 +61,10 @@ $specimenthirdparty->initAsSpecimen(); include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstorder = GETPOST('maskconstorder', 'alpha'); + $maskconstorder = GETPOST('maskconstorder', 'aZ09'); $maskvalue = GETPOST('maskorder', 'alpha'); - if ($maskconstorder) { + if ($maskconstorder && preg_match('/_MASK$/', $maskconstorder)) { $res = dolibarr_set_const($db, $maskconstorder, $maskvalue, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/supplier_payment.php b/htdocs/admin/supplier_payment.php index 86fcccfb8f2..ac00e4846ac 100644 --- a/htdocs/admin/supplier_payment.php +++ b/htdocs/admin/supplier_payment.php @@ -52,9 +52,9 @@ $type = 'supplier_payment'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstsupplierpayment = GETPOST('maskconstsupplierpayment', 'alpha'); + $maskconstsupplierpayment = GETPOST('maskconstsupplierpayment', 'aZ09'); $masksupplierpayment = GETPOST('masksupplierpayment', 'alpha'); - if ($maskconstsupplierpayment) { + if ($maskconstsupplierpayment && preg_match('/_MASK$/', $maskconstsupplierpayment)) { $res = dolibarr_set_const($db, $maskconstsupplierpayment, $masksupplierpayment, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php index 993e19fc796..62be111449d 100644 --- a/htdocs/admin/supplier_proposal.php +++ b/htdocs/admin/supplier_proposal.php @@ -55,9 +55,9 @@ $error = 0; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstsupplier_proposal = GETPOST('maskconstsupplier_proposal', 'alpha'); + $maskconstsupplier_proposal = GETPOST('maskconstsupplier_proposal', 'aZ09'); $masksupplier_proposal = GETPOST('masksupplier_proposal', 'alpha'); - if ($maskconstsupplier_proposal) { + if ($maskconstsupplier_proposal && preg_match('/_MASK$/', $maskconstsupplier_proposal)) { $res = dolibarr_set_const($db, $maskconstsupplier_proposal, $masksupplier_proposal, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index 71f7fd7f875..cf07dd49539 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -115,9 +115,6 @@ if ($action == 'set') { // Check configuration foreach ($activeModules as $modulename) { - /** - * @var LogHandler - */ $module = new $modulename; $error = $module->checkConfiguration(); } diff --git a/htdocs/admin/system/database.php b/htdocs/admin/system/database.php index 8cd1ad3d597..fd983a10924 100644 --- a/htdocs/admin/system/database.php +++ b/htdocs/admin/system/database.php @@ -113,7 +113,8 @@ if (!count($listofvars) && !count($listofstatus)) { if ($key != $param) { continue; } - $val2 = ${$val['var']}; + $tmpvar = $val['var']; + $val2 = ${$tmpvar}; $text = 'Should be in line with value of param '.$val['var'].' thas is '.($val2 ? $val2 : "'' (=".$val['valifempty'].")").''; $show = 1; } diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index 4a55c1a1160..afe5d4d3520 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -264,7 +264,7 @@ $daylight = round($c - $b); $val = ($a >= 0 ? '+' : '').$a; $val .= ' ('.($a == 'unknown' ? 'unknown' : ($a >= 0 ? '+' : '').($a * 3600)).')'; $val .= '       '.getServerTimeZoneString(); -$val .= '       '.$langs->trans("DaylingSavingTime").': '.($daylight === 'unknown' ? 'unknown' : ($a == $c ?yn($daylight) : yn(0).($daylight ? '     ('.$langs->trans('YesInSummer').')' : ''))); +$val .= '       '.$langs->trans("DaylingSavingTime").': '.(is_null($daylight) ? 'unknown' : ($a == $c ?yn($daylight) : yn(0).($daylight ? '     ('.$langs->trans('YesInSummer').')' : ''))); print $form->textwithtooltip($val, $txt, 2, 1, img_info('')); print ''."\n"; // value defined in http://fr3.php.net/manual/en/timezones.europe.php print '  => '.$langs->trans("CurrentHour").''.dol_print_date(dol_now('gmt'), 'dayhour', 'tzserver').''."\n"; diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index 9cebbc3b36d..6a6201642ee 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -47,7 +47,7 @@ $scandir = GETPOST('scandir', 'alpha'); $type = 'ticket'; $error = 0; - +$reg = array(); /* * Actions @@ -56,10 +56,10 @@ $error = 0; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstticket = GETPOST('maskconstticket', 'alpha'); + $maskconstticket = GETPOST('maskconstticket', 'aZ09'); $maskticket = GETPOST('maskticket', 'alpha'); - if ($maskconstticket) { + if ($maskconstticket && preg_match('/_MASK$/', $maskconstticket)) { $res = dolibarr_set_const($db, $maskconstticket, $maskticket, 'chaine', 0, '', $conf->entity); } @@ -484,7 +484,7 @@ foreach ($dirmodels as $reldir) { // Preview print ''; if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'pdf').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } @@ -526,7 +526,7 @@ if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $formcategory->selectarray("TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND", $arrval, $conf->global->TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND); + print $formcategory->selectarray("TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND", $arrval, getDolGlobalString('TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND')); } print ''; print ''; @@ -542,7 +542,7 @@ if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_AUTO_ASSIGN_USER_CREATE'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $formcategory->selectarray("TICKET_AUTO_ASSIGN_USER_CREATE", $arrval, $conf->global->TICKET_AUTO_ASSIGN_USER_CREATE); + print $formcategory->selectarray("TICKET_AUTO_ASSIGN_USER_CREATE", $arrval, getDolGlobalString('TICKET_AUTO_ASSIGN_USER_CREATE')); } print ''; print ''; @@ -557,7 +557,7 @@ if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_NOTIFY_AT_CLOSING'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $formcategory->selectarray("TICKET_NOTIFY_AT_CLOSING", $arrval, $conf->global->TICKET_NOTIFY_AT_CLOSING); + print $formcategory->selectarray("TICKET_NOTIFY_AT_CLOSING", $arrval, getDolGlobalString('TICKET_NOTIFY_AT_CLOSING')); } print ''; print ''; @@ -569,7 +569,7 @@ if (isModEnabled('product')) { $htmlname = "product_category_id"; print ''.$langs->trans("TicketChooseProductCategory").''; print ''; - $formcategory->selectProductCategory($conf->global->TICKET_PRODUCT_CATEGORY, $htmlname); + $formcategory->selectProductCategory(getDolGlobalString('TICKET_PRODUCT_CATEGORY'), $htmlname); if ($conf->use_javascript_ajax) { print ajax_combobox('select_'.$htmlname); } @@ -583,7 +583,7 @@ if (isModEnabled('product')) { print ''; print ''.$langs->trans("TicketsDelayBeforeFirstAnswer").""; print ' - + '; print ''; print $formcategory->textwithpicto('', $langs->trans("TicketsDelayBeforeFirstAnswerHelp"), 1, 'help'); @@ -593,7 +593,7 @@ print ''; print ''; print ''.$langs->trans("TicketsDelayBetweenAnswers").""; print ' - + '; print ''; print $formcategory->textwithpicto('', $langs->trans("TicketsDelayBetweenAnswersHelp"), 1, 'help'); diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index abb5ebfd6ba..fcbc01abef1 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -427,7 +427,7 @@ if ($mode == 'overwrite') { print '   '; print ''; } else { - print ''.img_edit().''; + print ''.img_edit().''; print '   '; print ''.img_delete().''; } diff --git a/htdocs/admin/webhook.php b/htdocs/admin/webhook.php index b589eac4079..91d3358a92d 100644 --- a/htdocs/admin/webhook.php +++ b/htdocs/admin/webhook.php @@ -150,10 +150,10 @@ $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconst = GETPOST('maskconst', 'alpha'); + $maskconst = GETPOST('maskconst', 'aZ09'); $maskvalue = GETPOST('maskvalue', 'alpha'); - if ($maskconst) { + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; @@ -293,14 +293,14 @@ if ($action == 'edit') { if ($val['type'] == 'textarea') { print '\n"; } elseif ($val['type']== 'html') { require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; - $doleditor = new DolEditor($constname, $conf->global->{$constname}, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); + $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); $doleditor->Create(); } elseif ($val['type'] == 'yesno') { - print $form->selectyesno($constname, $conf->global->{$constname}, 1); + print $form->selectyesno($constname, getDolGlobalString($constname), 1); } elseif (preg_match('/emailtemplate:/', $val['type'])) { include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $formmail = new FormMail($db); @@ -382,9 +382,9 @@ if ($action == 'edit') { print ''; if ($val['type'] == 'textarea') { - print dol_nl2br($conf->global->{$constname}); + print dol_nl2br(getDolGlobalString($constname)); } elseif ($val['type']== 'html') { - print $conf->global->{$constname}; + print getDolGlobalString($constname); } elseif ($val['type'] == 'yesno') { print ajax_constantonoff($constname); } elseif (preg_match('/emailtemplate:/', $val['type'])) { @@ -393,14 +393,14 @@ if ($action == 'edit') { $tmp = explode(':', $val['type']); - $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, $conf->global->{$constname}); + $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalString($constname)); if ($template<0) { setEventMessages(null, $formmail->errors, 'errors'); } print $langs->trans($template->label); } elseif (preg_match('/category:/', $val['type'])) { $c = new Categorie($db); - $result = $c->fetch($conf->global->{$constname}); + $result = $c->fetch(getDolGlobalString($constname)); if ($result < 0) { setEventMessages(null, $c->errors, 'errors'); } elseif ($result > 0 ) { @@ -412,25 +412,25 @@ if ($action == 'edit') { print '
    ' . implode(' ', $toprint) . '
'; } } elseif (preg_match('/thirdparty_type/', $val['type'])) { - if ($conf->global->{$constname}==2) { + if (getDolGlobalInt($constname)==2) { print $langs->trans("Prospect"); - } elseif ($conf->global->{$constname}==3) { + } elseif (getDolGlobalInt($constname)==3) { print $langs->trans("ProspectCustomer"); - } elseif ($conf->global->{$constname}==1) { + } elseif (getDolGlobalInt($constname)==1) { print $langs->trans("Customer"); - } elseif ($conf->global->{$constname}==0) { + } elseif (getDolGlobalInt($constname)==0) { print $langs->trans("NorProspectNorCustomer"); } } elseif ($val['type'] == 'product') { $product = new Product($db); - $resprod = $product->fetch($conf->global->{$constname}); + $resprod = $product->fetch(getDolGlobalInt($constname)); if ($resprod > 0) { print $product->ref; } elseif ($resprod < 0) { setEventMessages(null, $object->errors, "errors"); } } else { - print $conf->global->{$constname}; + print getDolGlobalString($constname); } print ''; } diff --git a/htdocs/admin/website.php b/htdocs/admin/website.php index 3c348d71a12..d8fb57b49f5 100644 --- a/htdocs/admin/website.php +++ b/htdocs/admin/website.php @@ -84,7 +84,7 @@ $tablib[1] = "Websites"; // Requests to extract data $tabsql = array(); -$tabsql[1] = "SELECT f.rowid as rowid, f.entity, f.ref, f.description, f.virtualhost, f.position, f.status, f.date_creation FROM ".MAIN_DB_PREFIX.'website as f WHERE f.entity IN ('.getEntity('website').')'; +$tabsql[1] = "SELECT f.rowid as rowid, f.entity, f.ref, f.description, f.virtualhost, f.position, f.status, f.date_creation, f.lastaccess, f.pageviews_previous_month, f.pageviews_total FROM ".MAIN_DB_PREFIX.'website as f WHERE f.entity IN ('.getEntity('website').')'; // Criteria to sort dictionaries $tabsqlsort = array(); @@ -92,7 +92,7 @@ $tabsqlsort[1] = "ref ASC"; // Nom des champs en resultat de select pour affichage du dictionnaire $tabfield = array(); -$tabfield[1] = "ref,description,virtualhost,position,date_creation"; +$tabfield[1] = "ref,description,virtualhost,position,date_creation,lastaccess,pageviews_previous_month,pageviews_total"; // Nom des champs d'edition pour modification d'un enregistrement $tabfieldvalue = array(); @@ -186,7 +186,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { $sql .= $tabrowid[$id].","; } $sql .= $tabfieldinsert[$id]; - $sql .= ",status)"; + $sql .= ", status, date_creation)"; $sql .= " VALUES("; // List of values @@ -211,7 +211,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { } $i++; } - $sql .= ",1)"; + $sql .= ", 1, '".$db->idate(dol_now())."')"; dol_syslog("actionadd", LOG_DEBUG); $result = $db->query($sql); @@ -441,12 +441,10 @@ if ($id) { // Form to add a new line if ($tabname[$id]) { - $fieldlist = explode(',', $tabfield[$id]); - // Line for title print ''; foreach ($fieldlist as $field => $value) { - if ($fieldlist[$field] == 'date_creation') { + if (in_array($fieldlist[$field], array('date_creation', 'lastaccess', 'pageviews_previous_month', 'pageviews_month', 'pageviews_total'))) { continue; } @@ -522,6 +520,7 @@ if ($id) { print ''; print ''; + print '
'; print ''; // Title of lines @@ -533,6 +532,10 @@ if ($id) { $align = "left"; $sortable = 1; $valuetoshow = ''; + if (in_array($fieldlist[$field], array('pageviews_total', 'pageviews_previous_month'))) { + $align = 'right'; + } + /* $tmparray=getLabelOfField($fieldlist[$field]); $showfield=$tmp['showfield']; @@ -554,14 +557,24 @@ if ($id) { if ($fieldlist[$field] == 'date_creation') { $valuetoshow = $langs->trans("DateCreation"); } + if ($fieldlist[$field] == 'lastaccess') { + $valuetoshow = $langs->trans("LastAccess"); + } + if ($fieldlist[$field] == 'pageviews_previous_month') { + $valuetoshow = $langs->trans("PagesViewedPreviousMonth"); + } + if ($fieldlist[$field] == 'pageviews_total') { + $valuetoshow = $langs->trans("PagesViewedTotal"); + } // Affiche nom du champ if ($showfield) { - print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), "", "align=".$align, $sortfield, $sortorder); + print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), "", '', $sortfield, $sortorder, $align.' '); } } - print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "status", ($page ? 'page='.$page.'&' : ''), "", 'align="center"', $sortfield, $sortorder); + // Status + print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "status", ($page ? 'page='.$page.'&' : ''), "", '', $sortfield, $sortorder, 'center '); print getTitleFieldOfList(''); print getTitleFieldOfList(''); print ''; @@ -581,8 +594,9 @@ if ($id) { fieldListWebsites($fieldlist, $obj, $tabname[$id], 'edit'); } - print ''; + print ''; } else { $tmpaction = 'view'; $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); @@ -593,13 +607,16 @@ if ($id) { if (empty($reshook)) { foreach ($fieldlist as $field => $value) { $showfield = 1; - $align = "left"; $fieldname = $fieldlist[$field]; + $align = "left"; + if (in_array($fieldname, array('pageviews_total', 'pageviews_previous_month'))) { + $align = 'right'; + } $valuetoshow = $obj->$fieldname; // Show value for field if ($showfield) { - print ''; + print ''; } } } @@ -612,9 +629,10 @@ if ($id) { $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : '').'&'; + // Active print '"; // Modify link @@ -633,6 +651,7 @@ if ($id) { } print '
 '; - print '  '; + print ''; + print ' '.$valuetoshow.''.$valuetoshow.''; - print ''.$actl[($obj->status ? 1 : 0)].''; + print ''.$actl[($obj->status ? 1 : 0)].''; print "
'; + print '
'; print ''; } @@ -668,6 +687,10 @@ function fieldListWebsites($fieldlist, $obj = '', $tabname = '', $context = '') $formadmin = new FormAdmin($db); foreach ($fieldlist as $field => $value) { + if (in_array($fieldlist[$field], array('lastaccess', 'pageviews_previous_month', 'pageviews_month', 'pageviews_total'))) { + continue; + } + $fieldname = $fieldlist[$field]; if ($fieldlist[$field] == 'lang') { diff --git a/htdocs/admin/workstation.php b/htdocs/admin/workstation.php index bdd7ba662cd..314e6d13a91 100644 --- a/htdocs/admin/workstation.php +++ b/htdocs/admin/workstation.php @@ -63,11 +63,11 @@ if (!$user->admin) { include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstorder = GETPOST('maskconstWorkstation', 'alpha'); + $maskconst = GETPOST('maskconstWorkstation', 'aZ09'); $maskorder = GETPOST('maskWorkstation', 'alpha'); - if ($maskconstorder) { - $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity); + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { + $res = dolibarr_set_const($db, $maskconst, $maskorder, 'chaine', 0, '', $conf->entity); } if (!($res > 0)) { diff --git a/htdocs/api/class/api_login.class.php b/htdocs/api/class/api_login.class.php index d5362f4ac56..0b8d3e64828 100644 --- a/htdocs/api/class/api_login.class.php +++ b/htdocs/api/class/api_login.class.php @@ -121,6 +121,9 @@ class Login include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; $login = checkLoginPassEntity($login, $password, $entity, $authmode, 'api'); // Check credentials. + if ($login === '--bad-login-validity--') { + $login = ''; + } if (empty($login)) { throw new RestException(403, 'Access denied'); } diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 9dcd168f344..e06cdeb0312 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -319,8 +319,8 @@ class Setup extends DolibarrApi /** * Get state by ID. * - * @param int $id ID of state - * @return array Array of cleaned object properties + * @param int $id ID of state + * @return Object Object with cleaned properties * * @url GET dictionary/states/{id} * @@ -334,8 +334,8 @@ class Setup extends DolibarrApi /** * Get state by Code. * - * @param string $code Code of state - * @return array Array of cleaned object properties + * @param string $code Code of state + * @return Object Object with cleaned properties * * @url GET dictionary/states/byCode/{code} * @@ -424,10 +424,9 @@ class Setup extends DolibarrApi /** * Get country by ID. * - * @param int $id ID of country - * @param string $lang Code of the language the name of the - * country must be translated to - * @return array Array of cleaned object properties + * @param int $id ID of country + * @param string $lang Code of the language the name of the country must be translated to + * @return Object Object with cleaned properties * * @url GET dictionary/countries/{id} * @@ -441,10 +440,9 @@ class Setup extends DolibarrApi /** * Get country by Code. * - * @param string $code Code of country (2 characters) - * @param string $lang Code of the language the name of the - * country must be translated to - * @return array Array of cleaned object properties + * @param string $code Code of country (2 characters) + * @param string $lang Code of the language the name of the country must be translated to + * @return Object Object with cleaned properties * * @url GET dictionary/countries/byCode/{code} * @@ -458,10 +456,9 @@ class Setup extends DolibarrApi /** * Get country by Iso. * - * @param string $iso ISO of country (3 characters) - * @param string $lang Code of the language the name of the - * country must be translated to - * @return array Array of cleaned object properties + * @param string $iso ISO of country (3 characters) + * @param string $lang Code of the language the name of the country must be translated to + * @return Object Object with cleaned properties * * @url GET dictionary/countries/byISO/{iso} * @@ -475,9 +472,9 @@ class Setup extends DolibarrApi /** * Get state. * - * @param int $id ID of state - * @param string $code Code of state - * @return array Array of cleaned object properties + * @param int $id ID of state + * @param string $code Code of state + * @return Object Object with cleaned properties * * @throws RestException */ @@ -498,12 +495,11 @@ class Setup extends DolibarrApi /** * Get country. * - * @param int $id ID of country - * @param string $code Code of country (2 characters) - * @param string $iso ISO of country (3 characters) - * @param string $lang Code of the language the name of the - * country must be translated to - * @return array Array of cleaned object properties + * @param int $id ID of country + * @param string $code Code of country (2 characters) + * @param string $iso ISO of country (3 characters) + * @param string $lang Code of the language the name of the country must be translated to + * @return Object Object with cleaned properties * * @throws RestException */ @@ -527,12 +523,12 @@ class Setup extends DolibarrApi /** * Get the list of delivery times. * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Number of items per page - * @param int $page Page number {@min 0} - * @param int $active Delivery times is active or not {@min 0} {@max 1} - * @param string $sqlfilters SQL criteria to filter with. + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Number of items per page + * @param int $page Page number {@min 0} + * @param int $active Delivery times is active or not {@min 0} {@max 1} + * @param string $sqlfilters SQL criteria to filter with. * * @url GET dictionary/availability * @@ -592,8 +588,8 @@ class Setup extends DolibarrApi /** * Clean sensible object datas * - * @param Object $object Object to clean - * @return Object Object with cleaned properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { @@ -1786,8 +1782,8 @@ class Setup extends DolibarrApi /** * Get establishment by ID. * - * @param int $id ID of establishment - * @return array Array of cleaned object properties + * @param int $id ID of establishment + * @return Object Object with cleaned properties * * @url GET establishments/{id} * @@ -1813,7 +1809,7 @@ class Setup extends DolibarrApi * Note that conf variables that stores security key or password hashes can't be loaded with API. * * @param string $constantname Name of conf variable to get - * @return array|mixed Data without useless information + * @return string Data without useless information * * @url GET conf/{constantname} * @@ -1825,7 +1821,7 @@ class Setup extends DolibarrApi global $conf; if (!DolibarrApiAccess::$user->admin - && (empty($conf->global->API_LOGINS_ALLOWED_FOR_CONST_READ) || DolibarrApiAccess::$user->login != $conf->global->API_LOGINS_ALLOWED_FOR_CONST_READ)) { + && (!getDolGlobalString('API_LOGINS_ALLOWED_FOR_CONST_READ') || DolibarrApiAccess::$user->login != getDolGlobalString('API_LOGINS_ALLOWED_FOR_CONST_READ'))) { throw new RestException(403, 'Error API open to admin users only or to the users with logins defined into constant API_LOGINS_ALLOWED_FOR_CONST_READ'); } @@ -1836,7 +1832,7 @@ class Setup extends DolibarrApi throw new RestException(403, 'Forbidden. This parameter cant be read with APIs'); } - return $conf->global->$constantname; + return getDolGlobalString($constantname); } /** diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 085dd338e69..4e4da2c94cc 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -389,13 +389,13 @@ if (!empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' && $usecompression = (empty($conf->global->API_DISABLE_COMPRESSION) && !empty($_SERVER['HTTP_ACCEPT_ENCODING'])); $foundonealgorithm = 0; if ($usecompression) { - if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'br') !== false && is_callable('brotli_compress')) { + if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'br') !== false && function_exists('brotli_compress')) { $foundonealgorithm++; } - if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'bz') !== false && is_callable('bzcompress')) { + if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'bz') !== false && function_exists('bzcompress')) { $foundonealgorithm++; } - if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && is_callable('gzencode')) { + if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && function_exists('gzencode')) { $foundonealgorithm++; } if (!$foundonealgorithm) { @@ -413,13 +413,13 @@ $result = $api->r->handle(); if (Luracast\Restler\Defaults::$returnResponse) { // We try to compress the data received data - if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'br') !== false && is_callable('brotli_compress')) { + if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'br') !== false && function_exists('brotli_compress') && defined('BROTLI_TEXT')) { header('Content-Encoding: br'); - $result = brotli_compress($result, 11, BROTLI_TEXT); - } elseif (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'bz') !== false && is_callable('bzcompress')) { + $result = brotli_compress($result, 11, constant('BROTLI_TEXT')); + } elseif (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'bz') !== false && function_exists('bzcompress')) { header('Content-Encoding: bz'); $result = bzcompress($result, 9); - } elseif (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && is_callable('gzencode')) { + } elseif (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && function_exists('gzencode')) { header('Content-Encoding: gzip'); $result = gzencode($result, 9); } else { diff --git a/htdocs/asset/admin/setup.php b/htdocs/asset/admin/setup.php index 965566c3a74..1b107746319 100644 --- a/htdocs/asset/admin/setup.php +++ b/htdocs/asset/admin/setup.php @@ -74,7 +74,7 @@ if ($action == 'updateMask') { $maskconst = GETPOST('maskconst', 'alpha'); $mask = GETPOST('mask', 'alpha'); - if ($maskconst) { + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { $res = dolibarr_set_const($db, $maskconst, $mask, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; @@ -473,14 +473,14 @@ if ($action == 'edit') { if ($val['type'] == 'textarea') { print '\n"; } elseif ($val['type']== 'html') { require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; - $doleditor = new DolEditor($constname, $conf->global->{$constname}, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); + $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); $doleditor->Create(); } elseif ($val['type'] == 'yesno') { - print $form->selectyesno($constname, $conf->global->{$constname}, 1); + print $form->selectyesno($constname, getDolGlobalString($constname), 1); } elseif (preg_match('/emailtemplate:/', $val['type'])) { include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $formmail = new FormMail($db); @@ -500,7 +500,7 @@ if ($action == 'edit') { $arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace('/\(|\)/', '', $modelmail->label)) . $moreonlabel; } } - print $form->selectarray($constname, $arrayofmessagename, $conf->global->{$constname}, 'None', 0, 0, '', 0, 0, 0, '', '', 1); + print $form->selectarray($constname, $arrayofmessagename, getDolGlobalString($constname), 'None', 0, 0, '', 0, 0, 0, '', '', 1); } elseif (preg_match('/category:/', $val['type'])) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; @@ -508,11 +508,11 @@ if ($action == 'edit') { $tmp = explode(':', $val['type']); print img_picto('', 'category', 'class="pictofixedwidth"'); - print $formother->select_categories($tmp[1], $conf->global->{$constname}, $constname, 0, $langs->trans('CustomersProspectsCategoriesShort')); + print $formother->select_categories($tmp[1], getDolGlobalString($constname), $constname, 0, $langs->trans('CustomersProspectsCategoriesShort')); } elseif (preg_match('/thirdparty_type/', $val['type'])) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; $formcompany = new FormCompany($db); - print $formcompany->selectProspectCustomerType($conf->global->{$constname}, $constname); + print $formcompany->selectProspectCustomerType(getDolGlobalString($constname), $constname); } elseif ($val['type'] == 'securekey') { print ''; if (!empty($conf->use_javascript_ajax)) { @@ -524,11 +524,11 @@ if ($action == 'edit') { print dolJSToSetRandomPassword($constname, 'generate_token'.$constname); } elseif ($val['type'] == 'product') { if (isModEnabled("product") || isModEnabled("service")) { - $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); + $selected = getDolGlobalString($constname); $form->select_produits($selected, $constname, '', 0); } } elseif ($val['type'] == 'accountancy_code') { - $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); + $selected = getDolGlobalString($constname); if (isModEnabled('accounting')) { require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; $formaccounting = new FormAccounting($db); @@ -537,7 +537,7 @@ if ($action == 'edit') { print ''; } } elseif ($val['type'] == 'accountancy_category') { - $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); + $selected = getDolGlobalString($constname); if (isModEnabled('accounting')) { print ''; // autosuggest from existing account types if found @@ -587,9 +587,9 @@ if ($action == 'edit') { print ''; if ($val['type'] == 'textarea') { - print dol_nl2br($conf->global->{$constname}); + print dol_nl2br(getDolGlobalString($constname)); } elseif ($val['type']== 'html') { - print $conf->global->{$constname}; + print getDolGlobalString($constname); } elseif ($val['type'] == 'yesno') { print ajax_constantonoff($constname); } elseif (preg_match('/emailtemplate:/', $val['type'])) { @@ -598,14 +598,14 @@ if ($action == 'edit') { $tmp = explode(':', $val['type']); - $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, $conf->global->{$constname}); + $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalString($constname)); if ($template<0) { setEventMessages(null, $formmail->errors, 'errors'); } print $langs->trans($template->label); } elseif (preg_match('/category:/', $val['type'])) { $c = new Categorie($db); - $result = $c->fetch($conf->global->{$constname}); + $result = $c->fetch(getDolGlobalInt($constname)); if ($result < 0) { setEventMessages(null, $c->errors, 'errors'); } elseif ($result > 0 ) { @@ -617,18 +617,18 @@ if ($action == 'edit') { print '
    ' . implode(' ', $toprint) . '
'; } } elseif (preg_match('/thirdparty_type/', $val['type'])) { - if ($conf->global->{$constname}==2) { + if (getDolGlobalInt($constname)==2) { print $langs->trans("Prospect"); - } elseif ($conf->global->{$constname}==3) { + } elseif (getDolGlobalInt($constname)==3) { print $langs->trans("ProspectCustomer"); - } elseif ($conf->global->{$constname}==1) { + } elseif (getDolGlobalInt($constname)==1) { print $langs->trans("Customer"); - } elseif ($conf->global->{$constname}==0) { + } elseif (getDolGlobalInt($constname)==0) { print $langs->trans("NorProspectNorCustomer"); } } elseif ($val['type'] == 'product') { $product = new Product($db); - $resprod = $product->fetch($conf->global->{$constname}); + $resprod = $product->fetch(getDolGlobalInt($constname)); if ($resprod > 0) { print $product->ref; } elseif ($resprod < 0) { @@ -638,11 +638,11 @@ if ($action == 'edit') { if (isModEnabled('accounting')) { require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; $accountingaccount = new AccountingAccount($db); - $accountingaccount->fetch('', $conf->global->{$constname}, 1); + $accountingaccount->fetch('', getDolGlobalString($constname), 1); print $accountingaccount->getNomUrl(0, 1, 1, '', 1); } else { - print $conf->global->{$constname}; + print getDolGlobalString($constname); } } else { print $conf->global->{$constname}; diff --git a/htdocs/asset/tpl/linkedobjectblock.tpl.php b/htdocs/asset/tpl/linkedobjectblock.tpl.php index aef30995432..11d94714db8 100644 --- a/htdocs/asset/tpl/linkedobjectblock.tpl.php +++ b/htdocs/asset/tpl/linkedobjectblock.tpl.php @@ -46,12 +46,12 @@ foreach ($linkedObjectBlock as $key => $objectlink) { $trclass .= ' liste_sub_total'; } echo ''; - echo ''.$langs->trans("Asset"); + echo ''.$langs->trans("Asset"); if (!empty($showImportButton) && !empty($conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES)) { print ' '; - echo ''.$objectlink->getNomUrl(1).''; + echo ''.$objectlink->getNomUrl(1).''; echo ''.$objectlink->label.''; echo ''.dol_print_date($objectlink->date_start, 'day').''; echo ''; diff --git a/htdocs/blockedlog/class/authority.class.php b/htdocs/blockedlog/class/authority.class.php index 7240aaf0151..b3dd9b45f47 100644 --- a/htdocs/blockedlog/class/authority.class.php +++ b/htdocs/blockedlog/class/authority.class.php @@ -304,8 +304,8 @@ class BlockedLogAuthority $url = $conf->global->BLOCKEDLOG_AUTHORITY_URL.'/blockedlog/ajax/authority.php?s='.$signature.'&b='.$block->signature; $res = getURLContent($url); - echo $block->signature.' '.$url.' '.$res.'
'; - if ($res === 'blockalreadyadded' || $res === 'blockadded') { + echo $block->signature.' '.$url.' '.$res['content'].'
'; + if ($res['content'] === 'blockalreadyadded' || $res['content'] === 'blockadded') { $block->setCertified(); } else { $this->error = $langs->trans('ImpossibleToContactAuthority ', $url); diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index d07a20774f5..1cb4946715a 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -490,10 +490,10 @@ print ''; print ''; print ''; -$newcardbutton .= ''; -$newcardbutton = dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton = dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/bom/bom_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $user->rights->bom->write); +$newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/bom/bom_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $user->rights->bom->write); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -562,7 +562,7 @@ foreach ($object->fields as $key => $val) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; + print ''; if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100'.($key == 'status' ? ' search_status onrightofpage' : ''), 1); } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) { diff --git a/htdocs/bom/class/api_boms.class.php b/htdocs/bom/class/api_boms.class.php index fb7d175a229..e199650be30 100644 --- a/htdocs/bom/class/api_boms.class.php +++ b/htdocs/bom/class/api_boms.class.php @@ -205,6 +205,9 @@ class Boms extends DolibarrApi foreach ($request_data as $field => $value) { $this->bom->$field = $value; } + + $this->checkRefNumbering(); + if (!$this->bom->create(DolibarrApiAccess::$user)) { throw new RestException(500, "Error creating BOM", array_merge(array($this->bom->error), $this->bom->errors)); } @@ -241,6 +244,8 @@ class Boms extends DolibarrApi $this->bom->$field = $value; } + $this->checkRefNumbering(); + if ($this->bom->update(DolibarrApiAccess::$user) > 0) { return $this->get($id); } else { @@ -536,4 +541,27 @@ class Boms extends DolibarrApi } return $myobject; } + + /** + * Validate the ref field and get the next Number if it's necessary. + * + * @return void + */ + private function checkRefNumbering(): void + { + $ref = substr($this->bom->ref, 1, 4); + if ($this->bom->status > 0 && $ref == 'PROV') { + throw new RestException(400, "Wrong naming scheme '(PROV%)' is only allowed on 'DRAFT' status. For automatic increment use 'auto' on the 'ref' field."); + } + + if (strtolower($this->bom->ref) == 'auto') { + if (empty($this->bom->id) && $this->bom->status == 0) { + $this->bom->ref = ''; // 'ref' will auto incremented with '(PROV' + newID + ')' + } else { + $this->bom->fetch_product(); + $numref = $this->bom->getNextNumRef($this->bom->product); + $this->bom->ref = $numref; + } + } + } } diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index e5d9cc82617..79d2b57ebc8 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1329,7 +1329,7 @@ class BOM extends CommonObject * BOM costs calculation based on cost_price or pmp of each BOM line. * Set the property ->total_cost and ->unit_cost of BOM. * - * @return void + * @return int <0 if KO, >0 if OK */ public function calculateCosts() { @@ -1414,6 +1414,8 @@ class BOM extends CommonObject $this->unit_cost = price2num($this->total_cost * $this->qty, 'MU'); } } + + return 1; } /** diff --git a/htdocs/bom/tpl/linkedobjectblock.tpl.php b/htdocs/bom/tpl/linkedobjectblock.tpl.php index 8a98c078bc5..1765e9a84c1 100644 --- a/htdocs/bom/tpl/linkedobjectblock.tpl.php +++ b/htdocs/bom/tpl/linkedobjectblock.tpl.php @@ -47,12 +47,12 @@ foreach ($linkedObjectBlock as $key => $objectlink) { $trclass .= ' liste_sub_total'; } echo ''; - echo ''.$langs->trans("Bom"); + echo ''.$langs->trans("Bom"); if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { print '
'; - echo ''.$objectlink->getNomUrl(1).''; + echo ''.$objectlink->getNomUrl(1).''; echo ''; $result = $product_static->fetch($objectlink->fk_product); diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index e644c7813e7..96a179b93f3 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -73,7 +73,7 @@ if ($nolinesbefore) { print ''.$langs->trans('Qty').''; if ($filtertype != 1) { - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print ''; print ''; print $langs->trans('Unit'); @@ -145,7 +145,7 @@ print ''; print ''; diff --git a/htdocs/bom/tpl/objectline_edit.tpl.php b/htdocs/bom/tpl/objectline_edit.tpl.php index 88463996ebc..969b210e89b 100644 --- a/htdocs/bom/tpl/objectline_edit.tpl.php +++ b/htdocs/bom/tpl/objectline_edit.tpl.php @@ -126,7 +126,7 @@ if (($line->info_bits & 2) != 2) { print ''; if ($filtertype != 1) { - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $coldisplay++; print ''; print ''; diff --git a/htdocs/bom/tpl/objectline_title.tpl.php b/htdocs/bom/tpl/objectline_title.tpl.php index 5252baf61ca..0ede4190279 100644 --- a/htdocs/bom/tpl/objectline_title.tpl.php +++ b/htdocs/bom/tpl/objectline_title.tpl.php @@ -67,7 +67,7 @@ print ''; print ''.$form->textwithpicto($langs->trans('Qty'), ($filtertype != 1) ? $langs->trans("QtyRequiredIfNoLoss") : '').''; if ($filtertype != 1) { - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print '' . $langs->trans('Unit') . ''; } diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index b7087b27288..d20692ac99a 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -119,7 +119,7 @@ echo price($line->qty, 0, '', 0, 0); // Yes, it is a quantity, not a price, but print ''; if ($filtertype != 1) { - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print ''; $label = $tmpproduct->getLabelOfUnit('long'); if ($label !== '') { diff --git a/htdocs/bookcal/admin/setup.php b/htdocs/bookcal/admin/setup.php index ca9d571ebfe..9772ffbbbf0 100644 --- a/htdocs/bookcal/admin/setup.php +++ b/htdocs/bookcal/admin/setup.php @@ -153,10 +153,10 @@ if ( versioncompare(explode('.', DOL_VERSION), array(15)) < 0 && $action == 'upd include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconst = GETPOST('maskconst', 'alpha'); + $maskconst = GETPOST('maskconst', 'aZ09'); $maskvalue = GETPOST('maskvalue', 'alpha'); - if ($maskconst) { + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; diff --git a/htdocs/bookcal/class/booking.class.php b/htdocs/bookcal/class/booking.class.php index 98cb5077844..1a4f402626b 100644 --- a/htdocs/bookcal/class/booking.class.php +++ b/htdocs/bookcal/class/booking.class.php @@ -104,7 +104,7 @@ class Booking extends CommonObject public $fields=array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>1.2, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'searchall'=>1, 'validate'=>'1', 'comment'=>"Reference of object"), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'picto'=>'company', 'enabled'=>'$conf->societe->enabled', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'help'=>"LinkToThirparty", 'validate'=>'1',), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'picto'=>'company', 'enabled'=>'isModEnabled("societe")', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'help'=>"LinkToThirparty", 'validate'=>'1',), 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'picto'=>'project', 'enabled'=>'$conf->project->enabled', 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'validate'=>'1',), 'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>3, 'validate'=>'1',), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0, 'cssview'=>'wordbreak', 'validate'=>'1',), diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 4c2842b2dcf..4d6e3e1736f 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1189,8 +1189,6 @@ class Categorie extends CommonObject dol_syslog(get_class($this)."::get_full_arbo dol_sort_array", LOG_DEBUG); $this->cats = dol_sort_array($this->cats, 'fulllabel', 'asc', true, false); - //$this->debug_cats(); - return $this->cats; } @@ -1201,7 +1199,7 @@ class Categorie extends CommonObject * * @param int $id_categ id_categ entry to update * @param int $protection Deep counter to avoid infinite loop - * @return void + * @return int <0 if KO, >0 if OK * @see get_full_arbo() */ private function buildPathFromId($id_categ, $protection = 1000) @@ -1211,7 +1209,7 @@ class Categorie extends CommonObject if (!empty($this->cats[$id_categ]['fullpath'])) { // Already defined dol_syslog(get_class($this)."::buildPathFromId fullpath and fulllabel already defined", LOG_WARNING); - return; + return -1; } // First build full array $motherof @@ -1238,28 +1236,7 @@ class Categorie extends CommonObject $nbunderscore = substr_count($this->cats[$id_categ]['fullpath'], '_'); $this->cats[$id_categ]['level'] = ($nbunderscore ? $nbunderscore : null); - return; - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Display content of $this->cats - * - * @return void - */ - public function debug_cats() - { - // phpcs:enable - // Display $this->cats - foreach ($this->cats as $key => $val) { - print 'id: '.$this->cats[$key]['id']; - print ' label: '.$this->cats[$key]['label']; - print ' mother: '.$this->cats[$key]['fk_parent']; - //print ' children: '.(is_array($this->cats[$key]['id_children'])?join(',',$this->cats[$key]['id_children']):''); - print ' fullpath: '.$this->cats[$key]['fullpath']; - print ' fulllabel: '.$this->cats[$key]['fulllabel']; - print "
\n"; - } + return 1; } diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index f0399fa6350..91eb9f49516 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1353,7 +1353,7 @@ if ($action == 'create') { if (empty($donotclearsession)) { $assignedtouser = GETPOST("assignedtouser") ?GETPOST("assignedtouser") : (!empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : $user->id); if ($assignedtouser) { - $listofuserid[$assignedtouser] = array('id'=>$assignedtouser, 'mandatory'=>0, 'transparency'=>$object->transparency); // Owner first + $listofuserid[$assignedtouser] = array('id'=>$assignedtouser, 'mandatory'=>0); // Owner first } //$listofuserid[$user->id] = array('id'=>$user->id, 'mandatory'=>0, 'transparency'=>(GETPOSTISSET('transparency') ? GETPOST('transparency', 'alpha') : 1)); // 1 by default at first init $listofuserid[$assignedtouser]['transparency'] = (GETPOSTISSET('transparency') ? GETPOST('transparency', 'alpha') : 1); // 1 by default at first init @@ -1602,7 +1602,7 @@ if ($action == 'create') { $("#select_actioncommsendmodel_mail").closest("tr").show(); } else { $("#select_actioncommsendmodel_mail").closest("tr").hide(); - }; + } }); })'; print ''."\n"; @@ -2104,7 +2104,7 @@ if ($id > 0) { $("#select_actioncommsendmodel_mail").closest("tr").show(); } else { $("#select_actioncommsendmodel_mail").closest("tr").hide(); - }; + } }); })'; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index efe9374a748..f71c75192ef 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -225,22 +225,22 @@ class ActionComm extends CommonObject public $transparency; /** - * @var int (0 By default) + * @var int (0 By default) */ public $priority; /** - * @var int[] Array of user ids + * @var int[] Array of user ids */ public $userassigned = array(); /** - * @var int Id of user owner = fk_user_action into table + * @var int Id of user owner = fk_user_action into table */ public $userownerid; /** - * @var int Id of user that has done the event. Used only if AGENDA_ENABLE_DONEBY is set. + * @var int Id of user that has done the event. Used only if AGENDA_ENABLE_DONEBY is set. */ public $userdoneid; @@ -429,7 +429,7 @@ class ActionComm extends CommonObject $now = dol_now(); // Check parameters - if (!isset($this->userownerid) || $this->userownerid === '') { // $this->userownerid may be 0 (anonymous event) of > 0 + if (!isset($this->userownerid) || (string) $this->userownerid === '') { // $this->userownerid may be 0 (anonymous event) or > 0 dol_syslog("You tried to create an event but mandatory property ownerid was not defined", LOG_WARNING); $this->errors[] = 'ErrorActionCommPropertyUserowneridNotDefined'; return -1; @@ -477,8 +477,8 @@ class ActionComm extends CommonObject $this->elementtype = 'contract'; } - if (!is_array($this->userassigned) && !empty($this->userassigned)) { // For backward compatibility when userassigned was an int instead fo array - $tmpid = $this->userassigned; + if (!is_array($this->userassigned) && !empty($this->userassigned)) { // For backward compatibility when userassigned was an int instead of an array + $tmpid = (int) $this->userassigned; $this->userassigned = array(); $this->userassigned[$tmpid] = array('id'=>$tmpid, 'transparency'=>$this->transparency); } @@ -1800,8 +1800,8 @@ class ActionComm extends CommonObject * Adds it to non existing supplied categories. * Existing categories are left untouch. * - * @param int[]|int $categories Category or categories IDs - * @return void + * @param int[]|int $categories Category or categories IDs + * @return int <0 if KO, >0 if OK */ public function setCategories($categories) { @@ -1835,7 +1835,7 @@ class ActionComm extends CommonObject $c->add_type($this, Categorie::TYPE_ACTIONCOMM); } } - return; + return 1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/comm/action/class/ical.class.php b/htdocs/comm/action/class/ical.class.php index 7ab09e8d891..26db2cd5e6e 100644 --- a/htdocs/comm/action/class/ical.class.php +++ b/htdocs/comm/action/class/ical.class.php @@ -54,8 +54,8 @@ class ICal /** * Read text file, icalender text file * - * @param string $file File - * @return string + * @param string $file File + * @return string|null Content of remote file read or null if error */ public function read_file($file) { @@ -65,7 +65,7 @@ class ICal $tmpresult = getURLContent($file, 'GET'); if ($tmpresult['http_code'] != 200) { - $file_text = ''; + $file_text = null; $this->error = 'Error: '.$tmpresult['http_code'].' '.$tmpresult['content']; } else { $file_text = preg_replace("/[\r\n]{1,} /", "", $tmpresult['content']); @@ -102,17 +102,40 @@ class ICal /** * Translate Calendar * - * @param string $uri Url + * @param string $uri Url + * @param string $usecachefile Full path of a cache file to use a cache file + * @param string $delaycache Delay in seconds for cache (by default 3600 secondes) * @return array|string */ - public function parse($uri) + public function parse($uri, $usecachefile = '', $delaycache = 3600) { $this->cal = array(); // new empty array $this->event_count = -1; + $this->file_text = null; + + // Save file into a cache + if ($usecachefile) { + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $datefile = dol_filemtime($usecachefile); + $now = dol_now('gmt'); + //print $datefile.' '.$now.' ...'; + if ($datefile && $datefile > ($now - $delaycache)) { + // We reuse the cache file + $this->file_text = file_get_contents($usecachefile); + } + } // read FILE text - $this->file_text = $this->read_file($uri); + if (is_null($this->file_text)) { + $this->file_text = $this->read_file($uri); + + if ($usecachefile && !is_null($this->file_text)) { + // Save the file content into cache file + file_put_contents($usecachefile, $this->file_text, LOCK_EX); + dolChmod($usecachefile); + } + } $this->file_text = preg_split("[\n]", $this->file_text); @@ -402,7 +425,7 @@ class ICal public function get_event_list() { // phpcs:enable - return (empty($this->cal['VEVENT']) ? '' : $this->cal['VEVENT']); + return (empty($this->cal['VEVENT']) ? array() : $this->cal['VEVENT']); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -414,7 +437,7 @@ class ICal public function get_freebusy_list() { // phpcs:enable - return (empty($this->cal['VFREEBUSY']) ? '' : $this->cal['VFREEBUSY']); + return (empty($this->cal['VFREEBUSY']) ? array() : $this->cal['VFREEBUSY']); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 5b51d48392b..8ec011f5e9d 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -49,6 +49,7 @@ if (empty($conf->global->AGENDA_EXT_NB)) { $conf->global->AGENDA_EXT_NB = 5; } $MAXAGENDA = $conf->global->AGENDA_EXT_NB; +$DELAYFORCACHE = 300; // 300 seconds $disabledefaultvalues = GETPOST('disabledefaultvalues', 'int'); @@ -299,6 +300,7 @@ if (empty($user->conf->AGENDA_DISABLE_EXT)) { $enabled = 'AGENDA_EXT_ENABLED_'.$user->id.'_'.$i; $default = 'AGENDA_EXT_ACTIVEBYDEFAULT_'.$user->id.'_'.$i; $buggedfile = 'AGENDA_EXT_BUGGEDFILE_'.$user->id.'_'.$i; + if (getDolUserString($source) && getDolUserString($name)) { // Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight' $listofextcals[] = array( @@ -427,36 +429,33 @@ if ($mode == 'show_day' || $mode == 'show_week' || $mode == 'show_month') { } // Show navigation bar +$nav = ''; +$nav .= '
'; $nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); //$nav .= ' '; @@ -495,7 +494,8 @@ print ''; //print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup, '', $resourceid); //print dol_get_fiche_end(); -$viewmode = ''; +$viewmode = ''; + $viewmode .= ''; // To add a space before the navigation tools @@ -614,7 +616,7 @@ if (!empty($conf->use_javascript_ajax)) { // If javascript on $default = ''; } - $s .= '
 
'; + $s .= '
 
'; } } @@ -1009,9 +1011,13 @@ if ($mode == 'show_day') { // Request only leaves for the current selected day $sql .= " AND '".$db->escape($year)."-".$db->escape($month)."-".$db->escape($day)."' BETWEEN x.date_debut AND x.date_fin"; // date_debut and date_fin are date without time } elseif ($mode == 'show_week') { - // TODO: Add filter to reduce database request + // Restrict on current month (we get more, but we will filter later) + $sql .= " AND date_debut < '".dol_get_last_day($year, $month)."'"; + $sql .= " AND date_fin >= '".dol_get_first_day($year, $month)."'"; } elseif ($mode == 'show_month') { - // TODO: Add filter to reduce database request + // Restrict on current month + $sql .= " AND date_debut <= '".dol_get_last_day($year, $month)."'"; + $sql .= " AND date_fin >= '".dol_get_first_day($year, $month)."'"; } $resql = $db->query($sql); @@ -1082,8 +1088,11 @@ if (count($listofextcals)) { $colorcal = $extcal['color']; $buggedfile = $extcal['buggedfile']; + $pathforcachefile = dol_sanitizePathName($conf->user->dir_temp).'/'.dol_sanitizeFileName('extcal_'.$namecal.'_user'.$user->id).'.cache'; + //var_dump($pathforcachefile);exit; + $ical = new ICal(); - $ical->parse($url); + $ical->parse($url, $pathforcachefile, $DELAYFORCACHE); // After this $ical->cal['VEVENT'] contains array of events, $ical->cal['DAYLIGHT'] contains daylight info, $ical->cal['STANDARD'] contains non daylight info, ... //var_dump($ical->cal); exit; diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 4be3195561e..ab2037d5f76 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -600,7 +600,7 @@ $num = $db->num_rows($resql); $arrayofselected = is_array($toselect) ? $toselect : array(); // Local calendar -$newtitle = '
'; +$newtitle = '
'; $newtitle .= ' '.$langs->trans("LocalAgenda").'   '; $newtitle .= '
'; //$newtitle=$langs->trans($title); @@ -887,6 +887,7 @@ print "\n"; $now = dol_now(); $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; +$today_start_time = dol_mktime(0, 0, 0, date('m', $now), date('d', $now), date('Y', $now)); require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; $caction = new CActionComm($db); @@ -899,6 +900,7 @@ $i = 0; //$savnbfield = $totalarray['nbfield']; //$totalarray['nbfield'] = 0; $imaxinloop = ($limit ? min($num, $limit) : $num); +$cache_user_list = array(); while ($i < $imaxinloop) { $obj = $db->fetch_object($resql); if (empty($obj)) { @@ -933,7 +935,55 @@ while ($i < $imaxinloop) { $actionstatic->fetchResources(); } - print ''; + // cache of user list (owners) + if ($obj->fk_user_action > 0 && !isset($cache_user_list[$obj->fk_user_action])) { + $userstatic = new User($db); + $res = $userstatic->fetch($obj->fk_user_action); + if ($res > 0) { + $cache_user_list[$obj->fk_user_action] = $userstatic; + } + } + + // get event style for user owner + $event_owner_style = ''; + // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) + if ($cache_user_list[$obj->fk_user_action]->color != '') { + $event_owner_style .= 'border-left: #' . $cache_user_list[$obj->fk_user_action]->color . ' 5px solid;'; + } + + // get event style for start and end date + $event_more_class = ''; + $event_start_date_css = ''; + $event_end_date_css = ''; + $event_start_date_time = $actionstatic->datep; + if ($event_start_date_time > $now) { + // future event + $event_more_class = 'event-future'; + $event_start_date_css = $event_end_date_css = $event_more_class; + } else { + if ($obj->fulldayevent == 1) { + $today_start_date_time = $today_start_time; + } else { + $today_start_date_time = $now; + } + + // check event end date + $event_end_date_time = $db->jdate($obj->dp2); + if ($event_end_date_time != null && $event_end_date_time < $today_start_date_time) { + // past event + $event_more_class = 'event-past'; + } elseif ($event_end_date_time == null && $event_start_date_time < $today_start_date_time) { + // past event + $event_more_class = 'event-past'; + } else { + // current event + $event_more_class = 'event-current'; + } + $event_start_date_css = $event_end_date_css = $event_more_class; + } + $event_start_date_css = $event_end_date_css = $event_more_class; + + print ''; // Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print ''; @@ -955,10 +1005,16 @@ while ($i < $imaxinloop) { // User owner if (!empty($arrayfields['owner']['checked'])) { - print ''; // With edge and chrome the td overflow is not supported correctly when content is not full text. - if ($obj->fk_user_action > 0) { - $userstatic->fetch($obj->fk_user_action); - print $userstatic->getNomUrl(-1); + print ''; // With edge and chrome the td overflow is not supported correctly when content is not full text. + if ($obj->fk_user_action > 0 && !isset($cache_user_list[$obj->fk_user_action])) { + $userstatic = new User($db); + $res = $userstatic->fetch($obj->fk_user_action); + if ($res > 0) { + $cache_user_list[$obj->fk_user_action] = $userstatic; + } + } + if (isset($cache_user_list[$obj->fk_user_action])) { + print $cache_user_list[$obj->fk_user_action]->getNomUrl(-1); } else { print ' '; } @@ -1006,13 +1062,14 @@ while ($i < $imaxinloop) { // Start date if (!empty($arrayfields['a.datep']['checked'])) { - print ''; + print ''; if (empty($obj->fulldayevent)) { print dol_print_date($db->jdate($obj->dp), $formatToUse, 'tzuserrel'); } else { $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT'); print dol_print_date($db->jdate($obj->dp), $formatToUse, ($tzforfullday ? $tzforfullday : 'tzuserrel')); } + print ''; $late = 0; if ($actionstatic->hasDelay() && $actionstatic->percentage >= 0 && $actionstatic->percentage < 100 ) { $late = 1; @@ -1025,13 +1082,14 @@ while ($i < $imaxinloop) { // End date if (!empty($arrayfields['a.datep2']['checked'])) { - print ''; + print ''; if (empty($obj->fulldayevent)) { print dol_print_date($db->jdate($obj->dp2), $formatToUse, 'tzuserrel'); } else { $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT'); print dol_print_date($db->jdate($obj->dp2), $formatToUse, ($tzforfullday ? $tzforfullday : 'tzuserrel')); } + print ''; print ''; } diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index ce33d0f40b2..c13de5fb183 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -368,12 +368,15 @@ $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year, 'gmt')); $tmpday = $first_day; $picto = 'calendarweek'; -$nav = "
".img_previous($langs->trans("Previous"))."\n"; +// Show navigation bar +$nav = ''; $nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); $nav .= ' '; diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index bd35fc16e7d..0ee3b6db4a1 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -363,13 +363,16 @@ $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year, 'gmt')); $tmpday = $first_day; $picto = 'calendarweek'; -$nav = "trans("Previous"))."\">   \n"; +// Show navigation bar +$nav = ''; $nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); $nav .= ' '; diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index 735bef1e688..6916a2dfe5d 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -33,6 +33,7 @@ $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $optioncss = GETPOST('optioncss', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index a21e227d822..b8a53aadba6 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -15,6 +15,7 @@ * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2020 Nicolas ZABOURI * Copyright (C) 2022 Gauthier VERDOL + * Copyright (C) 2023 Lenin Rivas * * 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 @@ -938,12 +939,12 @@ if (empty($reshook)) { $prod_entry_mode = GETPOST('prod_entry_mode', 'aZ09'); if ($prod_entry_mode == 'free') { $idprod = 0; - $tva_tx = (GETPOST('tva_tx', 'alpha') ? price2num(preg_replace('/\s*\(.*\)/', '', GETPOST('tva_tx', 'alpha'))) : 0); } else { $idprod = GETPOST('idprod', 'int'); - $tva_tx = ''; } + $tva_tx = GETPOST('tva_tx', 'alpha'); + $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS', 2); $remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef, 'alpha'), '', 2) : 0); if (empty($remise_percent)) { @@ -992,6 +993,8 @@ if (empty($reshook)) { if (!$error && ($qty >= 0) && (!empty($product_desc) || (!empty($idprod) && $idprod > 0))) { $pu_ht = 0; $pu_ttc = 0; + $pu_ht_devise = 0; + $pu_ttc_devise = 0; $price_min = 0; $price_min_ttc = 0; $price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT'); @@ -1002,7 +1005,6 @@ if (empty($reshook)) { // Ecrase $pu par celui du produit // Ecrase $desc par celui du produit - // Ecrase $tva_tx par celui du produit // Replaces $fk_unit with the product unit if (!empty($idprod) && $idprod > 0) { $prod = new Product($db); @@ -1011,11 +1013,11 @@ if (empty($reshook)) { $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : ''); // Update if prices fields are defined - $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); + /*$tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); if (empty($tva_tx)) { $tva_npr = 0; - } + }*/ // Price unique per product $pu_ht = $prod->price; @@ -1056,14 +1058,14 @@ if (empty($reshook)) { $price_min = price($prodcustprice->lines[0]->price_min); $price_min_ttc = price($prodcustprice->lines[0]->price_min_ttc); $price_base_type = $prodcustprice->lines[0]->price_base_type; - $tva_tx = ($prodcustprice->lines[0]->default_vat_code ? $prodcustprice->lines[0]->tva_tx.' ('.$prodcustprice->lines[0]->default_vat_code.' )' : $prodcustprice->lines[0]->tva_tx); + /*$tva_tx = ($prodcustprice->lines[0]->default_vat_code ? $prodcustprice->lines[0]->tva_tx.' ('.$prodcustprice->lines[0]->default_vat_code.' )' : $prodcustprice->lines[0]->tva_tx); if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) { $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; } $tva_npr = $prodcustprice->lines[0]->recuperableonly; if (empty($tva_tx)) { $tva_npr = 0; - } + }*/ } } } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) { @@ -1114,12 +1116,12 @@ if (empty($reshook)) { $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); // Set unit price to use - if (!empty($price_ht) || $price_ht === '0') { + if (!empty($price_ht) || (string) $price_ht === '0') { $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); - } elseif (!empty($price_ttc) || $price_ttc === '0') { + $pu_ttc = price2num($pu_ht * (1 + ((float) $tmpvat / 100)), 'MU'); + } elseif (!empty($price_ttc) || (string) $price_ttc === '0') { $pu_ttc = price2num($price_ttc, 'MU'); - $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); + $pu_ht = price2num($pu_ttc / (1 + ((float) $tmpvat / 100)), 'MU'); } elseif ($tmpvat != $tmpprodvat) { // Is this still used ? if ($price_base_type != 'HT') { @@ -1233,6 +1235,20 @@ if (empty($reshook)) { $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); + // Prepare a price equivalent for minimum price check + $pu_equivalent = $pu_ht; + $pu_equivalent_ttc = $pu_ttc; + $currency_tx = $object->multicurrency_tx; + + // Check if we have a foreing currency + // If so, we update the pu_equiv as the equivalent price in base currency + if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') { + $pu_equivalent = $pu_ht_devise * $currency_tx; + } + if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') { + $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx; + } + // Local Taxes $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $tva_npr); $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $tva_npr); @@ -1246,11 +1262,11 @@ if (empty($reshook)) { //var_dump(price2num($price_min_ttc)); var_dump(price2num($pu_ttc)); var_dump($remise_percent);exit; if ($usermustrespectpricemin) { - if ($pu_ht && $price_min && ((price2num($pu_ht) * (1 - $remise_percent / 100)) < price2num($price_min))) { + if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - $remise_percent / 100)) < price2num($price_min))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; - } elseif ($pu_ttc && $price_min_ttc && ((price2num($pu_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) { + } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; @@ -1349,6 +1365,20 @@ if (empty($reshook)) { $remise_percent = price2num(GETPOST('remise_percent'), '', 2); + // Prepare a price equivalent for minimum price check + $pu_equivalent = $pu_ht; + $pu_equivalent_ttc = $pu_ttc; + $currency_tx = $object->multicurrency_tx; + + // Check if we have a foreing currency + // If so, we update the pu_equiv as the equivalent price in base currency + if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') { + $pu_equivalent = $pu_ht_devise * $currency_tx; + } + if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') { + $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx; + } + // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); $array_options = $extrafields->getOptionalsFromPost($object->table_element_line); @@ -1388,12 +1418,12 @@ if (empty($reshook)) { //var_dump(price2num($price_min_ttc)); var_dump(price2num($pu_ttc)); var_dump($remise_percent);exit; if ($usermustrespectpricemin) { - if ($pu_ht && $price_min && ((price2num($pu_ht) * (1 - $remise_percent / 100)) < price2num($price_min))) { + if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - (float) $remise_percent / 100)) < price2num($price_min))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; $action = 'editline'; - } elseif ($pu_ttc && $price_min_ttc && ((price2num($pu_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) { + } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - (float) $remise_percent / 100)) < price2num($price_min_ttc))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; @@ -1830,7 +1860,7 @@ if ($action == 'create') { } print ''.$langs->trans('SendingMethod').''; print img_picto('', 'object_dollyrevert', 'class="pictofixedwidth"'); - print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx'); + $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx'); print ''; } @@ -1900,7 +1930,7 @@ if ($action == 'create') { print ''; print ''.$langs->trans('NotePublic').''; print ''; - $note_public = $object->getDefaultCreateValueFor('note_public', (!empty($objectsrc) ? $objectsrc->note_public : null)); + $note_public = $object->getDefaultCreateValueFor('note_public', (!empty($objectsrc) ? $objectsrc->note_public : (!empty($conf->global->PROPALE_ADDON_NOTE_PUBLIC_DEFAULT) ? $conf->global->PROPALE_ADDON_NOTE_PUBLIC_DEFAULT : null)), 'restricthtml'); $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); @@ -2776,7 +2806,7 @@ if ($action == 'create') { } if (!empty($object->lines)) { - $ret = $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 1); + $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 1); } // Form to add new line diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index cf675e01b62..5e0e2c31e19 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -49,7 +49,7 @@ class Proposals extends DolibarrApi */ public function __construct() { - global $db, $conf; + global $db; $this->db = $db; $this->propal = new Propal($this->db); } @@ -59,9 +59,9 @@ class Proposals extends DolibarrApi * * Return an array with commercial proposal informations * - * @param int $id ID of commercial proposal - * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id - * @return array|mixed data without useless information + * @param int $id ID of commercial proposal + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return Object Object with cleaned properties * * @throws RestException */ @@ -76,8 +76,8 @@ class Proposals extends DolibarrApi * Return an array with proposal informations * * @param string $ref Ref of object - * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id - * @return array|mixed data without useless information + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return Object Object with cleaned properties * * @url GET ref/{ref} * @@ -93,9 +93,9 @@ class Proposals extends DolibarrApi * * Return an array with proposal informations * - * @param string $ref_ext External reference of object - * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id - * @return array|mixed data without useless information + * @param string $ref_ext External reference of object + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return Object Object with cleaned properties * * @url GET ref_ext/{ref_ext} * @@ -111,11 +111,11 @@ class Proposals extends DolibarrApi * * Return an array with proposal informations * - * @param int $id ID of order - * @param string $ref Ref of object - * @param string $ref_ext External reference of object - * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id - * @return array|mixed data without useless information + * @param int $id ID of order + * @param string $ref Ref of object + * @param string $ref_ext External reference of object + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return Object Object with cleaned properties * * @throws RestException */ @@ -289,7 +289,7 @@ class Proposals extends DolibarrApi * * @url GET {id}/lines * - * @return int + * @return array */ public function getLines($id, $sqlfilters = '') { @@ -461,7 +461,7 @@ class Proposals extends DolibarrApi } if (empty($errors)) { $this->db->commit(); - return count($request_data); + return $updateRes; } else { $this->db->rollback(); throw new RestException(400, implode(", ", $errors)); @@ -471,13 +471,12 @@ class Proposals extends DolibarrApi /** * Update a line of given commercial proposal * - * @param int $id Id of commercial proposal to update - * @param int $lineid Id of line to update - * @param array $request_data Commercial proposal line data + * @param int $id Id of commercial proposal to update + * @param int $lineid Id of line to update + * @param array $request_data Commercial proposal line data + * @return Object|false Object with cleaned properties * * @url PUT {id}/lines/{lineid} - * - * @return object */ public function putLine($id, $lineid, $request_data = null) { @@ -548,13 +547,12 @@ class Proposals extends DolibarrApi * Delete a line of given commercial proposal * * - * @param int $id Id of commercial proposal to update - * @param int $lineid Id of line to delete + * @param int $id Id of commercial proposal to update + * @param int $lineid Id of line to delete + * @return Object|false Object with cleaned properties * * @url DELETE {id}/lines/{lineid} * - * @return int - * * @throws RestException 401 * @throws RestException 404 */ @@ -573,9 +571,7 @@ class Proposals extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - // TODO Check the lineid $lineid is a line of ojbect - - $updateRes = $this->propal->deleteline($lineid); + $updateRes = $this->propal->deleteline($lineid, $id); if ($updateRes > 0) { return $this->get($id); } else { @@ -589,11 +585,10 @@ class Proposals extends DolibarrApi * @param int $id Id of commercial proposal to update * @param int $contactid Id of contact to add * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER) + * @return array * * @url POST {id}/contact/{contactid}/{type} * - * @return int - * * @throws RestException 401 * @throws RestException 404 */ @@ -623,20 +618,24 @@ class Proposals extends DolibarrApi throw new RestException(500, 'Error when added the contact'); } - return $this->propal; + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Contact linked to the proposal' + ) + ); } /** * Delete a contact type of given commercial proposal * - * @param int $id Id of commercial proposal to update - * @param int $contactid Row key of the contact in the array contact_ids. - * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER). + * @param int $id Id of commercial proposal to update + * @param int $contactid Row key of the contact in the array contact_ids. + * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER). + * @return Object Object with cleaned properties * * @url DELETE {id}/contact/{contactid}/{type} * - * @return int - * * @throws RestException 401 * @throws RestException 404 * @throws RestException 500 System error @@ -675,10 +674,9 @@ class Proposals extends DolibarrApi /** * Update commercial proposal general fields (won't touch lines of commercial proposal) * - * @param int $id Id of commercial proposal to update - * @param array $request_data Datas - * - * @return int + * @param int $id Id of commercial proposal to update + * @param array $request_data Datas + * @return Object Object with cleaned properties */ public function put($id, $request_data = null) { @@ -722,7 +720,6 @@ class Proposals extends DolibarrApi * Delete commercial proposal * * @param int $id Commercial proposal ID - * * @return array */ public function delete($id) @@ -755,10 +752,9 @@ class Proposals extends DolibarrApi * Set a proposal to draft * * @param int $id Order ID + * @return Object Object with cleaned properties * * @url POST {id}/settodraft - * - * @return array */ public function settodraft($id) { @@ -807,6 +803,7 @@ class Proposals extends DolibarrApi * * @param int $id Commercial proposal ID * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return Object Object with cleaned properties * * @url POST {id}/validate * @@ -814,8 +811,6 @@ class Proposals extends DolibarrApi * @throws RestException 401 * @throws RestException 404 * @throws RestException 500 System error - * - * @return array */ public function validate($id, $notrigger = 0) { @@ -860,10 +855,9 @@ class Proposals extends DolibarrApi * @param int $status Must be 2 (accepted) or 3 (refused) {@min 2}{@max 3} * @param string $note_private Add this mention at end of private note * @param int $notrigger Disabled triggers + * @return Object Object with cleaned properties * * @url POST {id}/close - * - * @return array */ public function close($id, $status, $note_private = '', $notrigger = 0) { @@ -905,10 +899,9 @@ class Proposals extends DolibarrApi * Set a commercial proposal billed. Could be also called setbilled * * @param int $id Commercial proposal ID + * @return Object Object with cleaned properties * * @url POST {id}/setinvoiced - * - * @return array */ public function setinvoiced($id) { @@ -949,6 +942,7 @@ class Proposals extends DolibarrApi * * @param array $data Array with data to verify * @return array + * * @throws RestException */ private function _validate($data) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index a5fd221de87..150e2c99b66 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -301,7 +301,7 @@ 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'=>'$conf->societe->enabled', 'visible'=>-1, 'position'=>23), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'isModEnabled("societe")', 'visible'=>-1, 'position'=>23), 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Fk projet', 'enabled'=>"isModEnabled('project')", '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), @@ -454,6 +454,8 @@ class Propal extends CommonObject $this->lines[] = $line; } + + return 1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -981,9 +983,10 @@ class Propal extends CommonObject * Delete detail line * * @param int $lineid Id of line to delete + * @param int $id Id of object (for a check) * @return int >0 if OK, <0 if KO */ - public function deleteline($lineid) + public function deleteline($lineid, $id = 0) { global $user; @@ -992,9 +995,20 @@ class Propal extends CommonObject $line = new PropaleLigne($this->db); - // For triggers + $line->context = $this->context; + + // Load data $line->fetch($lineid); + if ($id > 0 && $line->fk_propal != $id) { + $this->error = 'ErrorLineIDDoesNotMatchWithObjectID'; + return -1; + } + + // Memorize previous line for triggers + $staticline = clone $line; + $line->oldline = $staticline; + if ($line->delete($user) > 0) { $this->update_price(1); @@ -2108,6 +2122,8 @@ class Propal extends CommonObject return -1 * $error; } } + + return -1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -2164,6 +2180,8 @@ class Propal extends CommonObject return -1 * $error; } } + + return -1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -2235,6 +2253,8 @@ class Propal extends CommonObject return -1 * $error; } } + + return -1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -2417,9 +2437,9 @@ class Propal extends CommonObject $this->db->rollback(); return -1 * $error; } - } else { - return -1; } + + return -1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -2480,6 +2500,8 @@ class Propal extends CommonObject return -1 * $error; } } + + return -1; } @@ -2542,6 +2564,8 @@ class Propal extends CommonObject return -1 * $error; } } + + return -1; } @@ -2879,7 +2903,7 @@ class Propal extends CommonObject * @param int $offset For pagination * @param string $sortfield Sort criteria * @param string $sortorder Sort order - * @return int -1 if KO, array with result if OK + * @return array|int -1 if KO, array with result if OK */ public function liste_array($shortlist = 0, $draft = 0, $notcurrentuser = 0, $socid = 0, $limit = 0, $offset = 0, $sortfield = 'p.datep', $sortorder = 'DESC') { @@ -2958,8 +2982,8 @@ class Propal extends CommonObject /** * Returns an array with id and ref of related invoices * - * @param int $id Id propal - * @return array Array of invoices id + * @param int $id Id propal + * @return array|int Array of invoices id */ public function InvoiceArrayList($id) { @@ -3890,6 +3914,41 @@ class Propal extends CommonObject return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables); } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + global $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + //$return .= ''; // Can be image + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + if (property_exists($this, 'fk_project')) { + $return .= ' | '.$this->fk_project.''; + } + if (property_exists($this, 'author')) { + $return .= '
'.$this->author.''; + } + if (property_exists($this, 'total_ht')) { + $return .='
'.$langs->trans("AmountHT").' : '.price($this->total_ht).''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } /** diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 2426abad9f4..cc5872abb25 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -70,6 +70,7 @@ $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'proposallist'; +$mode = GETPOST('mode', 'alpha'); $search_user = GETPOST('search_user', 'int'); $search_sale = GETPOST('search_sale', 'int'); @@ -306,7 +307,7 @@ if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massa $massaction = ''; } -$parameters = array('socid'=>$socid); +$parameters = array('socid'=>$socid, 'arrayfields'=>&$arrayfields); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -864,6 +865,9 @@ if ($resql) { } $param = '&search_status='.urlencode($search_status); + if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); + } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -1072,6 +1076,9 @@ if ($resql) { if (!empty($socid)) { $url .= '&socid='.$socid; } + $newcardbutton = ''; + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); $newcardbutton = dolGetButtonTitle($langs->trans('NewPropal'), '', 'fa fa-plus-circle', $url, '', $user->rights->propal->creer); // Fields title search @@ -1085,6 +1092,7 @@ if ($resql) { print ''; print ''; print ''; + print ''; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'propal', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -1386,8 +1394,8 @@ if ($resql) { } if (!empty($arrayfields['u.login']['checked'])) { // Author - print ''; - print ''; + print ''; + print ''; print ''; } if (!empty($arrayfields['sale_representative']['checked'])) { @@ -1443,8 +1451,8 @@ if ($resql) { } // Status if (!empty($arrayfields['p.fk_statut']['checked'])) { - print ''; - $formpropal->selectProposalStatus($search_status, 1, 0, 1, 'customer', 'search_statut', 'search_status maxwidth125 onrightofpage'); + print ''; + $formpropal->selectProposalStatus($search_status, 1, 0, 1, 'customer', 'search_statut', 'search_status width100 onrightofpage'); print ''; } // Action column @@ -1702,574 +1710,590 @@ if ($resql) { $total_margin += $marginInfo['total_margin']; } - print ''; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + print '
'; + } + // Output Kanban + $userstatic->fetch($obj->fk_user_author); + $objectstatic->author = $userstatic->getNomUrl(1); + $objectstatic->fk_project = $projectstatic->getNomUrl(1); + print $objectstatic->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print '
'; + print ''; + } + } else { + print ''; - // Action column - if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; } - print ''; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - if (!empty($arrayfields['p.ref']['checked'])) { - print ''; - - print ''; - // Picto + Ref - print ''; - // Warning - $warnornote = ''; - if ($obj->status == Propal::STATUS_VALIDATED && $db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) { - $warnornote .= img_warning($langs->trans("Late")); - } - if ($warnornote) { - print ''; - } - // Other picto tool - print '
'; - print $objectstatic->getNomUrl(1, '', '', 0, 1, (isset($conf->global->PROPAL_LIST_SHOW_NOTES) ? $conf->global->PROPAL_LIST_SHOW_NOTES : 1)); - print ''; - print $warnornote; print ''; - $filename = dol_sanitizeFileName($obj->ref); - $filedir = $conf->propal->multidir_output[$obj->propal_entity].'/'.dol_sanitizeFileName($obj->ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; - print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); - print '
'; - - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - if (!empty($arrayfields['p.ref_client']['checked'])) { - // Customer ref - print ''; - print dol_escape_htmltag($obj->ref_client); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - if (!empty($arrayfields['pr.ref']['checked'])) { - // Project ref - print ''; - if ($obj->project_id > 0) { - print $projectstatic->getNomUrl(1); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - if (!empty($arrayfields['pr.title']['checked'])) { - // Project label - print ''; - if ($obj->project_id > 0) { - print dol_escape_htmltag($projectstatic->title); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Thirdparty - if (!empty($arrayfields['s.nom']['checked'])) { - print ''; - print $companystatic->getNomUrl(1, 'customer', 0, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Alias - if (!empty($arrayfields['s.name_alias']['checked'])) { - print ''; - print $obj->alias; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Town - if (!empty($arrayfields['s.town']['checked'])) { - print ''; - print $obj->town; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Zip - if (!empty($arrayfields['s.zip']['checked'])) { - print ''; - print $obj->zip; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // State - if (!empty($arrayfields['state.nom']['checked'])) { - print "".$obj->state_name."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Country - if (!empty($arrayfields['country.code_iso']['checked'])) { - print ''; - $tmparray = getCountry($obj->fk_pays, 'all'); - print $tmparray['label']; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Type ent - if (!empty($arrayfields['typent.code']['checked'])) { - if (!is_array($typenArray) || empty($typenArray)) { - $typenArray = $formcompany->typent_array(1); - } - - print ''; - print $typenArray[$obj->typent_code]; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Date proposal - if (!empty($arrayfields['p.date']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->dp), 'day'); - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Date end validity - if (!empty($arrayfields['p.fin_validite']['checked'])) { - if ($obj->dfv) { - print ''.dol_print_date($db->jdate($obj->dfv), 'day'); - print ''; - } else { - print ' '; - } - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date delivery - if (!empty($arrayfields['p.date_livraison']['checked'])) { - if ($obj->ddelivery) { - print ''.dol_print_date($db->jdate($obj->ddelivery), 'day'); - print ''; - } else { - print ' '; - } - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date Signature - if (!empty($arrayfields['p.date_signature']['checked'])) { - if ($obj->dsignature) { - print ''.dol_print_date($db->jdate($obj->dsignature), 'day'); - print ''; - } else { - print ' '; - } - if (!$i) { - $totalarray['nbfield']++; - } - } - // Availability - if (!empty($arrayfields['ava.rowid']['checked'])) { - print ''; - $form->form_availability('', $obj->availability, 'none', 1); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Shipping Method - if (!empty($arrayfields['p.fk_shipping_method']['checked'])) { - print ''; - $form->formSelectShippingMethod('', $obj->fk_shipping_method, 'none', 1); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Source - input reason - if (!empty($arrayfields['p.fk_input_reason']['checked'])) { - print ''; - if ($obj->fk_input_reason > 0) { - print $form->cache_demand_reason[$obj->fk_input_reason]['label']; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Payment terms - if (!empty($arrayfields['p.fk_cond_reglement']['checked'])) { - print ''; - $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 0, '', 1, $obj->deposit_percent); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Payment mode - if (!empty($arrayfields['p.fk_mode_reglement']['checked'])) { - print ''; - $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount HT - if (!empty($arrayfields['p.total_ht']['checked'])) { - print ''.price($obj->total_ht)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ht'; - } - if (empty($totalarray['val']['p.total_ht'])) { - $totalarray['val']['p.total_ht'] = $obj->total_ht; - } else { - $totalarray['val']['p.total_ht'] += $obj->total_ht; - } - } - // Amount VAT - if (!empty($arrayfields['p.total_tva']['checked'])) { - print ''.price($obj->total_tva)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'p.total_tva'; - } - if (empty($totalarray['val']['p.total_tva'])) { - $totalarray['val']['p.total_tva'] = $obj->total_tva; - } else { - $totalarray['val']['p.total_tva'] += $obj->total_tva; - } - } - // Amount TTC - if (!empty($arrayfields['p.total_ttc']['checked'])) { - print ''.price($obj->total_ttc)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ttc'; - } - if (empty($totalarray['val']['p.total_ttc'])) { - $totalarray['val']['p.total_ttc'] = $obj->total_ttc; - } else { - $totalarray['val']['p.total_ttc'] += $obj->total_ttc; - } - } - // Amount invoiced HT - if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) { - print ''.price($totalInvoicedHT)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ht_invoiced'; - } - if (empty($totalarray['val']['p.total_ht_invoiced'])) { - $totalarray['val']['p.total_ht_invoiced'] = $totalInvoicedHT; - } else { - $totalarray['val']['p.total_ht_invoiced'] += $totalInvoicedHT; - } - } - // Amount invoiced TTC - if (!empty($arrayfields['p.total_invoiced']['checked'])) { - print ''.price($totalInvoicedTTC)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'p.total_invoiced'; - } - if (empty($totalarray['val']['p.total_invoiced'])) { - $totalarray['val']['p.total_invoiced'] = $totalInvoicedTTC; - } else { - $totalarray['val']['p.total_invoiced'] += $totalInvoicedTTC; - } - } - // Currency - if (!empty($arrayfields['p.multicurrency_code']['checked'])) { - print ''.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Currency rate - if (!empty($arrayfields['p.multicurrency_tx']['checked'])) { - print ''; - $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount HT - if (!empty($arrayfields['p.multicurrency_total_ht']['checked'])) { - print ''.price($obj->multicurrency_total_ht)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount VAT - if (!empty($arrayfields['p.multicurrency_total_tva']['checked'])) { - print ''.price($obj->multicurrency_total_tva)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount TTC - if (!empty($arrayfields['p.multicurrency_total_ttc']['checked'])) { - print ''.price($obj->multicurrency_total_ttc)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount invoiced - if (!empty($arrayfields['p.multicurrency_total_ht_invoiced']['checked'])) { - print ''.price($multicurrency_totalInvoicedHT)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount invoiced - if (!empty($arrayfields['p.multicurrency_total_invoiced']['checked'])) { - print ''.price($multicurrency_totalInvoicedTTC)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - $userstatic->id = $obj->fk_user_author; - $userstatic->login = $obj->login; - $userstatic->lastname = $obj->lastname; - $userstatic->firstname = $obj->firstname; - $userstatic->email = $obj->user_email; - $userstatic->statut = $obj->user_statut; - $userstatic->entity = $obj->user_entity; - $userstatic->photo = $obj->photo; - $userstatic->office_phone = $obj->office_phone; - $userstatic->office_fax = $obj->office_fax; - $userstatic->user_mobile = $obj->user_mobile; - $userstatic->job = $obj->job; - $userstatic->gender = $obj->gender; - - // Author - if (!empty($arrayfields['u.login']['checked'])) { - print ''; - if ($userstatic->id) { - print $userstatic->getNomUrl(-1); - } - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - if (!empty($arrayfields['sale_representative']['checked'])) { - // Sales representatives - print ''; - if ($obj->socid > 0) { - $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user); - if ($listsalesrepresentatives < 0) { - dol_print_error($db); + if (!$i) { + $totalarray['nbfield']++; } - $nbofsalesrepresentative = count($listsalesrepresentatives); - if ($nbofsalesrepresentative > 6) { - // We print only number - print $nbofsalesrepresentative; - } elseif ($nbofsalesrepresentative > 0) { - $userstatic = new User($db); - $j = 0; - foreach ($listsalesrepresentatives as $val) { - $userstatic->id = $val['id']; - $userstatic->lastname = $val['lastname']; - $userstatic->firstname = $val['firstname']; - $userstatic->email = $val['email']; - $userstatic->statut = $val['statut']; - $userstatic->entity = $val['entity']; - $userstatic->photo = $val['photo']; - $userstatic->login = $val['login']; - $userstatic->office_phone = $val['office_phone']; - $userstatic->office_fax = $val['office_fax']; - $userstatic->user_mobile = $val['user_mobile']; - $userstatic->job = $val['job']; - $userstatic->gender = $val['gender']; - //print '
': - print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2); - $j++; - if ($j < $nbofsalesrepresentative) { - print ' '; + } + + if (!empty($arrayfields['p.ref']['checked'])) { + print ''; + + print ''; + // Picto + Ref + print ''; + // Warning + $warnornote = ''; + if ($obj->status == Propal::STATUS_VALIDATED && $db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) { + $warnornote .= img_warning($langs->trans("Late")); + } + if ($warnornote) { + print ''; + } + // Other picto tool + print '
'; + print $objectstatic->getNomUrl(1, '', '', 0, 1, (isset($conf->global->PROPAL_LIST_SHOW_NOTES) ? $conf->global->PROPAL_LIST_SHOW_NOTES : 1)); + print ''; + print $warnornote; + print ''; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->propal->multidir_output[$obj->propal_entity].'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; + print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + print '
'; + + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + if (!empty($arrayfields['p.ref_client']['checked'])) { + // Customer ref + print ''; + print dol_escape_htmltag($obj->ref_client); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + if (!empty($arrayfields['pr.ref']['checked'])) { + // Project ref + print ''; + if ($obj->project_id > 0) { + print $projectstatic->getNomUrl(1); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + if (!empty($arrayfields['pr.title']['checked'])) { + // Project label + print ''; + if ($obj->project_id > 0) { + print dol_escape_htmltag($projectstatic->title); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Thirdparty + if (!empty($arrayfields['s.nom']['checked'])) { + print ''; + print $companystatic->getNomUrl(1, 'customer', 0, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Alias + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + print $obj->alias; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Town + if (!empty($arrayfields['s.town']['checked'])) { + print ''; + print $obj->town; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Zip + if (!empty($arrayfields['s.zip']['checked'])) { + print ''; + print $obj->zip; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // State + if (!empty($arrayfields['state.nom']['checked'])) { + print "".$obj->state_name."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) { + print ''; + $tmparray = getCountry($obj->fk_pays, 'all'); + print $tmparray['label']; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Type ent + if (!empty($arrayfields['typent.code']['checked'])) { + if (!is_array($typenArray) || empty($typenArray)) { + $typenArray = $formcompany->typent_array(1); + } + + print ''; + print $typenArray[$obj->typent_code]; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date proposal + if (!empty($arrayfields['p.date']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->dp), 'day'); + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date end validity + if (!empty($arrayfields['p.fin_validite']['checked'])) { + if ($obj->dfv) { + print ''.dol_print_date($db->jdate($obj->dfv), 'day'); + print ''; + } else { + print ' '; + } + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date delivery + if (!empty($arrayfields['p.date_livraison']['checked'])) { + if ($obj->ddelivery) { + print ''.dol_print_date($db->jdate($obj->ddelivery), 'day'); + print ''; + } else { + print ' '; + } + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date Signature + if (!empty($arrayfields['p.date_signature']['checked'])) { + if ($obj->dsignature) { + print ''.dol_print_date($db->jdate($obj->dsignature), 'day'); + print ''; + } else { + print ' '; + } + if (!$i) { + $totalarray['nbfield']++; + } + } + // Availability + if (!empty($arrayfields['ava.rowid']['checked'])) { + print ''; + $form->form_availability('', $obj->availability, 'none', 1); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Shipping Method + if (!empty($arrayfields['p.fk_shipping_method']['checked'])) { + print ''; + $form->formSelectShippingMethod('', $obj->fk_shipping_method, 'none', 1); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Source - input reason + if (!empty($arrayfields['p.fk_input_reason']['checked'])) { + print ''; + if ($obj->fk_input_reason > 0) { + print $form->cache_demand_reason[$obj->fk_input_reason]['label']; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Payment terms + if (!empty($arrayfields['p.fk_cond_reglement']['checked'])) { + print ''; + $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 0, '', 1, $obj->deposit_percent); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Payment mode + if (!empty($arrayfields['p.fk_mode_reglement']['checked'])) { + print ''; + $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount HT + if (!empty($arrayfields['p.total_ht']['checked'])) { + print ''.price($obj->total_ht)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ht'; + } + if (empty($totalarray['val']['p.total_ht'])) { + $totalarray['val']['p.total_ht'] = $obj->total_ht; + } else { + $totalarray['val']['p.total_ht'] += $obj->total_ht; + } + } + // Amount VAT + if (!empty($arrayfields['p.total_tva']['checked'])) { + print ''.price($obj->total_tva)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'p.total_tva'; + } + if (empty($totalarray['val']['p.total_tva'])) { + $totalarray['val']['p.total_tva'] = $obj->total_tva; + } else { + $totalarray['val']['p.total_tva'] += $obj->total_tva; + } + } + // Amount TTC + if (!empty($arrayfields['p.total_ttc']['checked'])) { + print ''.price($obj->total_ttc)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ttc'; + } + if (empty($totalarray['val']['p.total_ttc'])) { + $totalarray['val']['p.total_ttc'] = $obj->total_ttc; + } else { + $totalarray['val']['p.total_ttc'] += $obj->total_ttc; + } + } + // Amount invoiced HT + if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) { + print ''.price($totalInvoicedHT)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ht_invoiced'; + } + if (empty($totalarray['val']['p.total_ht_invoiced'])) { + $totalarray['val']['p.total_ht_invoiced'] = $totalInvoicedHT; + } else { + $totalarray['val']['p.total_ht_invoiced'] += $totalInvoicedHT; + } + } + // Amount invoiced TTC + if (!empty($arrayfields['p.total_invoiced']['checked'])) { + print ''.price($totalInvoicedTTC)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'p.total_invoiced'; + } + if (empty($totalarray['val']['p.total_invoiced'])) { + $totalarray['val']['p.total_invoiced'] = $totalInvoicedTTC; + } else { + $totalarray['val']['p.total_invoiced'] += $totalInvoicedTTC; + } + } + // Currency + if (!empty($arrayfields['p.multicurrency_code']['checked'])) { + print ''.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Currency rate + if (!empty($arrayfields['p.multicurrency_tx']['checked'])) { + print ''; + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount HT + if (!empty($arrayfields['p.multicurrency_total_ht']['checked'])) { + print ''.price($obj->multicurrency_total_ht)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount VAT + if (!empty($arrayfields['p.multicurrency_total_tva']['checked'])) { + print ''.price($obj->multicurrency_total_tva)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount TTC + if (!empty($arrayfields['p.multicurrency_total_ttc']['checked'])) { + print ''.price($obj->multicurrency_total_ttc)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount invoiced + if (!empty($arrayfields['p.multicurrency_total_ht_invoiced']['checked'])) { + print ''.price($multicurrency_totalInvoicedHT)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount invoiced + if (!empty($arrayfields['p.multicurrency_total_invoiced']['checked'])) { + print ''.price($multicurrency_totalInvoicedTTC)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + $userstatic->id = $obj->fk_user_author; + $userstatic->login = $obj->login; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; + $userstatic->email = $obj->user_email; + $userstatic->statut = $obj->user_statut; + $userstatic->entity = $obj->user_entity; + $userstatic->photo = $obj->photo; + $userstatic->office_phone = $obj->office_phone; + $userstatic->office_fax = $obj->office_fax; + $userstatic->user_mobile = $obj->user_mobile; + $userstatic->job = $obj->job; + $userstatic->gender = $obj->gender; + + // Author + if (!empty($arrayfields['u.login']['checked'])) { + print ''; + if ($userstatic->id) { + print $userstatic->getNomUrl(-1); + } + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + if (!empty($arrayfields['sale_representative']['checked'])) { + // Sales representatives + print ''; + if ($obj->socid > 0) { + $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user); + if ($listsalesrepresentatives < 0) { + dol_print_error($db); + } + $nbofsalesrepresentative = count($listsalesrepresentatives); + if ($nbofsalesrepresentative > 6) { + // We print only number + print $nbofsalesrepresentative; + } elseif ($nbofsalesrepresentative > 0) { + $userstatic = new User($db); + $j = 0; + foreach ($listsalesrepresentatives as $val) { + $userstatic->id = $val['id']; + $userstatic->lastname = $val['lastname']; + $userstatic->firstname = $val['firstname']; + $userstatic->email = $val['email']; + $userstatic->statut = $val['statut']; + $userstatic->entity = $val['entity']; + $userstatic->photo = $val['photo']; + $userstatic->login = $val['login']; + $userstatic->office_phone = $val['office_phone']; + $userstatic->office_fax = $val['office_fax']; + $userstatic->user_mobile = $val['user_mobile']; + $userstatic->job = $val['job']; + $userstatic->gender = $val['gender']; + //print '
': + print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2); + $j++; + if ($j < $nbofsalesrepresentative) { + print ' '; + } + //print '
'; } - //print '
'; + } + //else print $langs->trans("NoSalesRepresentativeAffected"); + } else { + print ' '; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Total buying or cost price + if (!empty($arrayfields['total_pa']['checked'])) { + print ''.price($marginInfo['pa_total']).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Total margin + if (!empty($arrayfields['total_margin']['checked'])) { + print ''.price($marginInfo['total_margin']).''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'total_margin'; + } + $totalarray['val']['total_margin'] = $total_margin; + } + // Total margin rate + if (!empty($arrayfields['total_margin_rate']['checked'])) { + print ''.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Total mark rate + if (!empty($arrayfields['total_mark_rate']['checked'])) { + print ''.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate'; + } + if ($i >= $imaxinloop - 1) { + if (!empty($total_ht)) { + $totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT'); + } else { + $totalarray['val']['total_mark_rate'] = ''; } } - //else print $langs->trans("NoSalesRepresentativeAffected"); - } else { - print ' '; } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Total buying or cost price - if (!empty($arrayfields['total_pa']['checked'])) { - print ''.price($marginInfo['pa_total']).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Total margin - if (!empty($arrayfields['total_margin']['checked'])) { - print ''.price($marginInfo['total_margin']).''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'total_margin'; - } - $totalarray['val']['total_margin'] = $total_margin; - } - // Total margin rate - if (!empty($arrayfields['total_margin_rate']['checked'])) { - print ''.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Total mark rate - if (!empty($arrayfields['total_mark_rate']['checked'])) { - print ''.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate'; - } - if ($i >= $imaxinloop - 1) { - if (!empty($total_ht)) { - $totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT'); - } else { - $totalarray['val']['total_mark_rate'] = ''; + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['p.datec']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; } } - } - - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['p.datec']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['p.tms']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date cloture - if (!empty($arrayfields['p.date_cloture']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Note public - if (!empty($arrayfields['p.note_public']['checked'])) { - print ''; - print dol_string_nohtmltag($obj->note_public); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Note private - if (!empty($arrayfields['p.note_private']['checked'])) { - print ''; - print dol_string_nohtmltag($obj->note_private); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Status - if (!empty($arrayfields['p.fk_statut']['checked'])) { - print ''.$objectstatic->getLibStatut(5).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Action column - if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; + // Date modification + if (!empty($arrayfields['p.tms']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; } - print ''; } - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Date cloture + if (!empty($arrayfields['p.date_cloture']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } + // Note public + if (!empty($arrayfields['p.note_public']['checked'])) { + print ''; + print dol_string_nohtmltag($obj->note_public); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Note private + if (!empty($arrayfields['p.note_private']['checked'])) { + print ''; + print dol_string_nohtmltag($obj->note_private); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Status + if (!empty($arrayfields['p.fk_statut']['checked'])) { + print ''.$objectstatic->getLibStatut(5).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Action column + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + + print ''."\n"; } - - print ''."\n"; - $i++; } diff --git a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php index 37c0f8d5e58..8aa72d9c43f 100644 --- a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php +++ b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php @@ -52,13 +52,13 @@ foreach ($linkedObjectBlock as $key => $objectlink) { $trclass .= ' liste_sub_total'; } print ''; - print ''.$langs->trans("Proposal"); + print ''.$langs->trans("Proposal"); if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { $url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$objectlink->id; print ' '; } print ''; - print ''.$objectlink->getNomUrl(1).''; + print ''.$objectlink->getNomUrl(1).''; print ''.$objectlink->ref_client.''; print ''.dol_print_date($objectlink->date, 'day').''; print ''; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 383cf7581e9..c2ab4fcd3bc 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -676,13 +676,28 @@ if (empty($reshook)) { $prod_entry_mode = GETPOST('prod_entry_mode', 'aZ09'); if ($prod_entry_mode == 'free') { $idprod = 0; - $tva_tx = (GETPOST('tva_tx', 'alpha') ? price2num(preg_replace('/\s*\(.*\)/', '', GETPOST('tva_tx', 'alpha'))) : 0); } else { $idprod = GETPOST('idprod', 'int'); - $tva_tx = ''; + } + + $tva_tx = GETPOST('tva_tx', 'alpha'); + + // Prepare a price equivalent for minimum price check + $pu_equivalent = $pu_ht; + $pu_equivalent_ttc = $pu_ttc; + $currency_tx = $object->multicurrency_tx; + + // Check if we have a foreing currency + // If so, we update the pu_equiv as the equivalent price in base currency + if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') { + $pu_equivalent = $pu_ht_devise * $currency_tx; + } + if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') { + $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx; } $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS', 2); + $remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef, 'alpha'), '', 2) : 0); if (empty($remise_percent)) { $remise_percent = 0; @@ -746,7 +761,6 @@ if (empty($reshook)) { // Ecrase $pu par celui du produit // Ecrase $desc par celui du produit - // Ecrase $tva_tx par celui du produit // Ecrase $base_price_type par celui du produit if (!empty($idprod) && $idprod > 0) { $prod = new Product($db); @@ -755,11 +769,11 @@ if (empty($reshook)) { $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : ''); // Update if prices fields are defined - $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); + /*$tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); if (empty($tva_tx)) { $tva_npr = 0; - } + }*/ $pu_ht = $prod->price; $pu_ttc = $prod->price_ttc; @@ -985,11 +999,11 @@ if (empty($reshook)) { $desc = dol_htmlcleanlastbr($desc); if ($usermustrespectpricemin) { - if ($pu_ht && $price_min && ((price2num($pu_ht) * (1 - $remise_percent / 100)) < price2num($price_min))) { + if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - $remise_percent / 100)) < price2num($price_min))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; - } elseif ($pu_ttc && $price_min_ttc && ((price2num($pu_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) { + } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; @@ -1075,6 +1089,20 @@ if (empty($reshook)) { $qty = price2num(GETPOST('qty', 'alpha'), 'MS'); + // Prepare a price equivalent for minimum price check + $pu_equivalent = $pu_ht; + $pu_equivalent_ttc = $pu_ttc; + $currency_tx = $object->multicurrency_tx; + + // Check if we have a foreing currency + // If so, we update the pu_equiv as the equivalent price in base currency + if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') { + $pu_equivalent = $pu_ht_devise * $currency_tx; + } + if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') { + $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx; + } + // Define info_bits $info_bits = 0; if (preg_match('/\*/', $vat_rate)) { @@ -1106,7 +1134,7 @@ if (empty($reshook)) { $special_code = 3; } - $remise_percent = price2num(GETPOST('remise_percent'), '', 2); + $remise_percent = GETPOST('remise_percent') != '' ? price2num(GETPOST('remise_percent'), '', 2) : 0; // Check minimum price $productid = GETPOST('productid', 'int'); @@ -1128,12 +1156,12 @@ if (empty($reshook)) { $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); if ($usermustrespectpricemin) { - if ($pu_ht && $price_min && ((price2num($pu_ht) * (1 - $remise_percent / 100)) < price2num($price_min))) { + if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - $remise_percent / 100)) < price2num($price_min))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; $action = 'editline'; - } elseif ($pu_ttc && $price_min_ttc && ((price2num($pu_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) { + } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; @@ -1833,7 +1861,8 @@ if ($action == 'create' && $usercancreate) { // Shipping Method if (isModEnabled('expedition')) { print ''.$langs->trans('SendingMethod').''; - print img_picto('', 'object_dolly', 'class="pictofixedwidth"').$form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx'); + print img_picto('', 'object_dolly', 'class="pictofixedwidth"'); + $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx'); print ''; } @@ -1898,7 +1927,7 @@ if ($action == 'create' && $usercancreate) { if ($soc->fetch_optionals() > 0) { $object->array_options = array_merge($object->array_options, $soc->array_options); } - }; + } print $object->showOptionals($extrafields, 'create', $parameters); } @@ -2736,7 +2765,7 @@ if ($action == 'create' && $usercancreate) { // Show object lines if (!empty($object->lines)) { - $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); + $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); } $numlines = count($object->lines); @@ -2840,7 +2869,7 @@ if ($action == 'create' && $usercancreate) { // Ship $numshipping = 0; if (isModEnabled('expedition')) { - $numshipping = $object->nb_expedition(); + $numshipping = $object->countNbOfShipments(); if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && ($object->getNbOfProductsLines() > 0 || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) { if ((isModEnabled('expedition_bon') && $user->rights->expedition->creer) || ($conf->delivery_note->enabled && $user->rights->expedition->delivery->creer)) { diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 2c916abda9a..1a879173684 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -28,7 +28,6 @@ require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; */ class Orders extends DolibarrApi { - /** * @var array $FIELDS Mandatory fields, checked when create and update object */ @@ -109,11 +108,11 @@ class Orders extends DolibarrApi * * Return an array with order informations * - * @param int $id ID of order + * @param int $id ID of order * @param string $ref Ref of object * @param string $ref_ext External reference of object - * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id - * @return array|mixed data without useless information + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return Object Object with cleaned properties * * @throws RestException */ @@ -299,7 +298,7 @@ class Orders extends DolibarrApi * * @url GET {id}/lines * - * @return int + * @return array */ public function getLines($id) { @@ -393,13 +392,12 @@ class Orders extends DolibarrApi /** * Update a line to given order * - * @param int $id Id of order to update - * @param int $lineid Id of line to update - * @param array $request_data OrderLine data + * @param int $id Id of order to update + * @param int $lineid Id of line to update + * @param array $request_data OrderLine data + * @return Object|false Object with cleaned properties * * @url PUT {id}/lines/{lineid} - * - * @return array|bool */ public function putLine($id, $lineid, $request_data = null) { @@ -458,16 +456,14 @@ class Orders extends DolibarrApi } /** - * Delete a line to given order + * Delete a line of a given order * - * - * @param int $id Id of order to update - * @param int $lineid Id of line to delete + * @param int $id Id of order to update + * @param int $lineid Id of line to delete + * @return Object Object with cleaned properties * * @url DELETE {id}/lines/{lineid} * - * @return int - * * @throws RestException 401 * @throws RestException 404 */ @@ -486,9 +482,7 @@ class Orders extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - // TODO Check the lineid $lineid is a line of ojbect - - $updateRes = $this->commande->deleteline(DolibarrApiAccess::$user, $lineid); + $updateRes = $this->commande->deleteline(DolibarrApiAccess::$user, $lineid, $id); if ($updateRes > 0) { return $this->get($id); } else { @@ -501,13 +495,12 @@ class Orders extends DolibarrApi * * Return an array with contact informations * - * @param int $id ID of order - * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER) + * @param int $id ID of order + * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER) + * @return Object Object with cleaned properties * * @url GET {id}/contacts * - * @return array data without useless information - * * @throws RestException */ public function getContacts($id, $type = '') @@ -536,11 +529,10 @@ class Orders extends DolibarrApi * @param int $id Id of order to update * @param int $contactid Id of contact to add * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER) + * @return array * * @url POST {id}/contact/{contactid}/{type} * - * @return int - * * @throws RestException 401 * @throws RestException 404 */ @@ -586,7 +578,7 @@ class Orders extends DolibarrApi * * @url DELETE {id}/contact/{contactid}/{type} * - * @return int + * @return array * * @throws RestException 401 * @throws RestException 404 @@ -630,10 +622,9 @@ class Orders extends DolibarrApi /** * Update order general fields (won't touch lines of order) * - * @param int $id Id of order to update - * @param array $request_data Datas - * - * @return int + * @param int $id Id of order to update + * @param array $request_data Datas + * @return Object Object with cleaned properties */ public function put($id, $request_data = null) { @@ -777,7 +768,6 @@ class Orders extends DolibarrApi */ public function reopen($id) { - if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } @@ -802,12 +792,11 @@ class Orders extends DolibarrApi /** * Classify the order as invoiced. Could be also called setbilled * - * @param int $id Id of the order + * @param int $id Id of the order + * @return Object Object with cleaned properties * * @url POST {id}/setinvoiced * - * @return int - * * @throws RestException 400 * @throws RestException 401 * @throws RestException 404 @@ -851,10 +840,9 @@ class Orders extends DolibarrApi * * @param int $id Order ID * @param int $notrigger Disabled triggers + * @return Object Object with cleaned properties * * @url POST {id}/close - * - * @return int */ public function close($id, $notrigger = 0) { @@ -897,10 +885,9 @@ class Orders extends DolibarrApi * * @param int $id Order ID * @param int $idwarehouse Warehouse ID to use for stock change (Used only if option STOCK_CALCULATE_ON_VALIDATE_ORDER is on) + * @return Object Object with cleaned properties * * @url POST {id}/settodraft - * - * @return array */ public function settodraft($id, $idwarehouse = -1) { @@ -942,12 +929,11 @@ class Orders extends DolibarrApi /** * Create an order using an existing proposal. * - * * @param int $proposalid Id of the proposal + * @return Object Object with cleaned properties * * @url POST /createfromproposal/{proposalid} * - * @return int * @throws RestException 400 * @throws RestException 401 * @throws RestException 404 diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 6083209a32e..9b987cb603c 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -306,7 +306,7 @@ class Commande extends CommonOrder 'ref' =>array('type'=>'varchar(30)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>25), 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'RefExt', 'enabled'=>1, 'visible'=>0, 'position'=>26), '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'=>'$conf->societe->enabled', 'visible'=>-1, 'notnull'=>1, 'position'=>20), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'isModEnabled("societe")', 'visible'=>-1, 'notnull'=>1, 'position'=>20), 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Project', 'enabled'=>"isModEnabled('project')", '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), @@ -1173,6 +1173,8 @@ class Commande extends CommonOrder return -1; } } + + return 0; } else { dol_print_error($this->db); $this->db->rollback(); @@ -1301,6 +1303,7 @@ class Commande extends CommonOrder { global $conf, $hookmanager; + dol_include_once('/multicurrency/class/multicurrency.class.php'); dol_include_once('/core/class/extrafields.class.php'); $error = 0; @@ -1376,6 +1379,29 @@ class Commande extends CommonOrder $this->origin = $object->element; $this->origin_id = $object->id; + // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) + if (!empty($conf->multicurrency->enabled)) { + if (!empty($object->multicurrency_code)) { + $this->multicurrency_code = $object->multicurrency_code; + } + if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($object->multicurrency_tx)) { + $this->multicurrency_tx = $object->multicurrency_tx; + } + + if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) { + $tmparray = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $this->date_commande); + $this->fk_multicurrency = $tmparray[0]; + $this->multicurrency_tx = $tmparray[1]; + } else { + $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); + } + if (empty($this->fk_multicurrency)) { + $this->multicurrency_code = $conf->currency; + $this->fk_multicurrency = 0; + $this->multicurrency_tx = 1; + } + } + // get extrafields from original line $object->fetch_optionals(); @@ -2283,17 +2309,13 @@ class Commande extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Returns a array with expeditions lines number + * Returns an array with expeditions lines number * * @return int Nb of shipments - * - * TODO deprecate, move to Shipping class */ - public function nb_expedition() + public function countNbOfShipments() { - // phpcs:enable $sql = 'SELECT count(*)'; $sql .= ' FROM '.MAIN_DB_PREFIX.'expedition as e'; $sql .= ', '.MAIN_DB_PREFIX.'element_element as el'; @@ -2309,6 +2331,8 @@ class Commande extends CommonOrder } else { dol_print_error($this->db); } + + return 0; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -2355,58 +2379,45 @@ class Commande extends CommonOrder * * @param User $user User object * @param int $lineid Id of line to delete + * @param int $id Id of object (for a check) * @return int >0 if OK, 0 if nothing to do, <0 if KO */ - public function deleteline($user = null, $lineid = 0) + public function deleteline($user = null, $lineid = 0, $id = 0) { if ($this->statut == self::STATUS_DRAFT) { $this->db->begin(); - $sql = "SELECT fk_product, qty"; - $sql .= " FROM ".MAIN_DB_PREFIX."commandedet"; - $sql .= " WHERE rowid = ".((int) $lineid); + // Delete line + $line = new OrderLine($this->db); - $result = $this->db->query($sql); - if ($result) { - $obj = $this->db->fetch_object($result); + $line->context = $this->context; - if ($obj) { - $product = new Product($this->db); - $product->id = $obj->fk_product; + // Load data + $line->fetch($lineid); - // Delete line - $line = new OrderLine($this->db); + if ($id > 0 && $line->fk_commande != $id) { + $this->error = 'ErrorLineIDDoesNotMatchWithObjectID'; + return -1; + } - // For triggers - $line->fetch($lineid); + // Memorize previous line for triggers + $staticline = clone $line; + $line->oldline = $staticline; - // Memorize previous line for triggers - $staticline = clone $line; - $line->oldline = $staticline; + if ($line->delete($user) > 0) { + $result = $this->update_price(1); - if ($line->delete($user) > 0) { - $result = $this->update_price(1); - - if ($result > 0) { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - $this->error = $this->db->lasterror(); - return -1; - } - } else { - $this->db->rollback(); - $this->error = $line->error; - return -1; - } + if ($result > 0) { + $this->db->commit(); + return 1; } else { $this->db->rollback(); - return 0; + $this->error = $this->db->lasterror(); + return -1; } } else { $this->db->rollback(); - $this->error = $this->db->lasterror(); + $this->error = $line->error; return -1; } } else { @@ -2490,6 +2501,8 @@ class Commande extends CommonOrder return -1 * $error; } } + + return 0; } @@ -2554,6 +2567,8 @@ class Commande extends CommonOrder return -1 * $error; } } + + return 0; } @@ -3422,7 +3437,7 @@ class Commande extends CommonOrder } // Test we can delete - if ($this->nb_expedition() != 0) { + if ($this->countNbOfShipments() != 0) { $this->errors[] = $langs->trans('SomeShipmentExists'); $error++; } @@ -4582,6 +4597,9 @@ class OrderLine extends CommonOrderLine if (empty($this->remise_percent)) { $this->remise_percent = 0; } + if (empty($this->remise)) { + $this->remise = 0; + } if (empty($this->info_bits)) { $this->info_bits = 0; } diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 4f644ef01f3..4fb5582e187 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -236,7 +236,7 @@ if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massa $massaction = ''; } -$parameters = array('socid'=>$socid); +$parameters = array('socid'=>$socid, 'arrayfields'=>&$arrayfields); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -683,14 +683,14 @@ if ($action == 'validate' && $permissiontoadd) { $idwarehouse = 0; } if ($objecttmp->valid($user, $idwarehouse)) { - setEventMessage($langs->trans('hasBeenValidated', $objecttmp->ref), 'mesgs'); + setEventMessages($langs->trans('hasBeenValidated', $objecttmp->ref), null, 'mesgs'); } else { - setEventMessage($objecttmp->error, $objecttmp->errors, 'errors'); + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; } } else { $langs->load("errors"); - setEventMessage($langs->trans('ErrorIsNotADraft', $objecttmp->ref), 'errors'); + setEventMessages($langs->trans('ErrorIsNotADraft', $objecttmp->ref), null, 'errors'); $error++; } } else { @@ -714,14 +714,14 @@ if ($action == 'shipped' && $permissiontoadd) { if ($objecttmp->fetch($checked)) { if ($objecttmp->statut == 1 || $objecttmp->statut == 2) { if ($objecttmp->cloture($user)) { - setEventMessage($langs->trans('PassedInClosedStatus', $objecttmp->ref), 'mesgs'); + setEventMessages($langs->trans('PassedInClosedStatus', $objecttmp->ref), null, 'mesgs'); } else { - setEventMessage($langs->trans('CantBeClosed'), 'errors'); + setEventMessages($langs->trans('CantBeClosed'), null, 'errors'); $error++; } } else { $langs->load("errors"); - setEventMessage($langs->trans('ErrorIsNotADraft', $objecttmp->ref), 'errors'); + setEventMessages($langs->trans('ErrorIsNotADraft', $objecttmp->ref), null, 'errors'); $error++; } } else { @@ -1526,16 +1526,16 @@ if ($resql) { } // Town if (!empty($arrayfields['s.town']['checked'])) { - print ''; + print ''; } // Zip if (!empty($arrayfields['s.zip']['checked'])) { - print ''; + print ''; } // State if (!empty($arrayfields['state.nom']['checked'])) { print ''; - print ''; + print ''; print ''; } // Country @@ -1723,18 +1723,18 @@ if ($resql) { } // Status billed if (!empty($arrayfields['c.facture']['checked'])) { - print ''; + print ''; print $form->selectyesno('search_billed', $search_billed, 1, 0, 1, 1); print ''; } // Import key if (!empty($arrayfields['c.import_key']['checked'])) { - print ''; + print ''; print ''; } // Status if (!empty($arrayfields['c.fk_statut']['checked'])) { - print ''; + print ''; $liststatus = array( Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraftShort"), Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"), @@ -1744,7 +1744,7 @@ if ($resql) { -2=>$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort"), Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceledShort") ); - print $form->selectarray('search_status', $liststatus, $search_status, -5, 0, 0, '', 0, 0, 0, '', 'maxwidth125 onrightofpage', 1); + print $form->selectarray('search_status', $liststatus, $search_status, -5, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage', 1); print ''; } // Action column @@ -1907,7 +1907,7 @@ if ($resql) { print_liste_field_titre($arrayfields['c.import_key']['label'], $_SERVER["PHP_SELF"], "c.import_key", "", $param, '', $sortfield, $sortorder, 'center '); } if (!empty($arrayfields['c.fk_statut']['checked'])) { - print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); } if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center '); @@ -2623,7 +2623,7 @@ if ($resql) { // Import key if (!empty($arrayfields['c.import_key']['checked'])) { - print ''.$obj->import_key.''; + print ''.dol_escape_htmltag($obj->import_key).''; if (!$i) { $totalarray['nbfield']++; } @@ -2631,7 +2631,7 @@ if ($resql) { // Status if (!empty($arrayfields['c.fk_statut']['checked'])) { - print ''.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).''; + print ''.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).''; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/commande/list_det.php b/htdocs/commande/list_det.php new file mode 100644 index 00000000000..fd36f229e5c --- /dev/null +++ b/htdocs/commande/list_det.php @@ -0,0 +1,2168 @@ + + * Copyright (C) 2004-2019 Laurent Destailleur + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2013 Christophe Battarel + * Copyright (C) 2013 Cédric Salvador + * Copyright (C) 2015-2018 Frédéric France + * Copyright (C) 2015 Marcos García + * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2016-2021 Ferran Marcet + * Copyright (C) 2018 Charlene Benke + * Copyright (C) 2021-2022 Anthony Berton + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * 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/commande/list.php + * \ingroup commande + * \brief Page to list orders + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +if (!empty($conf->margin->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; +} +require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array("orders", 'sendings', 'deliveries', 'companies', 'compta', 'bills', 'stocks', 'products')); + +$action = GETPOST('action', 'aZ09'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); +$toselect = GETPOST('toselect', 'array'); +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'orderlistdet'; +$productobuy = GETPOST('productobuy', 'alpha'); +$productonly = GETPOST('productonly', 'alpha'); +$disablelinefree = GETPOST('disablelinefree', 'alpha'); + +$search_datecloture_start = GETPOST('search_datecloture_start', 'int'); +if (empty($search_datecloture_start)) { + $search_datecloture_start = dol_mktime(0, 0, 0, GETPOST('search_datecloture_startmonth', 'int'), GETPOST('search_datecloture_startday', 'int'), GETPOST('search_datecloture_startyear', 'int')); +} +$search_datecloture_end = GETPOST('search_datecloture_end', 'int'); +if (empty($search_datecloture_end)) { + $search_datecloture_end = dol_mktime(23, 59, 59, GETPOST('search_datecloture_endmonth', 'int'), GETPOST('search_datecloture_endday', 'int'), GETPOST('search_datecloture_endyear', 'int')); +} +$search_dateorder_start = dol_mktime(0, 0, 0, GETPOST('search_dateorder_start_month', 'int'), GETPOST('search_dateorder_start_day', 'int'), GETPOST('search_dateorder_start_year', 'int')); +$search_dateorder_end = dol_mktime(23, 59, 59, GETPOST('search_dateorder_end_month', 'int'), GETPOST('search_dateorder_end_day', 'int'), GETPOST('search_dateorder_end_year', 'int')); +$search_datedelivery_start = dol_mktime(0, 0, 0, GETPOST('search_datedelivery_start_month', 'int'), GETPOST('search_datedelivery_start_day', 'int'), GETPOST('search_datedelivery_start_year', 'int')); +$search_datedelivery_end = dol_mktime(23, 59, 59, GETPOST('search_datedelivery_end_month', 'int'), GETPOST('search_datedelivery_end_day', 'int'), GETPOST('search_datedelivery_end_year', 'int')); +$search_product_category = GETPOST('search_product_category', 'int'); + +// Détail commande +$search_refProduct = GETPOST('search_refProduct', 'alpha'); +$search_descProduct = GETPOST('search_descProduct', 'alpha'); + +$search_ref = GETPOST('search_ref', 'alpha') != '' ?GETPOST('search_ref', 'alpha') : GETPOST('sref', 'alpha'); +$search_ref_customer = GETPOST('search_ref_customer', 'alpha'); +$search_company = GETPOST('search_company', 'alpha'); +$search_company_alias = GETPOST('search_company_alias', 'alpha'); +$search_town = GETPOST('search_town', 'alpha'); +$search_zip = GETPOST('search_zip', 'alpha'); +$search_state = GETPOST("search_state", 'alpha'); +$search_country = GETPOST("search_country", 'int'); +$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$socid = GETPOST('socid', 'int'); +$search_user = GETPOST('search_user', 'int'); +$search_sale = GETPOST('search_sale', 'int'); +$search_total_ht = GETPOST('search_total_ht', 'alpha'); +$search_total_vat = GETPOST('search_total_vat', 'alpha'); +$search_total_ttc = GETPOST('search_total_ttc', 'alpha'); +$search_warehouse = GETPOST('search_warehouse', 'int'); +$search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha'); +$search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha'); +$search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha'); +$search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha'); +$search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha'); +$search_login = GETPOST('search_login', 'alpha'); +$search_categ_cus = GETPOST("search_categ_cus", 'int'); +$optioncss = GETPOST('optioncss', 'alpha'); +$search_billed = GETPOSTISSET('search_billed') ? GETPOST('search_billed', 'int') : GETPOST('billed', 'int'); +$search_status = GETPOST('search_status', 'int'); +$search_btn = GETPOST('button_search', 'alpha'); +$search_remove_btn = GETPOST('button_removefilter', 'alpha'); +$search_project_ref = GETPOST('search_project_ref', 'alpha'); +$search_project = GETPOST('search_project', 'alpha'); +$search_shippable = GETPOST('search_shippable', 'aZ09'); +$search_fk_cond_reglement = GETPOST("search_fk_cond_reglement", 'int'); +$search_fk_shipping_method = GETPOST("search_fk_shipping_method", 'int'); +$search_fk_mode_reglement = GETPOST("search_fk_mode_reglement", 'int'); +$search_fk_input_reason = GETPOST("search_fk_input_reason", 'int'); + +// Security check +$id = (GETPOST('orderid') ?GETPOST('orderid', 'int') : GETPOST('id', 'int')); +if ($user->socid) { + $socid = $user->socid; +} +$result = restrictedArea($user, 'commande', $id, ''); + +$diroutputmassaction = $conf->commande->multidir_output[$conf->entity].'/temp/massgeneration/'.$user->id; + +// Load variable for pagination +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + $page = 0; +} // If $page is not defined, or '' or -1 or if we click on clear filters +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (!$sortfield) { + $sortfield = 'c.ref'; +} +if (!$sortorder) { + $sortorder = 'DESC'; +} + +$show_shippable_command = GETPOST('show_shippable_command', 'aZ09'); + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$object = new Commande($db); +$hookmanager->initHooks(array('orderlistdetail')); +$extrafields = new ExtraFields($db); + +// fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); + +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array( + 'c.ref'=>'Ref', + 'c.ref_client'=>'RefCustomerOrder', + 'pd.description'=>'Description', + 's.nom'=>"ThirdParty", + 's.name_alias'=>"AliasNameShort", + 's.zip'=>"Zip", + 's.town'=>"Town", + 'c.note_public'=>'NotePublic', +); +if (empty($user->socid)) { + $fieldstosearchall["c.note_private"] = "NotePrivate"; +} + +$checkedtypetiers = 0; +$arrayfields = array( + // Détail commande + 'pr.ref'=> array('label'=>'ProductRef', 'checked'=>1, 'position'=>1), + 'pr.desc'=> array('label'=>'ProductDescription', 'checked'=>1, 'position'=>1), + 'cdet.qty'=> array('label'=>'QtyOrdered', 'checked'=>1, 'position'=>1), + 'c.ref'=>array('label'=>"Ref", 'checked'=>1, 'position'=>5), + 'c.ref_client'=>array('label'=>"RefCustomerOrder", 'checked'=>-1, 'position'=>10), + 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>-1, 'enabled'=>(empty($conf->project->enabled) ? 0 : 1), 'position'=>20), + 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->project->enabled) ? 0 : 1), 'position'=>25), + 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>30), + 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>-1, 'position'=>31), + 's.town'=>array('label'=>"Town", 'checked'=>-1, 'position'=>35), + 's.zip'=>array('label'=>"Zip", 'checked'=>-1, 'position'=>40), + 'state.nom'=>array('label'=>"StateShort", 'checked'=>0, 'position'=>45), + 'country.code_iso'=>array('label'=>"Country", 'checked'=>0, 'position'=>50), + 'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers, 'position'=>55), + 'c.date_commande'=>array('label'=>"OrderDateShort", 'checked'=>1, 'position'=>60), + 'c.date_delivery'=>array('label'=>"DateDeliveryPlanned", 'checked'=>1, 'enabled'=>empty($conf->global->ORDER_DISABLE_DELIVERY_DATE), 'position'=>65), + 'c.fk_shipping_method'=>array('label'=>"SendingMethod", 'checked'=>-1, 'position'=>66 , 'enabled'=>!empty($conf->expedition->enabled)), + 'c.fk_cond_reglement'=>array('label'=>"PaymentConditionsShort", 'checked'=>-1, 'position'=>67), + 'c.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>-1, 'position'=>68), + 'c.fk_input_reason'=>array('label'=>"Channel", 'checked'=>-1, 'position'=>69), + 'cdet.total_ht'=>array('label'=>"AmountHT", 'checked'=>1, 'position'=>75), + 'c.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0, 'position'=>80), + 'cdet.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0, 'position'=>85), + 'c.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>90), + 'c.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>95), + 'c.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>100), + 'c.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>105), + 'c.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>110), + 'c.fk_warehouse'=>array('label'=>'Warehouse', 'checked'=>0, 'enabled'=>(empty($conf->stock->enabled) && empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER) ? 0 : 1), 'position'=>110), + 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>115), + 'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>0, 'position'=>116), + 'total_pa' => array('label' => (getDolGlobalString('MARGIN_TYPE') == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous ? 0 : 1)), + 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous ? 0 : 1)), + 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARGIN_RATES) ? 0 : 1)), + 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARK_RATES) ? 0 : 1)), + 'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>120), + 'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>125), + 'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>130), + 'c.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PUBLIC_NOTES)), 'position'=>135), + 'c.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PRIVATE_NOTES)), 'position'=>140), + 'shippable'=>array('label'=>"Shippable", 'checked'=>1,'enabled'=>(!empty($conf->expedition->enabled)), 'position'=>990), + 'c.facture'=>array('label'=>"Billed", 'checked'=>1, 'enabled'=>(empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)), 'position'=>995), + 'c.import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>999), + 'c.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000) +); + +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; + +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); + + + +/* + * Actions + */ + +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { + $massaction = ''; +} + +$parameters = array('socid'=>$socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} + +if (empty($reshook)) { + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers + $productobuy = ''; + $productonly = ''; + $disablelinefree = ''; + $search_categ = ''; + $search_user = ''; + $search_sale = ''; + $search_product_category = ''; + $search_refProduct = ''; + $search_descProduct = ''; + $search_ref = ''; + $search_ref_customer = ''; + $search_company = ''; + $search_company_alias = ''; + $search_town = ''; + $search_zip = ""; + $search_state = ""; + $search_type = ''; + $search_country = ''; + $search_type_thirdparty = ''; + $search_total_ht = ''; + $search_total_vat = ''; + $search_total_ttc = ''; + $search_warehouse = ''; + $search_multicurrency_code = ''; + $search_multicurrency_tx = ''; + $search_multicurrency_montant_ht = ''; + $search_multicurrency_montant_vat = ''; + $search_multicurrency_montant_ttc = ''; + $search_login = ''; + $search_dateorder_start = ''; + $search_dateorder_end = ''; + $search_datedelivery_start = ''; + $search_datedelivery_end = ''; + $search_project_ref = ''; + $search_project = ''; + $search_status = ''; + $search_billed = ''; + $toselect = array(); + $search_array_options = array(); + $search_categ_cus = 0; + $search_datecloture_start = ''; + $search_datecloture_end = ''; + $search_fk_cond_reglement = ''; + $search_fk_shipping_method = ''; + $search_fk_mode_reglement = ''; + $search_fk_input_reason = ''; + } + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } + + // Mass actions + $objectclass = 'Commande'; + $objectlabel = 'Orders'; + $permissiontoread = $user->rights->commande->lire; + $permissiontoadd = $user->rights->commande->creer; + $permissiontodelete = $user->rights->commande->supprimer; + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { + $permissiontovalidate = $user->rights->commande->order_advance->validate; + $permissiontoclose = $user->rights->commande->order_advance->close; + $permissiontocancel = $user->rights->commande->order_advance->annuler; + $permissiontosendbymail = $user->rights->commande->order_advance->send; + } else { + $permissiontovalidate = $user->rights->commande->creer; + $permissiontoclose = $user->rights->commande->creer; + $permissiontocancel = $user->rights->commande->creer; + $permissiontosendbymail = $user->rights->commande->creer; + } + $uploaddir = $conf->commande->multidir_output[$conf->entity]; + $triggersendname = 'ORDER_SENTBYMAIL'; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; +} + +// Closed records +// if (!$error && $massaction === 'setbilled' && $permissiontoclose) { + +// } + +/* + * View + */ + +$now = dol_now(); + +$form = new Form($db); +$formother = new FormOther($db); +$formfile = new FormFile($db); +$formmargin = null; +if (!empty($conf->margin->enabled)) { + $formmargin = new FormMargin($db); +} +$companystatic = new Societe($db); +$formcompany = new FormCompany($db); +$projectstatic = new Project($db); + +$title = $langs->trans("Orders"); +$help_url = "EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes"; +// llxHeader('',$title,$help_url); + +$sql = 'SELECT'; +if ($sall || $search_product_category > 0 || $search_user > 0) { + $sql = 'SELECT DISTINCT'; +} +$sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; +$sql .= " typent.code as typent_code,"; +$sql .= " state.code_departement as state_code, state.nom as state_name,"; +$sql .= " country.code as country_code,"; +$sql .= ' c.rowid as c_rowid, c.ref, c.ref_client, c.fk_user_author,'; +$sql .= ' c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multicurrency_total_ht, c.multicurrency_total_tva as multicurrency_total_vat, c.multicurrency_total_ttc,'; +$sql .= ' c.total_ht as c_total_ht, c.total_tva as c_total_tva, c.total_ttc as c_total_ttc, c.fk_warehouse as warehouse,'; +$sql .= ' c.date_valid, c.date_commande, c.note_public, c.note_private, c.date_livraison as date_delivery, c.fk_statut, c.facture as billed,'; +$sql .= ' c.date_creation as date_creation, c.tms as date_update, c.date_cloture as date_cloture,'; +$sql .= ' p.rowid as project_id, p.ref as project_ref, p.title as project_label,'; +$sql .= ' u.login, u.lastname, u.firstname, u.email as user_email, u.statut as user_statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender,'; +$sql .= ' c.fk_cond_reglement,c.deposit_percent,c.fk_mode_reglement,c.fk_shipping_method,'; +$sql .= ' c.fk_input_reason, c.import_key'; + +// Détail commande +$sql .= ', cdet.rowid, cdet.description, cdet.qty, cdet.product_type, cdet.fk_product, cdet.total_ht, cdet.total_tva, cdet.total_ttc, '; +$sql .= ' pr.rowid as product_rowid, pr.ref as product_ref, pr.label as product_label, pr.barcode as product_barcode, pr.tobatch as product_batch, pr.tosell as product_status, pr.tobuy as product_status_buy'; + +if (($search_categ_cus > 0) || ($search_categ_cus == -2)) { + $sql .= ", cc.fk_categorie, cc.fk_soc"; +} +// Add fields from extrafields +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : ''); + } +} +// Add fields from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s'; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +if (($search_categ_cus > 0) || ($search_categ_cus == -2)) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ +} + +// Détail commande +$sql .= ', '.MAIN_DB_PREFIX.'commandedet as cdet'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande as c ON cdet.fk_commande=c.rowid'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as pr ON pr.rowid=cdet.fk_product'; + +if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_extrafields as ef on (c.rowid = ef.fk_object)"; +} +if ($sall || $search_product_category > 0) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet as pd ON c.rowid=pd.fk_commande'; +} +if ($search_product_category > 0) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; +} +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = c.fk_projet"; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON c.fk_user_author = u.rowid'; + +// We'll need this table joined to the select in order to filter by sale +if ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid)) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +} +if ($search_user > 0) { + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; + $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; +} + +// Add table from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; + +$sql .= ' WHERE c.fk_soc = s.rowid'; +$sql .= ' AND c.entity IN ('.getEntity('commande').')'; +$sql .= ' AND cdet.product_type <> 9'; + +if (!empty($productobuy)) { + $sql .= " AND pr.tobuy = 1"; +} +if (!empty($productonly)) { + $sql .= " AND (cdet.product_type = 0 OR cdet.product_type = 1)"; +} +if (!empty($disablelinefree)) { + $sql .= " AND cdet.fk_product IS NOT NULL"; +} +if ($search_product_category > 0) { + $sql .= " AND cp.fk_categorie = ".((int) $search_product_category); +} +if ($socid > 0) { + $sql .= ' AND s.rowid = '.((int) $socid); +} +if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); +} +if ($search_refProduct) { + $sql .= natural_search('pr.ref', $search_refProduct); +} +if ($search_descProduct) { + $sql .= natural_search('pr.label', $search_descProduct); + $sql .= natural_search('cdet.description', $search_descProduct); +} +if ($search_ref) { + $sql .= natural_search('c.ref', $search_ref); +} +if ($search_ref_customer) { + $sql .= natural_search('c.ref_client', $search_ref_customer); +} +if ($sall) { + $sql .= natural_search(array_keys($fieldstosearchall), $sall); +} +if ($search_billed != '' && $search_billed >= 0) { + $sql .= ' AND c.facture = '.((int) $search_billed); +} +if ($search_status <> '') { + if ($search_status <= 3 && $search_status >= -1) { // status from -1 to 3 are real status (other are virtual combination) + if ($search_status == 1 && empty($conf->expedition->enabled)) { + $sql .= ' AND c.fk_statut IN (1,2)'; // If module expedition disabled, we include order with status 'sending in process' into 'validated' + } else { + $sql .= ' AND c.fk_statut = '.((int) $search_status); // brouillon, validee, en cours, annulee + } + } + if ($search_status == -2) { // To process + //$sql.= ' AND c.fk_statut IN (1,2,3) AND c.facture = 0'; + $sql .= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected + } + if ($search_status == -3) { // To bill + //$sql.= ' AND c.fk_statut in (1,2,3)'; + //$sql.= ' AND c.facture = 0'; // invoice not created + $sql .= ' AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))'; // validated, in process or closed but not billed + } + if ($search_status == -4) { // "validate and in progress" + $sql .= ' AND (c.fk_statut IN (1,2))'; // validated, in process + } +} + +if ($search_datecloture_start) { + $sql .= " AND c.date_cloture >= '".$db->idate($search_datecloture_start)."'"; +} +if ($search_datecloture_end) { + $sql .= " AND c.date_cloture <= '".$db->idate($search_datecloture_end)."'"; +} +if ($search_dateorder_start) { + $sql .= " AND c.date_commande >= '".$db->idate($search_dateorder_start)."'"; +} +if ($search_dateorder_end) { + $sql .= " AND c.date_commande <= '".$db->idate($search_dateorder_end)."'"; +} +if ($search_datedelivery_start) { + $sql .= " AND c.date_livraison >= '".$db->idate($search_datedelivery_start)."'"; +} +if ($search_datedelivery_end) { + $sql .= " AND c.date_livraison <= '".$db->idate($search_datedelivery_end)."'"; +} +if ($search_town) { + $sql .= natural_search('s.town', $search_town); +} +if ($search_zip) { + $sql .= natural_search("s.zip", $search_zip); +} +if ($search_state) { + $sql .= natural_search("state.nom", $search_state); +} +if ($search_country) { + $sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')'; +} +if ($search_type_thirdparty && $search_type_thirdparty != '-1') { + $sql .= " AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).')'; +} +if ($search_company) { + $sql .= natural_search('s.nom', $search_company); +} +if ($search_company_alias) { + $sql .= natural_search('s.name_alias', $search_company_alias); +} +if ($search_sale > 0) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale); +} +if ($search_user > 0) { + $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".((int) $search_user); +} +if ($search_total_ht != '') { + $sql .= natural_search('cdet.total_ht', $search_total_ht, 1); +} +if ($search_total_vat != '') { + $sql .= natural_search('cdet.total_tva', $search_total_vat, 1); +} +if ($search_total_ttc != '') { + $sql .= natural_search('cdet.total_ttc', $search_total_ttc, 1); +} +if ($search_warehouse != '' && $search_warehouse > 0) { + $sql .= natural_search('c.fk_warehouse', $search_warehouse, 1); +} +if ($search_multicurrency_code != '') { + $sql .= " AND c.multicurrency_code = '".$db->escape($search_multicurrency_code)."'"; +} +if ($search_multicurrency_tx != '') { + $sql .= natural_search('c.multicurrency_tx', $search_multicurrency_tx, 1); +} +if ($search_multicurrency_montant_ht != '') { + $sql .= natural_search('c.multicurrency_total_ht', $search_multicurrency_montant_ht, 1); +} +if ($search_multicurrency_montant_vat != '') { + $sql .= natural_search('c.multicurrency_total_tva', $search_multicurrency_montant_vat, 1); +} +if ($search_multicurrency_montant_ttc != '') { + $sql .= natural_search('c.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1); +} +if ($search_login) { + $sql .= natural_search(array("u.login", "u.firstname", "u.lastname"), $search_login); +} +if ($search_project_ref != '') { + $sql .= natural_search("p.ref", $search_project_ref); +} +if ($search_project != '') { + $sql .= natural_search("p.title", $search_project); +} +if ($search_categ_cus > 0) { + $sql .= " AND cc.fk_categorie = ".((int) $search_categ_cus); +} +if ($search_categ_cus == -2) { + $sql .= " AND cc.fk_categorie IS NULL"; +} +if ($search_fk_cond_reglement > 0) { + $sql .= " AND c.fk_cond_reglement = ".((int) $search_fk_cond_reglement); +} +if ($search_fk_shipping_method > 0) { + $sql .= " AND c.fk_shipping_method = ".((int) $search_fk_shipping_method); +} +if ($search_fk_mode_reglement > 0) { + $sql .= " AND c.fk_mode_reglement = ".((int) $search_fk_mode_reglement); +} +if ($search_fk_input_reason > 0) { + $sql .= " AND c.fk_input_reason = ".((int) $search_fk_input_reason); +} + +// Add where from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; +// Add where from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; + +// Add HAVING from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint; + +$sql .= $db->order($sortfield, $sortorder); + +// Count total nb of records +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 + $page = 0; + $offset = 0; + } +} + +$sql .= $db->plimit($limit + 1, $offset); +//print $sql; + +$resql = $db->query($sql); +if ($resql) { + if ($socid > 0) { + $soc = new Societe($db); + $soc->fetch($socid); + $title = $langs->trans('ListOrderLigne').' - '.$soc->name; + if (empty($search_company)) { + $search_company = $soc->name; + } + } else { + $title = $langs->trans('ListOrderLigne'); + } + if (strval($search_status) == '0') { + $title .= ' - '.$langs->trans('StatusOrderDraftShort'); + } + if ($search_status == 1) { + $title .= ' - '.$langs->trans('StatusOrderValidatedShort'); + } + if ($search_status == 2) { + $title .= ' - '.$langs->trans('StatusOrderSentShort'); + } + if ($search_status == 3) { + $title .= ' - '.$langs->trans('StatusOrderToBillShort'); + } + if ($search_status == -1) { + $title .= ' - '.$langs->trans('StatusOrderCanceledShort'); + } + if ($search_status == -2) { + $title .= ' - '.$langs->trans('StatusOrderToProcessShort'); + } + if ($search_status == -3) { + $title .= ' - '.$langs->trans('StatusOrderValidated').', '.(empty($conf->expedition->enabled) ? '' : $langs->trans("StatusOrderSent").', ').$langs->trans('StatusOrderToBill'); + } + if ($search_status == -4) { + $title .= ' - '.$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort"); + } + + $num = $db->num_rows($resql); + + $arrayofselected = is_array($toselect) ? $toselect : array(); + + if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".DOL_URL_ROOT.'/commande/card.php?id='.$id); + exit; + } + + llxHeader('', $title, $help_url); + + $param = ''; + + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + if ($sall) { + $param .= '&sall='.urlencode($sall); + } + if ($socid > 0) { + $param .= '&socid='.urlencode($socid); + } + if ($search_status != '') { + $param .= '&search_status='.urlencode($search_status); + } + if ($search_datecloture_start) { + $param .= '&search_datecloture_startday='.dol_print_date($search_datecloture_start, '%d').'&search_datecloture_startmonth='.dol_print_date($search_datecloture_start, '%m').'&search_datecloture_startyear='.dol_print_date($search_datecloture_start, '%Y'); + } + if ($search_datecloture_end) { + $param .= '&search_datecloture_endday='.dol_print_date($search_datecloture_end, '%d').'&search_datecloture_endmonth='.dol_print_date($search_datecloture_end, '%m').'&search_datecloture_endyear='.dol_print_date($search_datecloture_end, '%Y'); + } + if ($search_dateorder_start) { + $param .= '&search_dateorder_start_day='.dol_print_date($search_dateorder_start, '%d').'&search_dateorder_start_month='.dol_print_date($search_dateorder_start, '%m').'&search_dateorder_start_year='.dol_print_date($search_dateorder_start, '%Y'); + } + if ($search_dateorder_end) { + $param .= '&search_dateorder_end_day='.dol_print_date($search_dateorder_end, '%d').'&search_dateorder_end_month='.dol_print_date($search_dateorder_end, '%m').'&search_dateorder_end_year='.dol_print_date($search_dateorder_end, '%Y'); + } + if ($search_datedelivery_start) { + $param .= '&search_datedelivery_start_day='.dol_print_date($search_datedelivery_start, '%d').'&search_datedelivery_start_month='.dol_print_date($search_datedelivery_start, '%m').'&search_datedelivery_start_year='.dol_print_date($search_datedelivery_start, '%Y'); + } + if ($search_datedelivery_end) { + $param .= '&search_datedelivery_end_day='.dol_print_date($search_datedelivery_end, '%d').'&search_datedelivery_end_month='.dol_print_date($search_datedelivery_end, '%m').'&search_datedelivery_end_year='.dol_print_date($search_datedelivery_end, '%Y'); + } + if ($search_ref) { + $param .= '&search_ref='.urlencode($search_ref); + } + if ($search_company) { + $param .= '&search_company='.urlencode($search_company); + } + if ($search_company_alias) { + $param .= '&search_company_alias='.urlencode($search_company_alias); + } + if ($search_ref_customer) { + $param .= '&search_ref_customer='.urlencode($search_ref_customer); + } + if ($search_user > 0) { + $param .= '&search_user='.urlencode($search_user); + } + if ($search_sale > 0) { + $param .= '&search_sale='.urlencode($search_sale); + } + if ($search_total_ht != '') { + $param .= '&search_total_ht='.urlencode($search_total_ht); + } + if ($search_total_vat != '') { + $param .= '&search_total_vat='.urlencode($search_total_vat); + } + if ($search_total_ttc != '') { + $param .= '&search_total_ttc='.urlencode($search_total_ttc); + } + if ($search_warehouse != '') { + $param .= '&search_warehouse='.urlencode($search_warehouse); + } + if ($search_login) { + $param .= '&search_login='.urlencode($search_login); + } + if ($search_multicurrency_code != '') { + $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code); + } + if ($search_multicurrency_tx != '') { + $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx); + } + if ($search_multicurrency_montant_ht != '') { + $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht); + } + if ($search_multicurrency_montant_vat != '') { + $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat); + } + if ($search_multicurrency_montant_ttc != '') { + $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc); + } + if ($search_project_ref >= 0) { + $param .= "&search_project_ref=".urlencode($search_project_ref); + } + if ($search_town != '') { + $param .= '&search_town='.urlencode($search_town); + } + if ($search_zip != '') { + $param .= '&search_zip='.urlencode($search_zip); + } + if ($search_state != '') { + $param .= '&search_state='.urlencode($search_state); + } + if ($search_country != '') { + $param .= '&search_country='.urlencode($search_country); + } + if ($search_type_thirdparty && $search_type_thirdparty != '-1') { + $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty); + } + if ($search_product_category != '') { + $param .= '&search_product_category='.urlencode($search_product_category); + } + if (($search_categ_cus > 0) || ($search_categ_cus == -2)) { + $param .= '&search_categ_cus='.urlencode($search_categ_cus); + } + if ($show_files) { + $param .= '&show_files='.urlencode($show_files); + } + if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); + } + if ($search_billed != '') { + $param .= '&search_billed='.urlencode($search_billed); + } + if ($search_fk_cond_reglement > 0) { + $param .= '&search_fk_cond_reglement='.urlencode($search_fk_cond_reglement); + } + if ($search_fk_shipping_method > 0) { + $param .= '&search_fk_shipping_method='.urlencode($search_fk_shipping_method); + } + if ($search_fk_mode_reglement > 0) { + $param .= '&search_fk_mode_reglement='.urlencode($search_fk_mode_reglement); + } + if ($search_fk_input_reason > 0) { + $param .= '&search_fk_input_reason='.urlencode($search_fk_input_reason); + } + + // Add $param from extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + + // Add $param from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook + $param .= $hookmanager->resPrint; + + // List of mass actions available + $arrayofmassactions = array( + 'GenerateOrdersSuppliers'=>img_picto('', 'doc', 'class="pictofixedwidth"').$langs->trans("GenerateOrdersSupplie"), + ); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); + + $url = DOL_URL_ROOT.'/commande/card.php?action=create'; + if (!empty($socid)) { + $url .= '&socid='.$socid; + } + $newcardbutton = '';//dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', $url, '', $contextpage == 'orderlistdet' && $permissiontoadd); + + // Lines of title fields + print '
'; + if ($optioncss != '') { + print ''; + } + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'order', 0, $newcardbutton, '', $limit, 0, 0, 1); + + print ''; + print ''; + print ''; + + $topicmail = "SendOrderRef"; + $modelmail = "order_send"; + $objecttmp = new Commande($db); + $trackid = 'ord'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + + if ($sall) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; + } + + $moreforfilter = ''; + + // If the user can view prospects other than his' + if ($user->rights->user->user->lire) { + $langs->load("commercial"); + $moreforfilter .= '
'; + $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx'); + $moreforfilter .= '
'; + } + // If the user can view other users + if ($user->rights->user->user->lire) { + $moreforfilter .= '
'; + $tmptitle = $langs->trans('LinkedToSpecificUsers'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx'); + $moreforfilter .= '
'; + } + // If the user can view prospects other than his' + if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { + include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter .= '
'; + $tmptitle = $langs->trans('IncludingProductWithTag'); + $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'maxwidth300 widthcentpercentminusx', 1); + $moreforfilter .= '
'; + } + if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter .= '
'; + $tmptitle = $langs->trans('CustomersProspectsCategoriesShort'); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $tmptitle, 'maxwidth300 widthcentpercentminusx'); + $moreforfilter .= '
'; + } + if (!empty($conf->stock->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { + require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; + $formproduct = new FormProduct($db); + $moreforfilter .= '
'; + $tmptitle = $langs->trans('Warehouse'); + $moreforfilter .= img_picto($tmptitle, 'stock', 'class="pictofixedwidth"').$formproduct->selectWarehouses($search_warehouse, 'search_warehouse', '', 1, 0, 0, $tmptitle, 0, 0, array(), 'maxwidth250 widthcentpercentminusx'); + $moreforfilter .= '
'; + } + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; + } else { + $moreforfilter = $hookmanager->resPrint; + } + + if (!empty($moreforfilter)) { + print '
'; + print $moreforfilter; + print '
'; + } + + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields + $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); + + if (GETPOST('autoselectall', 'int')) { + $selectedfields .= ''; + } + + print '
'; + print ''."\n"; + + print ''; + + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } + + // Détail commande + if (!empty($arrayfields['pr.ref']['checked'])) { + print ''; + } + // Product Description + if (!empty($arrayfields['pr.desc']['checked'])) { + print ''; + } + // Product QtyOrdered + if (!empty($arrayfields['cdet.qty']['checked'])) { + print ''; + } + + // Ref + if (!empty($arrayfields['c.ref']['checked'])) { + print ''; + } + // Ref customer + if (!empty($arrayfields['c.ref_client']['checked'])) { + print ''; + } + // Project ref + if (!empty($arrayfields['p.ref']['checked'])) { + print ''; + } + // Project title + if (!empty($arrayfields['p.title']['checked'])) { + print ''; + } + // Thirpdarty + if (!empty($arrayfields['s.nom']['checked'])) { + print ''; + } + // Alias + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + } + // Town + if (!empty($arrayfields['s.town']['checked'])) { + print ''; + } + // Zip + if (!empty($arrayfields['s.zip']['checked'])) { + print ''; + } + // State + if (!empty($arrayfields['state.nom']['checked'])) { + print ''; + } + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) { + print ''; + } + // Company type + if (!empty($arrayfields['typent.code']['checked'])) { + print ''; + } + // Date order + if (!empty($arrayfields['c.date_commande']['checked'])) { + print ''; + } + if (!empty($arrayfields['c.date_delivery']['checked'])) { + print ''; + } + // Shipping Method + if (!empty($arrayfields['c.fk_shipping_method']['checked'])) { + print ''; + } + // Payment term + if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) { + print ''; + } + // Payment mode + if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) { + print ''; + } + // Channel + if (!empty($arrayfields['c.fk_input_reason']['checked'])) { + print ''; + } + if (!empty($arrayfields['cdet.total_ht']['checked'])) { + // Amount + print ''; + } + if (!empty($arrayfields['c.total_vat']['checked'])) { + // Amount + print ''; + } + if (!empty($arrayfields['cdet.total_ttc']['checked'])) { + // Amount + print ''; + } + if (!empty($arrayfields['c.fk_warehouse']['checked'])) { + // Warehouse + print ''; + } + if (!empty($arrayfields['c.multicurrency_code']['checked'])) { + // Currency + print ''; + } + if (!empty($arrayfields['c.multicurrency_tx']['checked'])) { + // Currency rate + print ''; + } + if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) { + // Amount + print ''; + } + if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) { + // Amount VAT + print ''; + } + if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) { + // Amount + print ''; + } + if (!empty($arrayfields['u.login']['checked'])) { + // Author + print ''; + } + if (!empty($arrayfields['sale_representative']['checked'])) { + print ''; + } + if (!empty($arrayfields['total_pa']['checked'])) { + print ''; + } + if (!empty($arrayfields['total_margin']['checked'])) { + print ''; + } + if (!empty($arrayfields['total_margin_rate']['checked'])) { + print ''; + } + if (!empty($arrayfields['total_mark_rate']['checked'])) { + print ''; + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['c.datec']['checked'])) { + print ''; + } + // Date modification + if (!empty($arrayfields['c.tms']['checked'])) { + print ''; + } + // Date cloture + if (!empty($arrayfields['c.date_cloture']['checked'])) { + print ''; + } + // Note public + if (!empty($arrayfields['c.note_public']['checked'])) { + print ''; + } + // Note private + if (!empty($arrayfields['c.note_private']['checked'])) { + print ''; + } + // Shippable + if (!empty($arrayfields['shippable']['checked'])) { + print ''; + } + // Status billed + if (!empty($arrayfields['c.facture']['checked'])) { + print ''; + } + // Import key + if (!empty($arrayfields['c.import_key']['checked'])) { + print ''; + } + // Status + if (!empty($arrayfields['c.fk_statut']['checked'])) { + print ''; + } + // Action column + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } + print "\n"; + + // Fields title + print ''; + + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center '); + } + + // Détail commande + if (!empty($arrayfields['pr.ref']['checked'])) { + print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], 'pr.ref', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['pr.desc']['checked'])) { + print_liste_field_titre($arrayfields['pr.desc']['label'], $_SERVER["PHP_SELF"], 'pr.desc', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['cdet.qty']['checked'])) { + print_liste_field_titre($arrayfields['cdet.qty']['label'], $_SERVER["PHP_SELF"], 'cdet.qty', '', $param, '', $sortfield, $sortorder); + } + + if (!empty($arrayfields['c.ref']['checked'])) { + print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], 'c.ref', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['c.ref_client']['checked'])) { + print_liste_field_titre($arrayfields['c.ref_client']['label'], $_SERVER["PHP_SELF"], 'c.ref_client', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['p.ref']['checked'])) { + print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['p.title']['checked'])) { + print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['s.nom']['checked'])) { + print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['s.name_alias']['checked'])) { + print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], 's.name_alias', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['s.town']['checked'])) { + print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['s.zip']['checked'])) { + print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['state.nom']['checked'])) { + print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['country.code_iso']['checked'])) { + print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['typent.code']['checked'])) { + print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['c.date_commande']['checked'])) { + print_liste_field_titre($arrayfields['c.date_commande']['label'], $_SERVER["PHP_SELF"], 'c.date_commande', '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['c.date_delivery']['checked'])) { + print_liste_field_titre($arrayfields['c.date_delivery']['label'], $_SERVER["PHP_SELF"], 'c.date_livraison', '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['c.fk_shipping_method']['checked'])) { + print_liste_field_titre($arrayfields['c.fk_shipping_method']['label'], $_SERVER["PHP_SELF"], "c.fk_shipping_method", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) { + print_liste_field_titre($arrayfields['c.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "c.fk_cond_reglement", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) { + print_liste_field_titre($arrayfields['c.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "c.fk_mode_reglement", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['c.fk_input_reason']['checked'])) { + print_liste_field_titre($arrayfields['c.fk_input_reason']['label'], $_SERVER["PHP_SELF"], "c.fk_input_reason", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['cdet.total_ht']['checked'])) { + print_liste_field_titre($arrayfields['cdet.total_ht']['label'], $_SERVER["PHP_SELF"], 'cdet.total_ht', '', $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['c.total_vat']['checked'])) { + print_liste_field_titre($arrayfields['c.total_vat']['label'], $_SERVER["PHP_SELF"], 'cdet.total_tva', '', $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['cdet.total_ttc']['checked'])) { + print_liste_field_titre($arrayfields['cdet.total_ttc']['label'], $_SERVER["PHP_SELF"], 'cdet.total_ttc', '', $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['c.fk_warehouse']['checked'])) { + print_liste_field_titre($arrayfields['c.fk_warehouse']['label'], "", '', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['c.multicurrency_code']['checked'])) { + print_liste_field_titre($arrayfields['c.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_code', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['c.multicurrency_tx']['checked'])) { + print_liste_field_titre($arrayfields['c.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_tx', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) { + print_liste_field_titre($arrayfields['c.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) { + print_liste_field_titre($arrayfields['c.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) { + print_liste_field_titre($arrayfields['c.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['u.login']['checked'])) { + print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder); + } + if (!empty($arrayfields['sale_representative']['checked'])) { + print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder); + } + if (!empty($arrayfields['total_pa']['checked'])) { + print_liste_field_titre($arrayfields['total_pa']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['total_margin']['checked'])) { + print_liste_field_titre($arrayfields['total_margin']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['total_margin_rate']['checked'])) { + print_liste_field_titre($arrayfields['total_margin_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['total_mark_rate']['checked'])) { + print_liste_field_titre($arrayfields['total_mark_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + } + + $totalarray = array( + 'nbfield' => 0, + 'val' => array( + 'cdet.total_ht' => 0, + 'cdet.total_tva' => 0, + 'cdet.total_ttc' => 0, + ), + 'pos' => array(), + ); + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; + // Hook fields + $parameters = array( + 'arrayfields' => $arrayfields, + 'param' => $param, + 'sortfield' => $sortfield, + 'sortorder' => $sortorder, + 'totalarray' => &$totalarray, + ); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (!empty($arrayfields['c.datec']['checked'])) { + print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + } + if (!empty($arrayfields['c.tms']['checked'])) { + print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + } + if (!empty($arrayfields['c.date_cloture']['checked'])) { + print_liste_field_titre($arrayfields['c.date_cloture']['label'], $_SERVER["PHP_SELF"], "c.date_cloture", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + } + if (!empty($arrayfields['c.note_public']['checked'])) { + print_liste_field_titre($arrayfields['c.note_public']['label'], $_SERVER["PHP_SELF"], "c.note_public", "", $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['c.note_private']['checked'])) { + print_liste_field_titre($arrayfields['c.note_private']['label'], $_SERVER["PHP_SELF"], "c.note_private", "", $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['shippable']['checked'])) { + print_liste_field_titre($arrayfields['shippable']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['c.facture']['checked'])) { + print_liste_field_titre($arrayfields['c.facture']['label'], $_SERVER["PHP_SELF"], 'c.facture', '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['c.import_key']['checked'])) { + print_liste_field_titre($arrayfields['c.import_key']['label'], $_SERVER["PHP_SELF"], "c.import_key", "", $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['c.fk_statut']['checked'])) { + print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'center '); + } + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center '); + } + print ''."\n"; + + $total = 0; + $subtotal = 0; + $productstat_cache = array(); + $productstat_cachevirtual = array(); + $getNomUrl_cache = array(); + + $generic_commande = new Commande($db); + $generic_product = new Product($db); + $userstatic = new User($db); + $i = 0; + + $with_margin_info = false; + if (!empty($conf->margin->enabled) && ( + !empty($arrayfields['total_pa']['checked']) + || !empty($arrayfields['total_margin']['checked']) + || !empty($arrayfields['total_margin_rate']['checked']) + || !empty($arrayfields['total_mark_rate']['checked']) + ) + ) { + $with_margin_info = true; + } + $total_ht = 0; + $total_margin = 0; + + // Détail commande + $totalqty = 0; + + $totalarray = array(); + $totalarray['nbfield'] = 0; + $totalarray['val']['cdet.total_tva'] = 0; + $totalarray['val']['cdet.total_ttc'] = 0; + $imaxinloop = ($limit ? min($num, $limit) : $num); + while ($i < $imaxinloop) { + $obj = $db->fetch_object($resql); + + $notshippable = 0; + $warning = 0; + $text_info = ''; + $text_warning = ''; + $nbprod = 0; + + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->name_alias = $obj->alias; + $companystatic->client = $obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->email = $obj->email; + $companystatic->phone = $obj->phone; + $companystatic->address = $obj->address; + $companystatic->zip = $obj->zip; + $companystatic->town = $obj->town; + $companystatic->country_code = $obj->country_code; + if (!isset($getNomUrl_cache[$obj->socid])) { + $getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1, 'customer'); + } + + $generic_commande->id = $obj->c_rowid; + $generic_commande->ref = $obj->ref; + $generic_commande->statut = $obj->fk_statut; + $generic_commande->billed = $obj->billed; + $generic_commande->date = $db->jdate($obj->date_commande); + $generic_commande->date_livraison = $db->jdate($obj->date_delivery); // deprecated + $generic_commande->delivery_date = $db->jdate($obj->date_delivery); + $generic_commande->ref_client = $obj->ref_client; + $generic_commande->total_ht = $obj->c_total_ht; + $generic_commande->total_tva = $obj->c_total_tva; + $generic_commande->total_ttc = $obj->c_total_ttc; + $generic_commande->note_public = $obj->note_public; + $generic_commande->note_private = $obj->note_private; + + $projectstatic->id = $obj->project_id; + $projectstatic->ref = $obj->project_ref; + $projectstatic->title = $obj->project_label; + + $marginInfo = array(); + if ($with_margin_info === true) { + $generic_commande->fetch_lines(); + $marginInfo = $formmargin->getMarginInfosArray($generic_commande); + $total_ht += $obj->total_ht; + $total_margin += $marginInfo['total_margin']; + } + + print ''; + + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Détail commande + // Product Ref + if (!empty($arrayfields['pr.ref']['checked'])) { + if (!empty($obj->product_rowid)) { + $generic_product->id = $obj->product_rowid; + $generic_product->ref = $obj->product_ref; + $generic_product->label = $obj->product_label; + $generic_product->status = $obj->product_status; + $generic_product->status_buy = $obj->product_status_buy; + $generic_product->status_batch = $obj->product_batch; + $generic_product->barcode = $obj->product_barcode; + print ''; + } else { + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } + } + // Product Description + if (!empty($arrayfields['pr.desc']['checked'])) { + // print ''; + !empty($obj->product_label) ? $labelproduct = $obj->product_label : $labelproduct = $obj->description; + print ''; + + if (!$i) { + $totalarray['nbfield']++; + } + } + // Product QtyOrdered + if (!empty($arrayfields['cdet.qty']['checked'])) { + print ''; + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'cdet.qty'; + } + if (isset($totalarray['val']['cdet.qty'])) { + $totalarray['val']['cdet.qty'] += $obj->qty; + } else { + $totalarray['val']['cdet.qty'] = $obj->qty; + } + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Ref + if (!empty($arrayfields['c.ref']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Ref customer + if (!empty($arrayfields['c.ref_client']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Project ref + if (!empty($arrayfields['p.ref']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Project label + if (!empty($arrayfields['p.title']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Third party + if (!empty($arrayfields['s.nom']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Alias name + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Town + if (!empty($arrayfields['s.town']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Zip + if (!empty($arrayfields['s.zip']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // State + if (!empty($arrayfields['state.nom']['checked'])) { + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Type ent + if (!empty($arrayfields['typent.code']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Order date + if (!empty($arrayfields['c.date_commande']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Plannned date of delivery + if (!empty($arrayfields['c.date_delivery']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Shipping Method + if (!empty($arrayfields['c.fk_shipping_method']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Payment terms + if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Payment mode + if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Channel + if (!empty($arrayfields['c.fk_input_reason']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount HT + if (!empty($arrayfields['cdet.total_ht']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'cdet.total_ht'; + } + if (isset($totalarray['val']['cdet.total_ht'])) { + $totalarray['val']['cdet.total_ht'] += $obj->total_ht; + } else { + $totalarray['val']['cdet.total_ht'] = $obj->total_ht; + } + } + // Amount VAT + if (!empty($arrayfields['c.total_vat']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'cdet.total_tva'; + } + $totalarray['val']['cdet.total_tva'] += $obj->total_tva; + } + // Amount TTC + if (!empty($arrayfields['cdet.total_ttc']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'cdet.total_ttc'; + } + $totalarray['val']['cdet.total_ttc'] += $obj->total_ttc; + } + // Warehouse + if (!empty($arrayfields['c.fk_warehouse']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Currency + if (!empty($arrayfields['c.multicurrency_code']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Currency rate + if (!empty($arrayfields['c.multicurrency_tx']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount HT + if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount VAT + if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount TTC + if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + $userstatic->id = $obj->fk_user_author; + $userstatic->login = $obj->login; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; + $userstatic->email = $obj->user_email; + $userstatic->statut = $obj->user_statut; + $userstatic->entity = $obj->entity; + $userstatic->photo = $obj->photo; + $userstatic->office_phone = $obj->office_phone; + $userstatic->office_fax = $obj->office_fax; + $userstatic->user_mobile = $obj->user_mobile; + $userstatic->job = $obj->job; + $userstatic->gender = $obj->gender; + + // Author + if (!empty($arrayfields['u.login']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + if (!empty($arrayfields['sale_representative']['checked'])) { + // Sales representatives + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Total buying or cost price + if (!empty($arrayfields['total_pa']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Total margin + if (!empty($arrayfields['total_margin']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'total_margin'; + } + $totalarray['val']['total_margin'] += $marginInfo['total_margin']; + } + // Total margin rate + if (!empty($arrayfields['total_margin_rate']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Total mark rate + if (!empty($arrayfields['total_mark_rate']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate'; + } + if ($i >= $imaxinloop - 1) { + if (!empty($total_ht)) { + $totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT'); + } else { + $totalarray['val']['total_mark_rate'] = ''; + } + } + } + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Date creation + if (!empty($arrayfields['c.datec']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date modification + if (!empty($arrayfields['c.tms']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date cloture + if (!empty($arrayfields['c.date_cloture']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Note public + if (!empty($arrayfields['c.note_public']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Note private + if (!empty($arrayfields['c.note_private']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Show shippable Icon (this creates subloops, so may be slow) + if (!empty($arrayfields['shippable']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Billed + if (!empty($arrayfields['c.facture']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Import key + if (!empty($arrayfields['c.import_key']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Status + if (!empty($arrayfields['c.fk_statut']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Action column + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // $totalarray['nbfield']--; + // $totalarray['nbfield']--; + print "\n"; + + $total += $obj->total_ht; + $subtotal += $obj->total_ht; + $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 ''; + } + + $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 + print $hookmanager->resPrint; + + print '
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); + print ''; + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1); + print ''; + print '
'; + print $form->selectDate($search_dateorder_start ? $search_dateorder_start : -1, 'search_dateorder_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_dateorder_end ? $search_dateorder_end : -1, 'search_dateorder_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; + print '
'; + print '
'; + print $form->selectDate($search_datedelivery_start ? $search_datedelivery_start : -1, 'search_datedelivery_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_datedelivery_end ? $search_datedelivery_end : -1, 'search_datedelivery_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; + print '
'; + $form->selectShippingMethod($search_fk_shipping_method, 'search_fk_shipping_method', '', 1, '', 1); + print ''; + $form->select_conditions_paiements($search_fk_cond_reglement, 'search_fk_cond_reglement', 1, 1, 1); + print ''; + $form->select_types_paiements($search_fk_mode_reglement, 'search_fk_mode_reglement', '', 0, 1, 1, 0, -1); + print ''; + $form->selectInputReason($search_fk_input_reason, 'search_fk_input_reason', '', 1, '', 1); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $form->selectDate($search_datecloture_start ? $search_datecloture_start : -1, 'search_datecloture_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_datecloture_end ? $search_datecloture_end : -1, 'search_datecloture_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; + print '
'; + print ''; + print ''; + //print $form->selectyesno('search_shippable', $search_shippable, 1, 0, 1, 1); + if (!empty($conf->global->ORDER_SHIPABLE_STATUS_DISABLED_BY_DEFAULT)) { + print ''; + print $langs->trans('ShowShippableStatus'); + } else { + $show_shippable_command = 1; + } + print ''; + print $form->selectyesno('search_billed', $search_billed, 1, 0, 1, 1); + print ''; + print ''; + $liststatus = array( + Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraftShort"), + Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"), + Commande::STATUS_SHIPMENTONPROCESS=>$langs->trans("StatusOrderSentShort"), + Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"), + -3=>$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort").'+'.$langs->trans("StatusOrderDelivered"), + -2=>$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort"), + Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceledShort") + ); + print $form->selectarray('search_status', $liststatus, $search_status, -5, 0, 0, '', 0, 0, 0, '', 'maxwidth125', 1); + print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''.$generic_product->getNomUrl(1).'Ligne libre'.$obj->description.''.dol_escape_htmltag($labelproduct).''.$obj->qty.''; + print $generic_commande->getNomUrl(1, ($search_status != 2 ? 0 : $obj->fk_statut), 0, 0, 0, 1, 1); + + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->commande->multidir_output[$conf->entity].'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; + print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir); + + print ''.$obj->ref_client.''; + if ($obj->project_id > 0) { + print $projectstatic->getNomUrl(1); + } + print ''; + if ($obj->project_id > 0) { + print $projectstatic->title; + } + print ''; + print $getNomUrl_cache[$obj->socid]; + + // If module invoices enabled and user with invoice creation permissions + if (isModEnabled('facture') && !empty($conf->global->ORDER_BILLING_ALL_CUSTOMER)) { + if ($user->rights->facture->creer) { + if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0)) { + print ' '; + print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->name, 'object_bill', 'hideonsmartphone').''; + } + } + } + print ''; + print $obj->alias; + print ''; + print $obj->town; + print ''; + print $obj->zip; + print '".$obj->state_name."'; + $tmparray = getCountry($obj->fk_pays, 'all'); + print $tmparray['label']; + print ''; + if (empty($typenArray)) { + $typenArray = $formcompany->typent_array(1); + } + print $typenArray[$obj->typent_code]; + print ''; + print dol_print_date($db->jdate($obj->date_commande), 'day'); + // Warning late icon and note + if ($generic_commande->hasDelay()) { + print img_picto($langs->trans("Late").' : '.$generic_commande->showDelay(), "warning"); + } + print ''; + print dol_print_date($db->jdate($obj->date_delivery), 'dayhour'); + print ''; + $form->formSelectShippingMethod('', $obj->fk_shipping_method, 'none', 1); + print ''; + $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 0, '', 1, $obj->deposit_percent); + print ''; + $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1); + print ''; + $form->formInputReason($_SERVER['PHP_SELF'], $obj->fk_input_reason, 'none', ''); + print ''.price($obj->total_ht)."'.price($obj->total_tva)."'.price($obj->total_ttc)."'; + if ($obj->warehouse > 0) { + print img_picto('', 'stock', 'class="paddingrightonly"'); + } + $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'], $obj->warehouse, 'none'); + print "'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."'; + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); + print "'.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_vat)."'.price($obj->multicurrency_total_ttc)."'; + if ($userstatic->id) { + print $userstatic->getNomUrl(-1); + } else { + print ' '; + } + print "'; + if ($obj->socid > 0) { + $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user); + if ($listsalesrepresentatives < 0) { + dol_print_error($db); + } + $nbofsalesrepresentative = count($listsalesrepresentatives); + if ($nbofsalesrepresentative > 6) { + // We print only number + print $nbofsalesrepresentative; + } elseif ($nbofsalesrepresentative > 0) { + $j = 0; + foreach ($listsalesrepresentatives as $val) { + $userstatic->id = $val['id']; + $userstatic->lastname = $val['lastname']; + $userstatic->firstname = $val['firstname']; + $userstatic->email = $val['email']; + $userstatic->statut = $val['statut']; + $userstatic->entity = $val['entity']; + $userstatic->photo = $val['photo']; + $userstatic->login = $val['login']; + $userstatic->office_phone = $val['office_phone']; + $userstatic->office_fax = $val['office_fax']; + $userstatic->user_mobile = $val['user_mobile']; + $userstatic->job = $val['job']; + $userstatic->gender = $val['gender']; + //print '
': + print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2); + $j++; + if ($j < $nbofsalesrepresentative) { + print ' '; + } + //print '
'; + } + } + //else print $langs->trans("NoSalesRepresentativeAffected"); + } else { + print ' '; + } + print '
'.price($marginInfo['pa_total']).''.price($marginInfo['total_margin']).''.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').''.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser'); + print ''; + print dol_string_nohtmltag($obj->note_public); + print ''; + print dol_string_nohtmltag($obj->note_private); + print ''; + if (!empty($show_shippable_command) && !empty($conf->stock->enabled)) { + if (($obj->fk_statut > $generic_commande::STATUS_DRAFT) && ($obj->fk_statut < $generic_commande::STATUS_CLOSED)) { + $generic_commande->getLinesArray(); // Load array ->lines + $generic_commande->loadExpeditions(); // Load array ->expeditions + + $numlines = count($generic_commande->lines); // Loop on each line of order + for ($lig = 0; $lig < $numlines; $lig++) { + if (isset($generic_commande->expeditions[$generic_commande->lines[$lig]->id])) { + $reliquat = $generic_commande->lines[$lig]->qty - $generic_commande->expeditions[$generic_commande->lines[$lig]->id]; + } else { + $reliquat = $generic_commande->lines[$lig]->qty; + } + if ($generic_commande->lines[$lig]->product_type == 0 && $generic_commande->lines[$lig]->fk_product > 0) { // If line is a product and not a service + $nbprod++; // order contains real products + $generic_product->id = $generic_commande->lines[$lig]->fk_product; + + // Get local and virtual stock and store it into cache + if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product])) { + $generic_product->load_stock('nobatch'); // ->load_virtual_stock() is already included into load_stock() + $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_reel; + $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique; + } else { + $generic_product->stock_reel = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel']; + $generic_product->stock_theorique = $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique; + } + + if ($reliquat > $generic_product->stock_reel) { + $notshippable++; + } + if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) { // Default code. Default should be this case. + $text_info .= $reliquat.' x '.$generic_commande->lines[$lig]->product_ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 20); + $text_info .= ' - '.$langs->trans("Stock").': '.$generic_product->stock_reel.''; + $text_info .= ' - '.$langs->trans("VirtualStock").': '.$generic_product->stock_theorique.''; + $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' ('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).')' : ''); + $text_info .= '
'; + } else { // BUGGED CODE. + // DOES NOT TAKE INTO ACCOUNT MANUFACTURING. THIS CODE SHOULD BE USELESS. PREVIOUS CODE SEEMS COMPLETE. + // COUNT STOCK WHEN WE SHOULD ALREADY HAVE VALUE + // Detailed virtual stock, looks bugged, uncomplete and need heavy load. + // stock order and stock order_supplier + $stock_order = 0; + $stock_order_supplier = 0; + if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { // What about other options ? + if (!empty($conf->commande->enabled)) { + if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'])) { + $generic_product->load_stats_commande(0, '1,2'); + $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'] = $generic_product->stats_commande['qty']; + } else { + $generic_product->stats_commande['qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer']; + } + $stock_order = $generic_product->stats_commande['qty']; + } + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) { + if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'])) { + $generic_product->load_stats_commande_fournisseur(0, '3'); + $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'] = $generic_product->stats_commande_fournisseur['qty']; + } else { + $generic_product->stats_commande_fournisseur['qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier']; + } + $stock_order_supplier = $generic_product->stats_commande_fournisseur['qty']; + } + } + $text_info .= $reliquat.' x '.$generic_commande->lines[$lig]->ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 20); + $text_stock_reel = $generic_product->stock_reel.'/'.$stock_order; + if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $generic_commande->lines[$lig]->qty)) { + $warning++; + $text_warning .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; + } + if ($reliquat > $generic_product->stock_reel) { + $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; + } else { + $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; + } + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) { + $text_info .= ' '.$langs->trans('SupplierOrder').' : '.$stock_order_supplier; + } + $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' ('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).')' : ''); + $text_info .= '
'; + } + } + } + if ($notshippable == 0) { + $text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'green paddingleft'); + $text_info = $text_icon.' '.$langs->trans('Shippable').'
'.$text_info; + } else { + $text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'error paddingleft'); + $text_info = $text_icon.' '.$langs->trans('NonShippable').'
'.$text_info; + } + } + + if ($nbprod) { + print $form->textwithtooltip('', $text_info, 2, 1, $text_icon, '', 2); + } + if ($warning) { // Always false in default mode + print $form->textwithtooltip('', $langs->trans('NotEnoughForAllOrders').'
'.$text_warning, 2, 1, img_picto('', 'error'), '', 2); + } + } + print '
'.yn($obj->billed).''.$obj->import_key.''.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print '
'.$langs->trans("NoRecordFound").'
'."\n"; + print '
'; + + print '
'."\n"; + + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + $hidegeneratedfilelistifempty = 0; + } + + // Show list of available documents + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); + + $filedir = $diroutputmassaction; + $genallowed = $permissiontoread; + $delallowed = $permissiontoadd; + + print $formfile->showdocuments('massfilesarea_orders', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); +} else { + dol_print_error($db); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/commande/tpl/linkedobjectblock.tpl.php b/htdocs/commande/tpl/linkedobjectblock.tpl.php index 819a6ecb74f..a6a1fde3851 100644 --- a/htdocs/commande/tpl/linkedobjectblock.tpl.php +++ b/htdocs/commande/tpl/linkedobjectblock.tpl.php @@ -46,12 +46,12 @@ foreach ($linkedObjectBlock as $key => $objectlink) { $trclass .= ' liste_sub_total'; } echo ''; - echo ''.$langs->trans("CustomerOrder"); + echo ''.$langs->trans("CustomerOrder"); if (!empty($showImportButton) && !empty($conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES)) { print ' '; - echo ''.$objectlink->getNomUrl(1).''; + echo ''.$objectlink->getNomUrl(1).''; echo ''.$objectlink->ref_client.''; echo ''.dol_print_date($objectlink->date, 'day').''; echo ''; diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index b0514c71ee6..6c961e85af9 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -1134,8 +1134,8 @@ if ($resql) { } // Conciliated if (!empty($arrayfields['b.conciliated']['checked'])) { - print ''; - print $form->selectyesno('search_conciliated', $search_conciliated, 1, false, 1, 1); + print ''; + print $form->selectyesno('search_conciliated', $search_conciliated, 1, false, 1, 1, 'search_status onrightofpage maxwidth75'); print ''; } // Bordereau diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index a73fd2b5f2c..ab2ecf3a030 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1060,8 +1060,8 @@ class Account extends CommonObject * Adds it to non existing supplied categories. * Existing categories are left untouch. * - * @param int[]|int $categories Category or categories IDs - * @return void + * @param int[]|int $categories Category or categories IDs + * @return int <0 if KO, >0 if OK */ public function setCategories($categories) { @@ -1748,6 +1748,39 @@ class Account extends CommonObject return false; } } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + global $langs; + $return = ''; + return $return; + } } diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index c9886a176f0..537c7c9acb6 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -122,8 +122,8 @@ class BankAccounts extends DolibarrApi /** * Get account by ID. * - * @param int $id ID of account - * @return array Account object + * @param int $id ID of account + * @return Object Object with cleaned properties * * @throws RestException */ @@ -313,9 +313,9 @@ class BankAccounts extends DolibarrApi /** * Update account * - * @param int $id ID of account - * @param array $request_data data - * @return int + * @param int $id ID of account + * @param array $request_data data + * @return Object Object with cleaned properties */ public function put($id, $request_data = null) { diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 3d07c280559..857b49d1576 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -768,4 +768,41 @@ class PaymentVarious extends CommonObject } return 0; } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + global $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + if (property_exists($this, 'fk_bank')) { + $return .= ' | '.$this->fk_bank.''; + } + if (property_exists($this, 'datep')) { + $return .= '
'.$langs->trans("Date").' : '.dol_print_date($this->db->jdate($this->datep), 'day').''; + } + if (property_exists($this, 'type_payment') && !empty($this->type_payment)) { + $return .= '
'.$langs->trans("Payment", $this->type_payment).' : '.$this->type_payment.''; + } + if (property_exists($this, 'accountancy_code')) { + $return .= '
'.$langs->trans("Account").' : '.$this->accountancy_code.''; + } + if (property_exists($this, 'amount')) { + $return .= '
'.$langs->trans("Debit").' : '.price($this->amount).''; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index c11e13f1e71..490107e4893 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -458,7 +458,7 @@ if ($result < 0) { if ($day > ($max + 86400)) { $datas[$i] = ''; // Valeur speciale permettant de ne pas tracer le graph } else { - $datas[$i] = 0 + $solde + $subtotal; + $datas[$i] = $solde + $subtotal; } $datamin[$i] = $object->min_desired; $dataall[$i] = $object->min_allowed; diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 38b666cc2ef..2a0995af009 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -52,6 +52,7 @@ $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'bankaccountlist'; // To manage different context of search +$mode = GETPOST('mode', 'alpha'); $search_ref = GETPOST('search_ref', 'alpha'); $search_label = GETPOST('search_label', 'alpha'); @@ -305,6 +306,9 @@ llxHeader('', $title, $help_url); $arrayofselected = is_array($toselect) ? $toselect : array(); $param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -365,8 +369,13 @@ print ''; print ''; print ''; +print ''; -$newcardbutton = dolGetButtonTitle($langs->trans('NewFinancialAccount'), '', 'fa fa-plus-circle', 'card.php?action=create', '', $user->rights->banque->configurer); + +$newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('NewFinancialAccount'), '', 'fa fa-plus-circle', 'card.php?action=create', '', $user->rights->banque->configurer); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bank_account', 0, $newcardbutton, '', $limit, 1); @@ -483,7 +492,7 @@ if (!empty($arrayfields['b.tms']['checked'])) { } // Status if (!empty($arrayfields['b.clos']['checked'])) { - print ''; + print ''; $array = array( 'opened'=>$langs->trans("Opened"), 'closed'=>$langs->trans("Closed") @@ -584,224 +593,236 @@ foreach ($accounts as $key => $type) { $lastcurrencycode = $objecttmp->currency_code; } - print ''; - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($objecttmp->id, $arrayofselected)) { - $selected = 1; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + print '
'; + } + // Output Kanban + print $objecttmp->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print '
'; + print ''; + } + } else { + print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($objecttmp->id, $arrayofselected)) { + $selected = 1; + } + print ''; } - print ''; + print ''; } - print ''; - } - // Ref - if (!empty($arrayfields['b.ref']['checked'])) { - print ''.$objecttmp->getNomUrl(1).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Label - if (!empty($arrayfields['b.label']['checked'])) { - print ''.dol_escape_htmltag($objecttmp->label).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Account type - if (!empty($arrayfields['accountype']['checked'])) { - print ''; - print $objecttmp->type_lib[$objecttmp->type]; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Number - if (!empty($arrayfields['b.number']['checked'])) { - print ''.dol_escape_htmltag($objecttmp->number).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Account number - if (!empty($arrayfields['b.account_number']['checked'])) { - print ''; - if (isModEnabled('accounting') && !empty($objecttmp->account_number)) { - $accountingaccount = new AccountingAccount($db); - $accountingaccount->fetch('', $objecttmp->account_number, 1); - print ''; - print $accountingaccount->getNomUrl(0, 1, 1, '', 0); - print ''; - } else { - print ''.$objecttmp->account_number.''; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Accountancy journal - if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) { - print ''; - if (isModEnabled('accounting')) { - if (empty($objecttmp->fk_accountancy_journal)) { - print img_warning($langs->trans("Mandatory")); - } else { - $accountingjournal = new AccountingJournal($db); - $accountingjournal->fetch($objecttmp->fk_accountancy_journal); - print $accountingjournal->getNomUrl(0, 1, 1, '', 1); + // Ref + if (!empty($arrayfields['b.ref']['checked'])) { + print ''.$objecttmp->getNomUrl(1).''; + if (!$i) { + $totalarray['nbfield']++; } - } else { - print ''; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Currency - if (!empty($arrayfields['b.currency_code']['checked'])) { - print ''; - print $objecttmp->currency_code; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Transactions to reconcile - if (!empty($arrayfields['toreconcile']['checked'])) { - $conciliate = $objecttmp->canBeConciliated(); - - $labeltoshow = ''; - if ($conciliate == -2) { - $labeltoshow = $langs->trans("CashAccount"); - } elseif ($conciliate == -3) { - $labeltoshow = $langs->trans("Closed"); - } elseif (empty($objecttmp->rappro)) { - $labeltoshow = $langs->trans("ConciliationDisabled"); } - print ''; - if ($conciliate == -2) { - print ''.$langs->trans("CashAccount").''; - } elseif ($conciliate == -3) { - print ''.$langs->trans("Closed").''; - } elseif (empty($objecttmp->rappro)) { - print ''.$langs->trans("ConciliationDisabled").''; - } else { - $result = $objecttmp->load_board($user, $objecttmp->id); - if (is_numeric($result) && $result < 0) { - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - } else { - print '
'; - print ''; - print $result->nbtodo; + // Label + if (!empty($arrayfields['b.label']['checked'])) { + print ''.dol_escape_htmltag($objecttmp->label).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Account type + if (!empty($arrayfields['accountype']['checked'])) { + print ''; + print $objecttmp->type_lib[$objecttmp->type]; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Number + if (!empty($arrayfields['b.number']['checked'])) { + print ''.dol_escape_htmltag($objecttmp->number).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Account number + if (!empty($arrayfields['b.account_number']['checked'])) { + print ''; + if (isModEnabled('accounting') && !empty($objecttmp->account_number)) { + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch('', $objecttmp->account_number, 1); + print ''; + print $accountingaccount->getNomUrl(0, 1, 1, '', 0); print ''; - print ''; - if ($result->nbtodolate) { - print ''; - print ' '.$result->nbtodolate; + } else { + print ''.$objecttmp->account_number.''; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Accountancy journal + if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) { + print ''; + if (isModEnabled('accounting')) { + if (empty($objecttmp->fk_accountancy_journal)) { + print img_warning($langs->trans("Mandatory")); + } else { + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($objecttmp->fk_accountancy_journal); + print $accountingjournal->getNomUrl(0, 1, 1, '', 1); + } + } else { + print ''; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Currency + if (!empty($arrayfields['b.currency_code']['checked'])) { + print ''; + print $objecttmp->currency_code; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Transactions to reconcile + if (!empty($arrayfields['toreconcile']['checked'])) { + $conciliate = $objecttmp->canBeConciliated(); + + $labeltoshow = ''; + if ($conciliate == -2) { + $labeltoshow = $langs->trans("CashAccount"); + } elseif ($conciliate == -3) { + $labeltoshow = $langs->trans("Closed"); + } elseif (empty($objecttmp->rappro)) { + $labeltoshow = $langs->trans("ConciliationDisabled"); + } + + print ''; + if ($conciliate == -2) { + print ''.$langs->trans("CashAccount").''; + } elseif ($conciliate == -3) { + print ''.$langs->trans("Closed").''; + } elseif (empty($objecttmp->rappro)) { + print ''.$langs->trans("ConciliationDisabled").''; + } else { + $result = $objecttmp->load_board($user, $objecttmp->id); + if (is_numeric($result) && $result < 0) { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + } else { + print ''; + print ''; + print $result->nbtodo; print ''; + print ''; + if ($result->nbtodolate) { + print ''; + print ' '.$result->nbtodolate; + print ''; + } } } - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Extra fields - if (is_array($objecttmp->array_options)) { - $obj = new stdClass(); - foreach ($objecttmp->array_options as $k => $v) { - $obj->$k = $v; - } - } - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objecttmp, $action); // Note that $action and $objecttmpect may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['b.datec']['checked'])) { - print ''; - print dol_print_date($objecttmp->date_creation, 'dayhour'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['b.tms']['checked'])) { - print ''; - print dol_print_date($objecttmp->date_update, 'dayhour'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Status - if (!empty($arrayfields['b.clos']['checked'])) { - print ''.$objecttmp->getLibStatut(5).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Balance - if (!empty($arrayfields['balance']['checked'])) { - print ''; - print ''; - print ''.price($solde, 0, $langs, 1, -1, -1, $objecttmp->currency_code).''; - print ''; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'balance'; - } - $totalarray['val']['balance'] += $solde; - } - - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($objecttmp->id, $arrayofselected)) { - $selected = 1; + print ''; + if (!$i) { + $totalarray['nbfield']++; } - print ''; } - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } - print ''; + // Extra fields + if (is_array($objecttmp->array_options)) { + $obj = new stdClass(); + foreach ($objecttmp->array_options as $k => $v) { + $obj->$k = $v; + } + } + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objecttmp, $action); // Note that $action and $objecttmpect may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['b.datec']['checked'])) { + print ''; + print dol_print_date($objecttmp->date_creation, 'dayhour'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date modification + if (!empty($arrayfields['b.tms']['checked'])) { + print ''; + print dol_print_date($objecttmp->date_update, 'dayhour'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } - if (empty($total[$objecttmp->currency_code])) { - $total[$objecttmp->currency_code] = $solde; - } else { - $total[$objecttmp->currency_code] += $solde; + // Status + if (!empty($arrayfields['b.clos']['checked'])) { + print ''.$objecttmp->getLibStatut(5).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Balance + if (!empty($arrayfields['balance']['checked'])) { + print ''; + print ''; + print ''.price($solde, 0, $langs, 1, -1, -1, $objecttmp->currency_code).''; + print ''; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'balance'; + } + $totalarray['val']['balance'] += $solde; + } + + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($objecttmp->id, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } + + print ''; + + if (empty($total[$objecttmp->currency_code])) { + $total[$objecttmp->currency_code] = $solde; + } else { + $total[$objecttmp->currency_code] += $solde; + } } - $i++; } diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index d3e573f21bf..e75402ba429 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -353,10 +353,10 @@ if (GETPOST("account") || GETPOST("ref")) { print "".$refcomp.""; if ($tmpobj->total_ttc < 0) { print ''.price(abs($total_ttc))." "; - }; + } if ($tmpobj->total_ttc >= 0) { print ' '.price($total_ttc).""; - }; + } print ''.price($solde).''; print ""; } diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index 0721aeb7ef0..70abe873cba 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -29,6 +29,7 @@ require '../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; @@ -45,6 +46,7 @@ if ($user->socid) { } $optioncss = GETPOST('optioncss', 'alpha'); +$mode = GETPOST('mode', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $search_ref = GETPOST('search_ref', 'int'); @@ -312,6 +314,9 @@ if ($resql) { $total = 0; $param = ''; + if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); + } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -362,7 +367,10 @@ if ($resql) { if (!empty($socid)) { $url .= '&socid='.urlencode($socid); } - $newcardbutton = dolGetButtonTitle($langs->trans('MenuNewVariousPayment'), '', 'fa fa-plus-circle', $url, '', $user->rights->banque->modifier); + $newcardbutton = ''; + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('MenuNewVariousPayment'), '', 'fa fa-plus-circle', $url, '', $user->rights->banque->modifier); print '
'; @@ -375,6 +383,8 @@ if ($resql) { print ''; print ''; print ''; + print ''; + print_barre_liste($langs->trans("MenuVariousPayment"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'object_payment', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -568,166 +578,187 @@ if ($resql) { $variousstatic->id = $obj->rowid; $variousstatic->ref = $obj->rowid; $variousstatic->label = $obj->label; + $variousstatic->datep = $obj->datep; + $variousstatic->type_payment = $obj->payment_code; + $bankline->fetch($obj->fk_bank); + $variousstatic->fk_bank = $bankline->getNomUrl(1); + $variousstatic->amount = $obj->amount; - print ''; + $accountingaccount->fetch('', $obj->accountancy_code, 1); + $variousstatic->accountancy_code = $accountingaccount->getNomUrl(0, 0, 1, $obj->accountingaccount, 1); - // No - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { - print ''.(($offset * $limit) + $i).''; - } - - // Ref - if ($arrayfields['ref']['checked']) { - print ''.$variousstatic->getNomUrl(1).""; - if (!$i) { - $totalarray['nbfield']++; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + print '
'; } - } + // Output Kanban - // Label payment - if ($arrayfields['label']['checked']) { - print ''.$variousstatic->label.""; - if (!$i) { - $totalarray['nbfield']++; + print $variousstatic->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print '
'; + print ''; } - } + } else { + print ''; - // Date payment - if ($arrayfields['datep']['checked']) { - print ''.dol_print_date($obj->datep, 'day').""; - if (!$i) { - $totalarray['nbfield']++; + // No + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { + print ''.(($offset * $limit) + $i).''; } - } - - // Date value - if ($arrayfields['datev']['checked']) { - print ''.dol_print_date($obj->datev, 'day').""; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Type - if ($arrayfields['type']['checked']) { - print ''; - if ($obj->payment_code) { - print $langs->trans("PaymentTypeShort".$obj->payment_code); - print ' '; - } - print $obj->num_payment; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Project - if ($arrayfields['project']['checked']) { - print ''; - if ($obj->fk_project > 0) { - $proj->fetch($obj->fk_project); - print $proj->getNomUrl(1); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Bank account - if ($arrayfields['bank']['checked']) { - print ''; - if ($obj->bid > 0) { - $accountstatic->id = $obj->bid; - $accountstatic->ref = $obj->bref; - $accountstatic->number = $obj->bnumber; - - if (isModEnabled('accounting')) { - $accountstatic->account_number = $obj->bank_account_number; - $accountingjournal->fetch($obj->accountancy_journal); - $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); + // Ref + if ($arrayfields['ref']['checked']) { + print ''.$variousstatic->getNomUrl(1).""; + if (!$i) { + $totalarray['nbfield']++; } - - $accountstatic->label = $obj->blabel; - print $accountstatic->getNomUrl(1); - } else { - print ' '; } - print ''; + + // Label payment + if ($arrayfields['label']['checked']) { + print ''.$variousstatic->label.""; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date payment + if ($arrayfields['datep']['checked']) { + print ''.dol_print_date($obj->datep, 'day').""; + if (!$i) { + $totalarray['nbfield']++; + } + } + + + // Date value + if ($arrayfields['datev']['checked']) { + print ''.dol_print_date($obj->datev, 'day').""; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Type + if ($arrayfields['type']['checked']) { + print ''; + if ($obj->payment_code) { + print $langs->trans("PaymentTypeShort".$obj->payment_code); + print ' '; + } + print $obj->num_payment; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Project + if ($arrayfields['project']['checked']) { + print ''; + if ($obj->fk_project > 0) { + $proj->fetch($obj->fk_project); + print $proj->getNomUrl(1); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Bank account + if ($arrayfields['bank']['checked']) { + print ''; + if ($obj->bid > 0) { + $accountstatic->id = $obj->bid; + $accountstatic->ref = $obj->bref; + $accountstatic->number = $obj->bnumber; + + if (isModEnabled('accounting')) { + $accountstatic->account_number = $obj->bank_account_number; + $accountingjournal->fetch($obj->accountancy_journal); + $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); + } + + $accountstatic->label = $obj->blabel; + print $accountstatic->getNomUrl(1); + } else { + print ' '; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Bank entry + if ($arrayfields['entry']['checked']) { + $bankline->fetch($obj->fk_bank); + print ''.$bankline->getNomUrl(1).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Accounting account + if (!empty($arrayfields['account']['checked'])) { + $accountingaccount->fetch('', $obj->accountancy_code, 1); + + print ''.$accountingaccount->getNomUrl(0, 1, 1, '', 1).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Accounting subledger account + if (!empty($arrayfields['subledger']['checked'])) { + print ''.length_accounta($obj->subledger_account).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Debit + if ($arrayfields['debit']['checked']) { + print ''; + if ($obj->sens == 0) { + print ''.price($obj->amount).''; + $totalarray['val']['total_deb'] += $obj->amount; + } + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'total_deb'; + } + print ''; + } + + // Credit + if ($arrayfields['credit']['checked']) { + print ''; + if ($obj->sens == 1) { + print ''.price($obj->amount).''; + $totalarray['val']['total_cred'] += $obj->amount; + } + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'total_cred'; + } + print ''; + } + + print ''; + if (!$i) { $totalarray['nbfield']++; } + + print ''."\n"; } - - // Bank entry - if ($arrayfields['entry']['checked']) { - $bankline->fetch($obj->fk_bank); - print ''.$bankline->getNomUrl(1).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Accounting account - if (!empty($arrayfields['account']['checked'])) { - $accountingaccount->fetch('', $obj->accountancy_code, 1); - - print ''.$accountingaccount->getNomUrl(0, 1, 1, '', 1).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Accounting subledger account - if (!empty($arrayfields['subledger']['checked'])) { - print ''.length_accounta($obj->subledger_account).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Debit - if ($arrayfields['debit']['checked']) { - print ''; - if ($obj->sens == 0) { - print ''.price($obj->amount).''; - $totalarray['val']['total_deb'] += $obj->amount; - } - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'total_deb'; - } - print ''; - } - - // Credit - if ($arrayfields['credit']['checked']) { - print ''; - if ($obj->sens == 1) { - print ''.price($obj->amount).''; - $totalarray['val']['total_cred'] += $obj->amount; - } - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'total_cred'; - } - print ''; - } - - print ''; - - if (!$i) { - $totalarray['nbfield']++; - } - - print ''."\n"; - $i++; } diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php index 7d433282367..a1e5dae0c91 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_list.php +++ b/htdocs/compta/cashcontrol/cashcontrol_list.php @@ -41,7 +41,7 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'cashcontrol'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') - +$mode = GETPOST('mode', 'alpha'); // for mode view result $id = GETPOST('id', 'int'); // Load variable for pagination @@ -399,10 +399,14 @@ print ''; print ''; print ''; print ''; +print ''; $permforcashfence = 1; -$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permforcashfence); +$newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permforcashfence); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'cash-register', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -552,81 +556,101 @@ while ($i < ($limit ? min($num, $limit) : $num)) { // Store properties in $object $object->setVarsFromFetchObj($obj); - // Show here line of result - $j = 0; - print ''; - foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; + // show kanban result + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + print '
'; } - if (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif ($key == 'ref') { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } + $object->posmodule = $obj->posmodule; + $object->cash = $obj->cash; + $object->opening = $obj->opening; + $object->year_close = $obj->year_close; + $object->cheque = $obj->cheque; - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) { - $cssforfield .= ($cssforfield ? ' ' : '').'right'; - } - //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; - if (!empty($arrayfields['t.'.$key]['checked'])) { - print 'getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print '
'; + print ''; + } + } else { + // Show here line of result + $j = 0; + print ''; + foreach ($object->fields as $key => $val) { + $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; } - print '>'; - if ($key == 'status') { - print $object->getLibStatut(5); - } elseif ($key == 'rowid') { - print $object->showOutputField($val, $key, $object->id, ''); - } else { - print $object->showOutputField($val, $key, $object->$key, ''); + + if (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif ($key == 'ref') { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; } - print ''; - if (!$i) { - $totalarray['nbfield']++; + + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; } - if (!empty($val['isameasure']) && $val['isameasure'] == 1) { + //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; + + if (!empty($arrayfields['t.'.$key]['checked'])) { + print ''; + if ($key == 'status') { + print $object->getLibStatut(5); + } elseif ($key == 'rowid') { + print $object->showOutputField($val, $key, $object->id, ''); + } else { + print $object->showOutputField($val, $key, $object->$key, ''); + } + print ''; if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + $totalarray['nbfield']++; } - if (!isset($totalarray['val'])) { - $totalarray['val'] = array(); + if (!empty($val['isameasure']) && $val['isameasure'] == 1) { + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + } + if (!isset($totalarray['val'])) { + $totalarray['val'] = array(); + } + if (!isset($totalarray['val']['t.'.$key])) { + $totalarray['val']['t.'.$key] = 0; + } + $totalarray['val']['t.'.$key] += $object->$key; } - if (!isset($totalarray['val']['t.'.$key])) { - $totalarray['val']['t.'.$key] = 0; - } - $totalarray['val']['t.'.$key] += $object->$key; } } - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Action column - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($object->id, $arrayofselected)) { - $selected = 1; + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Action column + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($object->id, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; } - print ''; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - - print ''."\n"; + print ''."\n"; + } $i++; } diff --git a/htdocs/compta/cashcontrol/class/cashcontrol.class.php b/htdocs/compta/cashcontrol/class/cashcontrol.class.php index bc45f3b417d..01bebc35f5d 100644 --- a/htdocs/compta/cashcontrol/class/cashcontrol.class.php +++ b/htdocs/compta/cashcontrol/class/cashcontrol.class.php @@ -469,4 +469,36 @@ class CashControl extends CommonObject return $result; } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + global $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + //var_dump($this->fields['rowid']);exit; + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1, 1) : $this->ref).''; + if (property_exists($this, 'posmodule')) { + $return .= '
'.substr($langs->trans("Module/Application"), 0, 12).' : '.$this->posmodule.''; + } + if (property_exists($this, 'year_close')) { + $return .= '
'.$langs->trans("Year").' : '.$this->year_close.''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 64a37dcbed4..7896b26e8b0 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -271,7 +271,7 @@ if (empty($reshook)) { } // Delete - if ($action == 'confirm_deleteinvoice' && $confirm == 'yes' && $user->rights->facture->supprimer) { + if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture->supprimer) { $object->delete($user); header("Location: ".DOL_URL_ROOT.'/compta/facture/invoicetemplate_list.php'); @@ -1175,8 +1175,8 @@ if ($action == 'create') { } // Confirm delete of repeatable invoice - if ($action == 'ask_deleteinvoice') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteRepeatableInvoice'), $langs->trans('ConfirmDeleteRepeatableInvoice'), 'confirm_deleteinvoice', '', 'no', 1); + if ($action == 'delete') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteRepeatableInvoice'), $langs->trans('ConfirmDeleteRepeatableInvoice'), 'confirm_delete', '', 'no', 1); } // Call Hook formConfirm @@ -1635,7 +1635,7 @@ if ($action == 'create') { // Show object lines if (!empty($object->lines)) { $canchangeproduct = 1; - $ret = $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice + $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice } // Form to add new line diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index e28e5427c0b..5f24ca87830 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2038,12 +2038,12 @@ if (empty($reshook)) { $prod_entry_mode = GETPOST('prod_entry_mode', 'aZ09'); if ($prod_entry_mode == 'free') { $idprod = 0; - $tva_tx = (GETPOST('tva_tx', 'alpha') ? price2num(preg_replace('/\s*\(.*\)/', '', GETPOST('tva_tx', 'alpha'))) : 0); } else { $idprod = GETPOST('idprod', 'int'); - $tva_tx = ''; } + $tva_tx = GETPOST('tva_tx', 'alpha'); + $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS', 2); $remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef, 'alpha'), '', 2) : 0); if (empty($remise_percent)) { @@ -2137,7 +2137,6 @@ if (empty($reshook)) { // Ecrase $pu par celui du produit // Ecrase $desc par celui du produit - // Ecrase $tva_tx par celui du produit // Ecrase $base_price_type par celui du produit // Replaces $fk_unit with the product's if (!empty($idprod) && $idprod > 0) { @@ -2157,8 +2156,8 @@ if (empty($reshook)) { $price_min_ttc = $datapriceofproduct['price_min_ttc']; $price_base_type = $datapriceofproduct['price_base_type']; - $tva_tx = $datapriceofproduct['tva_tx']; - $tva_npr = $datapriceofproduct['tva_npr']; + //$tva_tx = $datapriceofproduct['tva_tx']; + //$tva_npr = $datapriceofproduct['tva_npr']; $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); @@ -3067,8 +3066,8 @@ if ($action == 'create') { $remise_absolue = (!empty($expesrc->remise_absolue) ? $expesrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); if (isModEnabled('multicurrency')) { - $currency_code = (!empty($expesrc->currency_code) ? $expesrc->currency_code : (!empty($soc->currency_code) ? $soc->currency_code : $objectsrc->multicurrency_code)); - $currency_tx = (!empty($expesrc->currency_tx) ? $expesrc->currency_tx : (!empty($soc->currency_tx) ? $soc->currency_tx : $objectsrc->currency_tx)); + $currency_code = (!empty($expesrc->multicurrency_code) ? $expesrc->multicurrency_code : (!empty($soc->multicurrency_code) ? $soc->multicurrency_code : $objectsrc->multicurrency_code)); + $currency_tx = (!empty($expesrc->multicurrency_tx) ? $expesrc->multicurrency_tx : (!empty($soc->multicurrency_tx) ? $soc->multicurrency_tx : $objectsrc->multicurrency_tx)); } //Replicate extrafields @@ -3357,7 +3356,7 @@ if ($action == 'create') { jQuery(".checkforselect").prop("disabled", false); jQuery(".checkforselect").prop("checked", true); } - }; + } }); '; @@ -3780,7 +3779,7 @@ if ($action == 'create') { if ($soc->fetch_optionals() > 0) { $object->array_options = array_merge($object->array_options, $soc->array_options); } - }; + } print $object->showOptionals($extrafields, 'create', $parameters); } @@ -4678,16 +4677,16 @@ if ($action == 'create') { if ($displayWarranty) { // Retained Warranty print ''; - print ''; - print '
'; - print '
'; + print ''; - if ($action != 'editretainedwarranty' && $user->rights->facture->creer) { + if ($action != 'editretainedwarranty' && $user->rights->facture->creer && $object->statut == Facture::STATUS_DRAFT) { print ''; } print '
'; print $langs->trans('RetainedWarranty'); print 'id.'">'.img_edit($langs->trans('setretainedwarranty'), 1).'
'; print '
'; - if ($action == 'editretainedwarranty') { + if ($action == 'editretainedwarranty' && $object->statut == Facture::STATUS_DRAFT) { print ''; print ''; print ''; @@ -4704,7 +4703,7 @@ if ($action == 'create') { print ''; - if ($action != 'editretainedwarrantypaymentterms' && $user->rights->facture->creer) { + if ($action != 'editretainedwarrantypaymentterms' && $user->rights->facture->creer && $object->statut == Facture::STATUS_DRAFT) { print ''; } @@ -4715,7 +4714,7 @@ if ($action == 'create') { $defaultDate = $object->date; } - if ($action == 'editretainedwarrantypaymentterms') { + if ($action == 'editretainedwarrantypaymentterms' && $object->statut == Facture::STATUS_DRAFT) { //date('Y-m-d',$object->date_lim_reglement) print ''; print ''; @@ -4739,7 +4738,7 @@ if ($action == 'create') { print '
'; print $langs->trans('PaymentConditionsShortRetainedWarranty'); print 'id.'">'.img_edit($langs->trans('setPaymentConditionsShortRetainedWarranty'), 1).'
'; - if ($action != 'editretainedwarrantydatelimit' && $user->rights->facture->creer) { + if ($action != 'editretainedwarrantydatelimit' && $user->rights->facture->creer && $object->statut == Facture::STATUS_DRAFT) { print ''; } @@ -4750,7 +4749,7 @@ if ($action == 'create') { $defaultDate = $object->date; } - if ($action == 'editretainedwarrantydatelimit') { + if ($action == 'editretainedwarrantydatelimit' && $object->statut == Facture::STATUS_DRAFT) { //date('Y-m-d',$object->date_lim_reglement) print ''; print ''; @@ -5423,7 +5422,7 @@ if ($action == 'create') { // Show object lines if (!empty($object->lines)) { - $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); + $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); } // Form to add new line diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 4c1392e28eb..bae53bce6a8 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -65,9 +65,9 @@ class Invoices extends DolibarrApi * * Return an array with invoice informations * - * @param int $id ID of invoice - * @param int $contact_list 0:Return array contains all properties, 1:Return array contains just id, -1: Do not return contacts/adddesses - * @return array|mixed data without useless information + * @param int $id ID of invoice + * @param int $contact_list 0:Return array contains all properties, 1:Return array contains just id, -1: Do not return contacts/adddesses + * @return Object Object with cleaned properties * * @throws RestException */ @@ -81,9 +81,9 @@ class Invoices extends DolibarrApi * * Return an array with invoice informations * - * @param string $ref Ref of object - * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses - * @return array|mixed data without useless information + * @param string $ref Ref of object + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses + * @return Object Object with cleaned properties * * @url GET ref/{ref} * @@ -99,9 +99,9 @@ class Invoices extends DolibarrApi * * Return an array with invoice informations * - * @param string $ref_ext External reference of object - * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses - * @return array|mixed data without useless information + * @param string $ref_ext External reference of object + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses + * @return Object Object with cleaned properties * * @url GET ref_ext/{ref_ext} * @@ -117,11 +117,11 @@ class Invoices extends DolibarrApi * * Return an array with invoice informations * - * @param int $id ID of order - * @param string $ref Ref of object - * @param string $ref_ext External reference of object - * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses - * @return array|mixed data without useless information + * @param int $id ID of order + * @param string $ref Ref of object + * @param string $ref_ext External reference of object + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses + * @return Object Object with cleaned properties * * @throws RestException */ @@ -325,12 +325,11 @@ class Invoices extends DolibarrApi /** * Create an invoice using an existing order. * - * * @param int $orderid Id of the order + * @return Object Object with cleaned properties * * @url POST /createfromorder/{orderid} * - * @return int * @throws RestException 400 * @throws RestException 401 * @throws RestException 404 @@ -338,7 +337,6 @@ class Invoices extends DolibarrApi */ public function createInvoiceFromOrder($orderid) { - require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; if (!DolibarrApiAccess::$user->rights->commande->lire) { @@ -368,11 +366,10 @@ class Invoices extends DolibarrApi /** * Get lines of an invoice * - * @param int $id Id of invoice + * @param int $id Id of invoice + * @return array Array of lines * * @url GET {id}/lines - * - * @return int */ public function getLines($id) { @@ -399,14 +396,13 @@ class Invoices extends DolibarrApi /** * Update a line to a given invoice * - * @param int $id Id of invoice to update - * @param int $lineid Id of line to update - * @param array $request_data InvoiceLine data + * @param int $id Id of invoice to update + * @param int $lineid Id of line to update + * @param array $request_data InvoiceLine data + * @return Object Object with cleaned properties * * @url PUT {id}/lines/{lineid} * - * @return array - * * @throws RestException 304 * @throws RestException 401 * @throws RestException 404 Invoice not found @@ -472,14 +468,13 @@ class Invoices extends DolibarrApi /** * Add a contact type of given invoice * - * @param int $id Id of invoice to update - * @param int $contactid Id of contact to add - * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER) + * @param int $id Id of invoice to update + * @param int $contactid Id of contact to add + * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER) + * @return array * * @url POST {id}/contact/{contactid}/{type} * - * @return int - * * @throws RestException 401 * @throws RestException 404 */ @@ -509,20 +504,24 @@ class Invoices extends DolibarrApi throw new RestException(500, 'Error when added the contact'); } - return $this->_cleanObjectDatas($this->invoice); + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Contact linked to the invoice' + ) + ); } /** * Delete a contact type of given invoice * - * @param int $id Id of invoice to update - * @param int $contactid Row key of the contact in the array contact_ids. - * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER). + * @param int $id Id of invoice to update + * @param int $contactid Row key of the contact in the array contact_ids. + * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER). + * @return Object Object with cleaned properties * * @url DELETE {id}/contact/{contactid}/{type} * - * @return array - * * @throws RestException 401 * @throws RestException 404 * @throws RestException 500 System error @@ -561,13 +560,12 @@ class Invoices extends DolibarrApi /** * Deletes a line of a given invoice * - * @param int $id Id of invoice - * @param int $lineid Id of the line to delete + * @param int $id Id of invoice + * @param int $lineid Id of the line to delete + * @return Object Object with cleaned properties * * @url DELETE {id}/lines/{lineid} * - * @return array - * * @throws RestException 400 * @throws RestException 401 * @throws RestException 404 @@ -575,7 +573,6 @@ class Invoices extends DolibarrApi */ public function deleteLine($id, $lineid) { - if (!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } @@ -592,9 +589,7 @@ class Invoices extends DolibarrApi throw new RestException(404, 'Invoice not found'); } - // TODO Check the lineid $lineid is a line of ojbect - - $updateRes = $this->invoice->deleteline($lineid); + $updateRes = $this->invoice->deleteline($lineid, $id); if ($updateRes > 0) { return $this->get($id); } else { @@ -605,9 +600,9 @@ class Invoices extends DolibarrApi /** * Update invoice * - * @param int $id Id of invoice to update - * @param array $request_data Datas - * @return int + * @param int $id Id of invoice to update + * @param array $request_data Datas + * @return Object|false Object with cleaned properties */ public function put($id, $request_data = null) { @@ -648,8 +643,8 @@ class Invoices extends DolibarrApi /** * Delete invoice * - * @param int $id Invoice ID - * @return array + * @param int $id Invoice ID + * @return array */ public function delete($id) { @@ -829,11 +824,10 @@ class Invoices extends DolibarrApi * * @param int $id Order ID * @param int $idwarehouse Warehouse ID + * @return Object Object with cleaned properties * * @url POST {id}/settodraft * - * @return array - * * @throws RestException 304 * @throws RestException 401 * @throws RestException 404 @@ -887,10 +881,9 @@ class Invoices extends DolibarrApi * @param int $id Invoice ID * @param int $idwarehouse Warehouse ID * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return Object|false Object with cleaned properties * * @url POST {id}/validate - * - * @return array */ public function validate($id, $idwarehouse = 0, $notrigger = 0) { @@ -932,11 +925,10 @@ class Invoices extends DolibarrApi * @param int $id Order ID * @param string $close_code Code filled if we classify to 'Paid completely' when payment is not complete (for escompte for example) * @param string $close_note Comment defined if we classify to 'Paid' when payment is not complete (for escompte for example) + * @return Object Object with cleaned properties * * @url POST {id}/settopaid * - * @return array An invoice object - * * @throws RestException 304 * @throws RestException 401 * @throws RestException 404 @@ -981,12 +973,11 @@ class Invoices extends DolibarrApi /** * Sets an invoice as unpaid * - * @param int $id Order ID + * @param int $id Order ID + * @return Object Object with cleaned properties * * @url POST {id}/settounpaid * - * @return array An invoice object - * * @throws RestException 304 * @throws RestException 401 * @throws RestException 404 @@ -1031,10 +1022,9 @@ class Invoices extends DolibarrApi * Get discount from invoice * * @param int $id Id of invoice + * @return Object Object with cleaned properties * * @url GET {id}/discount - * - * @return mixed */ public function getDiscount($id) { @@ -1069,10 +1059,10 @@ class Invoices extends DolibarrApi /** * Create a discount (credit available) for a credit note or a deposit. * - * @param int $id Invoice ID - * @url POST {id}/markAsCreditAvailable + * @param int $id Invoice ID + * @return Object Object with cleaned properties * - * @return array An invoice object + * @url POST {id}/markAsCreditAvailable * * @throws RestException 304 * @throws RestException 401 @@ -1241,11 +1231,10 @@ class Invoices extends DolibarrApi * * @param int $id Id of invoice * @param int $discountid Id of discount + * @return int * * @url POST {id}/usediscount/{discountid} * - * @return int - * * @throws RestException 400 * @throws RestException 401 * @throws RestException 404 @@ -1253,7 +1242,6 @@ class Invoices extends DolibarrApi */ public function useDiscount($id, $discountid) { - if (!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } @@ -1288,11 +1276,10 @@ class Invoices extends DolibarrApi * * @param int $id Id of invoice * @param int $discountid Id of a discount coming from a credit note + * @return int * * @url POST {id}/usecreditnote/{discountid} * - * @return int - * * @throws RestException 400 * @throws RestException 401 * @throws RestException 404 @@ -1300,7 +1287,6 @@ class Invoices extends DolibarrApi */ public function useCreditNote($id, $discountid) { - require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; if (!DolibarrApiAccess::$user->rights->facture->creer) { @@ -1333,12 +1319,11 @@ class Invoices extends DolibarrApi /** * Get list of payments of a given invoice * - * @param int $id Id of invoice + * @param int $id Id of invoice + * @return array * * @url GET {id}/payments * - * @return array - * * @throws RestException 400 * @throws RestException 401 * @throws RestException 404 @@ -1395,8 +1380,6 @@ class Invoices extends DolibarrApi */ public function addPayment($id, $datepaye, $paymentid, $closepaidinvoices, $accountid, $num_payment = '', $comment = '', $chqemetteur = '', $chqbank = '') { - global $conf; - require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; if (!DolibarrApiAccess::$user->rights->facture->creer) { @@ -1509,6 +1492,7 @@ class Invoices extends DolibarrApi * @url POST /paymentsdistributed * * @return int Payment ID + * * @throws RestException 400 * @throws RestException 401 * @throws RestException 403 @@ -1516,8 +1500,6 @@ class Invoices extends DolibarrApi */ public function addPaymentDistributed($arrayofamounts, $datepaye, $paymentid, $closepaidinvoices, $accountid, $num_payment = '', $comment = '', $chqemetteur = '', $chqbank = '', $ref_ext = '', $accepthigherpayment = false) { - global $conf; - require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; if (!DolibarrApiAccess::$user->rights->facture->creer) { @@ -1645,6 +1627,7 @@ class Invoices extends DolibarrApi * @url PUT payments/{id} * * @return array + * * @throws RestException 400 Bad parameters * @throws RestException 401 Not allowed * @throws RestException 404 Not found @@ -1708,8 +1691,8 @@ class Invoices extends DolibarrApi /** * Validate fields before create or update object * - * @param array|null $data Datas to validate - * @return array + * @param array|null $data Datas to validate + * @return array * * @throws RestException */ @@ -1733,7 +1716,7 @@ class Invoices extends DolibarrApi * * @param int $id ID of template invoice * @param int $contact_list 0:Return array contains all properties, 1:Return array contains just id, -1: Do not return contacts/adddesses - * @return array|mixed data without useless information + * @return Object Object with cleaned properties * * @url GET templates/{id} * @@ -1749,11 +1732,11 @@ class Invoices extends DolibarrApi * * Return an array with invoice informations * - * @param int $id ID of order - * @param string $ref Ref of object - * @param string $ref_ext External reference of object - * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses - * @return array|mixed data without useless information + * @param int $id ID of order + * @param string $ref Ref of object + * @param string $ref_ext External reference of object + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id, -1: Do not return contacts/adddesses + * @return Object Object with cleaned properties * * @throws RestException */ diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index cf9151c9bee..269c5267ab3 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'=>'$conf->societe->enabled', 'visible'=>-1, 'notnull'=>1, 'position'=>25), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'isModEnabled("societe")', '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), @@ -188,13 +188,12 @@ class FactureRec extends CommonInvoice 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>105), 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>110), 'modelpdf' =>array('type'=>'varchar(255)', 'label'=>'Modelpdf', 'enabled'=>1, 'visible'=>-1, 'position'=>115), - 'date_last_gen' =>array('type'=>'varchar(7)', 'label'=>'Last gen', 'enabled'=>1, 'visible'=>-1, 'position'=>120), - 'unit_frequency' =>array('type'=>'varchar(2)', 'label'=>'Unit frequency', 'enabled'=>1, 'visible'=>-1, 'position'=>125), 'date_when' =>array('type'=>'datetime', 'label'=>'Date when', 'enabled'=>1, 'visible'=>-1, 'position'=>130), 'date_last_gen' =>array('type'=>'datetime', 'label'=>'Date last gen', 'enabled'=>1, 'visible'=>-1, 'position'=>135), 'nb_gen_done' =>array('type'=>'integer', 'label'=>'Nb gen done', 'enabled'=>1, 'visible'=>-1, 'position'=>140), 'nb_gen_max' =>array('type'=>'integer', 'label'=>'Nb gen max', 'enabled'=>1, 'visible'=>-1, 'position'=>145), 'frequency' =>array('type'=>'integer', 'label'=>'Frequency', 'enabled'=>1, 'visible'=>-1, 'position'=>150), + 'unit_frequency' =>array('type'=>'varchar(2)', 'label'=>'UnitFrequency', 'enabled'=>1, 'visible'=>-1, 'position'=>152), 'usenewprice' =>array('type'=>'integer', 'label'=>'UseNewPrice', 'enabled'=>1, 'visible'=>0, 'position'=>155), '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), diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 87914eac38e..1af653e14d1 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1956,14 +1956,14 @@ class Facture extends CommonInvoice $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON f.fk_incoterms = i.rowid'; if ($rowid) { - $sql .= " WHERE f.rowid=".((int) $rowid); + $sql .= " WHERE f.rowid = ".((int) $rowid); } else { $sql .= ' WHERE f.entity IN ('.getEntity('invoice').')'; // Don't use entity if you use rowid if ($ref) { - $sql .= " AND f.ref='".$this->db->escape($ref)."'"; + $sql .= " AND f.ref = '".$this->db->escape($ref)."'"; } if ($ref_ext) { - $sql .= " AND f.ref_ext='".$this->db->escape($ref_ext)."'"; + $sql .= " AND f.ref_ext = '".$this->db->escape($ref_ext)."'"; } } @@ -4078,7 +4078,7 @@ class Facture extends CommonInvoice * * @param int $idline id of line to check * @param float $situation_percent progress percentage need to be test - * @return false if KO, true if OK + * @return bool false if KO, true if OK */ public function checkProgressLine($idline, $situation_percent) { @@ -4097,7 +4097,7 @@ class Facture extends CommonInvoice if ($obj === null) { return true; } else { - return $situation_percent < $obj->situation_percent; + return ($situation_percent < $obj->situation_percent); } } @@ -4148,9 +4148,10 @@ class Facture extends CommonInvoice * Delete line in database * * @param int $rowid Id of line to delete + * @param int $id Id of object (for a check) * @return int <0 if KO, >0 if OK */ - public function deleteline($rowid) + public function deleteline($rowid, $id = 0) { global $user; @@ -4161,6 +4162,22 @@ class Facture extends CommonInvoice return -1; } + $line = new FactureLigne($this->db); + + $line->context = $this->context; + + // Load line + $result = $line->fetch($rowid); + if (!($result > 0)) { + dol_print_error($this->db, $line->error, $line->errors); + return -1; + } + + if ($id > 0 && $line->fk_facture != $id) { + $this->error = 'ErrorLineIDDoesNotMatchWithObjectID'; + return -1; + } + $this->db->begin(); // Free discount linked to invoice line @@ -4176,15 +4193,9 @@ class Facture extends CommonInvoice return -1; } - $line = new FactureLigne($this->db); - - $line->context = $this->context; - - // For triggers - $result = $line->fetch($rowid); - if (!($result > 0)) { - dol_print_error($this->db, $line->error, $line->errors); - } + // Memorize previous line for triggers + $staticline = clone $line; + $line->oldline = $staticline; if ($line->delete($user) > 0) { $result = $this->update_price(1); @@ -4213,7 +4224,7 @@ class Facture extends CommonInvoice * @param User $user User that set discount * @param double $remise Discount * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int <0 if ko, >0 if ok + * @return int <0 if KO, >0 if OK */ public function set_remise($user, $remise, $notrigger = 0) { @@ -4228,7 +4239,7 @@ class Facture extends CommonInvoice * @param User $user User that set discount * @param double $remise Discount * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int <0 if ko, >0 if ok + * @return int <0 if KO, >0 if OK */ public function setDiscount($user, $remise, $notrigger = 0) { @@ -4280,6 +4291,8 @@ class Facture extends CommonInvoice return -1 * $error; } } + + return 0; } @@ -4345,6 +4358,8 @@ class Facture extends CommonInvoice return -1 * $error; } } + + return 0; } /** @@ -4636,8 +4651,8 @@ class Facture extends CommonInvoice * Invoices matching the following rules are returned: * (validated + payment on process) or classified (payed completely or payed partiely) + not already replaced + not already a credit note * - * @param int $socid Id thirdparty - * @return array Array of invoices ($id => array('ref'=>,'paymentornot'=>,'status'=>,'paye'=>) + * @param int $socid Id thirdparty + * @return array|int Array of invoices ($id => array('ref'=>,'paymentornot'=>,'status'=>,'paye'=>) */ public function list_qualified_avoir_invoices($socid = 0) { @@ -4711,8 +4726,8 @@ class Facture extends CommonInvoice /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * - * @param User $user Object user - * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK + * @param User $user Object user + * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ public function load_board($user) { @@ -5731,6 +5746,39 @@ class Facture extends CommonInvoice } else { dol_print_error($this->db); } + + return array(); + } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + //$return .= ''; // Can be image + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + if (property_exists($this, 'socid')) { + $return .= '
'.$this->socid.''; + } + if (property_exists($this, 'fk_user_author')) { + $return .= '
'.$this->fk_user_author.''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; } } @@ -6264,7 +6312,7 @@ class FactureLigne extends CommonInvoiceLine $sql .= ", total_localtax2=".price2num($this->total_localtax2); } $sql .= ", fk_product_fournisseur_price=".(!empty($this->fk_fournprice) ? "'".$this->db->escape($this->fk_fournprice)."'" : "null"); - $sql .= ", buy_price_ht=".(($this->pa_ht || $this->pa_ht === 0 || $this->pa_ht === '0') ? price2num($this->pa_ht) : "null"); // $this->pa_ht should always be defined (set to 0 or to sell price depending on option) + $sql .= ", buy_price_ht=".(($this->pa_ht || (string) $this->pa_ht === '0') ? price2num($this->pa_ht) : "null"); // $this->pa_ht should always be defined (set to 0 or to sell price depending on option) $sql .= ", fk_parent_line=".($this->fk_parent_line > 0 ? $this->fk_parent_line : "null"); if (!empty($this->rang)) { $sql .= ", rang=".((int) $this->rang); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index afc31d7efe3..0b5903c54c4 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -75,6 +75,7 @@ $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $optioncss = GETPOST('optioncss', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'invoicelist'; +$mode = GETPOST('mode', 'alpha'); if ($contextpage == 'poslist') { $optioncss = 'print'; @@ -299,7 +300,7 @@ if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massa $massaction = ''; } -$parameters = array('socid'=>$socid); +$parameters = array('socid'=>$socid, 'arrayfields'=>&$arrayfields); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -974,6 +975,9 @@ if ($resql) { } $param = '&socid='.urlencode($socid); + if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); + } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -1185,6 +1189,9 @@ if ($resql) { if (!empty($socid)) { $url .= '&socid='.$socid; } + $newcardbutton = ''; + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); $newcardbutton = dolGetButtonTitle($langs->trans('NewBill'), '', 'fa fa-plus-circle', $url, '', $user->hasRight("facture", "creer")); } @@ -1204,6 +1211,7 @@ if ($resql) { print ''; print ''; print ''; + print ''; print_barre_liste($langs->trans('BillsCustomers').' '.($socid > 0 ? ' '.$soc->name : ''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bill', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -1590,9 +1598,9 @@ if ($resql) { } // Status if (!empty($arrayfields['f.fk_statut']['checked'])) { - print ''; } // Action column @@ -1894,645 +1902,660 @@ if ($resql) { $total_margin += $marginInfo['total_margin']; } - print 'ref)); - print 'parent.place=\''.$place.'\''; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + } + } else { + print 'ref)); + print 'parent.place=\''.$place.'\''; } - print ''; + print '});"'; } - print ''; - } + print '>'; - // No - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { - print ''; - } - // Ref - if (!empty($arrayfields['f.ref']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Customer ref - if (!empty($arrayfields['f.ref_client']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Type - if (!empty($arrayfields['f.type']['checked'])) { - print '"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Date - if (!empty($arrayfields['f.datef']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Date - if (!empty($arrayfields['f.date_valid']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Date limit - if (!empty($arrayfields['f.date_lim_reglement']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Project ref - if (!empty($arrayfields['p.ref']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Project title - if (!empty($arrayfields['p.title']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Third party - if (!empty($arrayfields['s.nom']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Alias - if (!empty($arrayfields['s.name_alias']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Parent company - if (!empty($arrayfields['s2.nom']['checked'])) { - print ''; + } + + // No + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { + print ''; + } + + // Ref + if (!empty($arrayfields['f.ref']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; } } - print ""; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Town - if (!empty($arrayfields['s.town']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Zip - if (!empty($arrayfields['s.zip']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // State - if (!empty($arrayfields['state.nom']['checked'])) { - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Country - if (!empty($arrayfields['country.code_iso']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Type ent - if (!empty($arrayfields['typent.code']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Staff - if (!empty($arrayfields['staff.code']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Payment mode - if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { - $s = $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1, 0, '', 1); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Payment terms - if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { - $s = $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 0, '', -1, -1, 1); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Module Source - if (!empty($arrayfields['f.module_source']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // POS Terminal - if (!empty($arrayfields['f.pos_source']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Amount HT - if (!empty($arrayfields['f.total_ht']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ht'; - } - $totalarray['val']['f.total_ht'] += $obj->total_ht; - } - // Amount VAT - if (!empty($arrayfields['f.total_tva']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'f.total_tva'; - } - $totalarray['val']['f.total_tva'] += $obj->total_tva; - } - // Amount LocalTax1 - if (!empty($arrayfields['f.total_localtax1']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax1'; - } - $totalarray['val']['f.total_localtax1'] += $obj->total_localtax1; - } - // Amount LocalTax2 - if (!empty($arrayfields['f.total_localtax2']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax2'; - } - $totalarray['val']['f.total_localtax2'] += $obj->total_localtax2; - } - // Amount TTC - if (!empty($arrayfields['f.total_ttc']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc'; - } - $totalarray['val']['f.total_ttc'] += $obj->total_ttc; - } - - $userstatic->id = $obj->fk_user_author; - $userstatic->login = $obj->login; - $userstatic->lastname = $obj->lastname; - $userstatic->firstname = $obj->firstname; - $userstatic->email = $obj->user_email; - $userstatic->statut = $obj->user_statut; - $userstatic->entity = $obj->entity; - $userstatic->photo = $obj->photo; - $userstatic->office_phone = $obj->office_phone; - $userstatic->office_fax = $obj->office_fax; - $userstatic->user_mobile = $obj->user_mobile; - $userstatic->job = $obj->job; - $userstatic->gender = $obj->gender; - - // Author - if (!empty($arrayfields['u.login']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - if (!empty($arrayfields['sale_representative']['checked'])) { - // Sales representatives - print ''; + if (!$i) { + $totalarray['nbfield']++; } - $nbofsalesrepresentative = count($listsalesrepresentatives); - if ($nbofsalesrepresentative > 6) { - // We print only number - print $nbofsalesrepresentative; - } elseif ($nbofsalesrepresentative > 0) { - $j = 0; - foreach ($listsalesrepresentatives as $val) { - $userstatic->id = $val['id']; - $userstatic->lastname = $val['lastname']; - $userstatic->firstname = $val['firstname']; - $userstatic->email = $val['email']; - $userstatic->statut = $val['statut']; - $userstatic->entity = $val['entity']; - $userstatic->photo = $val['photo']; - $userstatic->login = $val['login']; - $userstatic->office_phone = $val['office_phone']; - $userstatic->office_fax = $val['office_fax']; - $userstatic->user_mobile = $val['user_mobile']; - $userstatic->job = $val['job']; - $userstatic->gender = $val['gender']; - //print '
': - print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2); - $j++; - if ($j < $nbofsalesrepresentative) { - print ' '; + } + + // Type + if (!empty($arrayfields['f.type']['checked'])) { + print '
"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date + if (!empty($arrayfields['f.datef']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date + if (!empty($arrayfields['f.date_valid']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date limit + if (!empty($arrayfields['f.date_lim_reglement']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Project ref + if (!empty($arrayfields['p.ref']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Project title + if (!empty($arrayfields['p.title']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Third party + if (!empty($arrayfields['s.nom']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Alias + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Parent company + if (!empty($arrayfields['s2.nom']['checked'])) { + print '"; + if (!$i) { + $totalarray['nbfield']++; + } } - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Town + if (!empty($arrayfields['s.town']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Zip + if (!empty($arrayfields['s.zip']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // State + if (!empty($arrayfields['state.nom']['checked'])) { + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Type ent + if (!empty($arrayfields['typent.code']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Staff + if (!empty($arrayfields['staff.code']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - if (!empty($arrayfields['f.retained_warranty']['checked'])) { - print ''; - } + // Payment mode + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { + $s = $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1, 0, '', 1); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } - if (!empty($arrayfields['dynamount_payed']['checked'])) { - print ''; // TODO Use a denormalized field - if (!$i) { - $totalarray['nbfield']++; + // Payment terms + if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { + $s = $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 0, '', -1, -1, 1); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'totalam'; - } - $totalarray['val']['totalam'] += $totalpay; - } - // Pending amount - if (!empty($arrayfields['rtp']['checked'])) { - print ''; // TODO Use a denormalized field - if (!$i) { - $totalarray['nbfield']++; + // Module Source + if (!empty($arrayfields['f.module_source']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'rtp'; - } - $totalarray['val']['rtp'] += $remaintopay; - } + // POS Terminal + if (!empty($arrayfields['f.pos_source']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } - // Currency - if (!empty($arrayfields['f.multicurrency_code']['checked'])) { - print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ht'; + } + $totalarray['val']['f.total_ht'] += $obj->total_ht; } - print "\n"; - if (!$i) { - $totalarray['nbfield']++; + // Amount VAT + if (!empty($arrayfields['f.total_tva']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_tva'; + } + $totalarray['val']['f.total_tva'] += $obj->total_tva; + } + // Amount LocalTax1 + if (!empty($arrayfields['f.total_localtax1']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax1'; + } + $totalarray['val']['f.total_localtax1'] += $obj->total_localtax1; + } + // Amount LocalTax2 + if (!empty($arrayfields['f.total_localtax2']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax2'; + } + $totalarray['val']['f.total_localtax2'] += $obj->total_localtax2; + } + // Amount TTC + if (!empty($arrayfields['f.total_ttc']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc'; + } + $totalarray['val']['f.total_ttc'] += $obj->total_ttc; } - } - // Currency rate - if (!empty($arrayfields['f.multicurrency_tx']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount HT - if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount VAT - if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount TTC - if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) { - print ''; // TODO Use a denormalized field - if (!$i) { - $totalarray['nbfield']++; - } - } + $userstatic->id = $obj->fk_user_author; + $userstatic->login = $obj->login; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; + $userstatic->email = $obj->user_email; + $userstatic->statut = $obj->user_statut; + $userstatic->entity = $obj->entity; + $userstatic->photo = $obj->photo; + $userstatic->office_phone = $obj->office_phone; + $userstatic->office_fax = $obj->office_fax; + $userstatic->user_mobile = $obj->user_mobile; + $userstatic->job = $obj->job; + $userstatic->gender = $obj->gender; - // Pending amount - if (!empty($arrayfields['multicurrency_rtp']['checked'])) { - print ''; // TODO Use a denormalized field - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Total buying or cost price - if (!empty($arrayfields['total_pa']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Total margin - if (!empty($arrayfields['total_margin']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'total_margin'; - } - $totalarray['val']['total_margin'] += $marginInfo['total_margin']; - } - // Total margin rate - if (!empty($arrayfields['total_margin_rate']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Total mark rate - if (!empty($arrayfields['total_mark_rate']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate'; - } - if ($i >= $imaxinloop - 1) { - if (!empty($total_ht)) { - $totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT'); + // Author + if (!empty($arrayfields['u.login']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; } } - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['f.datec']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['f.tms']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date closing - if (!empty($arrayfields['f.date_closing']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Note public - if (!empty($arrayfields['f.note_public']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Note private - if (!empty($arrayfields['f.note_private']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Template Invoice - if (!empty($arrayfields['f.fk_fac_rec_source']['checked'])) { - print ''; + if (!$i) { + $totalarray['nbfield']++; } } - print ''; + + if (!empty($arrayfields['f.retained_warranty']['checked'])) { + print ''; + } + + if (!empty($arrayfields['dynamount_payed']['checked'])) { + print ''; // TODO Use a denormalized field + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'totalam'; + } + $totalarray['val']['totalam'] += $totalpay; + } + + // Pending amount + if (!empty($arrayfields['rtp']['checked'])) { + print ''; // TODO Use a denormalized field + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'rtp'; + } + $totalarray['val']['rtp'] += $remaintopay; + } + + + // Currency + if (!empty($arrayfields['f.multicurrency_code']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Currency rate + if (!empty($arrayfields['f.multicurrency_tx']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount HT + if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount VAT + if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount TTC + if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) { + print ''; // TODO Use a denormalized field + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Pending amount + if (!empty($arrayfields['multicurrency_rtp']['checked'])) { + print ''; // TODO Use a denormalized field + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Total buying or cost price + if (!empty($arrayfields['total_pa']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Total margin + if (!empty($arrayfields['total_margin']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'total_margin'; + } + $totalarray['val']['total_margin'] += $marginInfo['total_margin']; + } + // Total margin rate + if (!empty($arrayfields['total_margin_rate']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Total mark rate + if (!empty($arrayfields['total_mark_rate']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate'; + } + if ($i >= $imaxinloop - 1) { + if (!empty($total_ht)) { + $totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT'); + } else { + $totalarray['val']['total_mark_rate'] = ''; + } + } + } + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['f.datec']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date modification + if (!empty($arrayfields['f.tms']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date closing + if (!empty($arrayfields['f.date_closing']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Note public + if (!empty($arrayfields['f.note_public']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Note private + if (!empty($arrayfields['f.note_private']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Template Invoice + if (!empty($arrayfields['f.fk_fac_rec_source']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Status + if (!empty($arrayfields['f.fk_statut']['checked'])) { + print '"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Action column (Show the massaction button only when this page is not opend from the Extended POS) + + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } if (!$i) { $totalarray['nbfield']++; } + print "\n"; } - // Status - if (!empty($arrayfields['f.fk_statut']['checked'])) { - print '"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Action column (Show the massaction button only when this page is not opend from the Extended POS) - - if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } - print "\n"; - $i++; } diff --git a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php index 6a16f4fa641..ca782052ff4 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php @@ -67,7 +67,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { break; } print ''; - print ''; + print ''; print ''; print ''; print ' - + '; // Status - print ''; + print ''; // Amount paid print ''; print "\n"; diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index ab7b13aba90..cf1a570f04f 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -240,12 +240,9 @@ class EcmFiles extends CommonObject } // If ref not defined - $ref = ''; - if (!empty($this->ref)) { - $ref = $this->ref; - } else { + if (empty($this->ref)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php'; - $ref = dol_hash($this->filepath.'/'.$this->filename, 3); + $this->ref = dol_hash($this->filepath.'/'.$this->filename, 3); } $maxposition = 0; @@ -300,7 +297,7 @@ class EcmFiles extends CommonObject $sql .= 'src_object_type,'; $sql .= 'src_object_id'; $sql .= ') VALUES ('; - $sql .= " '".$this->db->escape($ref)."', "; + $sql .= " '".$this->db->escape($this->ref)."', "; $sql .= ' '.(!isset($this->label) ? 'NULL' : "'".$this->db->escape($this->label)."'").','; $sql .= ' '.(!isset($this->share) ? 'NULL' : "'".$this->db->escape($this->share)."'").','; $sql .= ' '.((int) $this->entity).','; diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php index 9eb512bc96d..6edf59dcbed 100644 --- a/htdocs/ecm/index.php +++ b/htdocs/ecm/index.php @@ -322,7 +322,7 @@ $moreheadjs .= ''."\n"; llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', '', '', $morejs, '', 0, 0); -$head = ecm_prepare_dasboard_head(''); +$head = ecm_prepare_dasboard_head(null); print dol_get_fiche_head($head, 'index', '', -1, ''); diff --git a/htdocs/ecm/index_auto.php b/htdocs/ecm/index_auto.php index 342d7d74129..3944e869da0 100644 --- a/htdocs/ecm/index_auto.php +++ b/htdocs/ecm/index_auto.php @@ -309,7 +309,7 @@ llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', '', '', $m // Add sections to manage $rowspan = 0; $sectionauto = array(); -if (!empty($conf->global->ECM_AUTO_TREE_ENABLED)) { +if (empty($conf->global->ECM_AUTO_TREE_HIDEN)) { if (isModEnabled("product") || isModEnabled("service")) { $langs->load("products"); $rowspan++; $sectionauto[] = array('position'=>10, 'level'=>1, 'module'=>'product', 'test'=>(isModEnabled("product") || isModEnabled("service")), 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts")); @@ -387,7 +387,7 @@ if (!empty($conf->global->ECM_AUTO_TREE_ENABLED)) { } } -$head = ecm_prepare_dasboard_head(''); +$head = ecm_prepare_dasboard_head(null); print dol_get_fiche_head($head, 'index_auto', '', -1, ''); diff --git a/htdocs/ecm/index_medias.php b/htdocs/ecm/index_medias.php index 2e1edcdc269..39118774430 100644 --- a/htdocs/ecm/index_medias.php +++ b/htdocs/ecm/index_medias.php @@ -295,7 +295,7 @@ $moreheadjs .= ''."\n"; llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', '', '', $morejs, '', 0, 0); -$head = ecm_prepare_dasboard_head(''); +$head = ecm_prepare_dasboard_head(null); print dol_get_fiche_head($head, 'index_medias', '', -1, ''); diff --git a/htdocs/ecm/search.php b/htdocs/ecm/search.php index e37a1ce88f3..c43428fae8e 100644 --- a/htdocs/ecm/search.php +++ b/htdocs/ecm/search.php @@ -175,7 +175,7 @@ print load_fiche_titre($langs->trans("ECMArea").' - '.$langs->trans("Search")); print $langs->trans("FeatureNotYetAvailable").'.

'; // Tool bar -$head = ecm_prepare_head_fm($ecmdir, $module, $section); +$head = ecm_prepare_head_fm($ecmdir); //print dol_get_fiche_head($head, 'search_form', '', 1); diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 28dbc0835e7..b2b3cb70f39 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -1518,7 +1518,7 @@ class EmailCollector extends CommonObject $trackidfoundintorecipientid = 0; $reg = array(); // See also later list of all supported tags... - if (preg_match('/\+(thi|ctc|use|mem|sub|proj|tas|con|tic|job|pro|ord|inv|spro|sor|sin|leav|stockinv|job|surv|salary)([0-9]+)@/', $emailto, $reg)) { + if (preg_match('/\+(thi|ctc|use|mem|sub|proj|tas|con|tic|pro|ord|inv|spro|sor|sin|leav|stockinv|job|surv|salary)([0-9]+)@/', $emailto, $reg)) { $trackidfoundintorecipienttype = $reg[1]; $trackidfoundintorecipientid = $reg[2]; } elseif (preg_match('/\+emailing-(\w+)@/', $emailto, $reg)) { // Can be 'emailing-test' or 'emailing-IdMailing-IdRecipient' @@ -2158,6 +2158,118 @@ class EmailCollector extends CommonObject } } } + } elseif ($operation['type'] == 'loadandcreatecontact') { // Search and create contact + if (empty($operation['actionparam'])) { + $errorforactions++; + $this->error = "Action loadandcreatecontact has empty parameter. Must be 'SET:xxx' or 'EXTRACT:(body|subject):regex' to define how to extract data"; + $this->errors[] = $this->error; + } else { + $contact_static = new Contact($this->db); + // Overwrite values with values extracted from source email + $errorforthisaction = $this->overwritePropertiesOfObject($contact_static, $operation['actionparam'], $messagetext, $subject, $header, $operationslog); + if ($errorforthisaction) { + $errorforactions++; + } else { + if (!empty($contact_static->email) && $contact_static->email != $from) $from = $contact_static->email; + + $result = $contactstatic->fetch(0, null, '', $from); + if ($result < 0) { + $errorforactions++; + $this->error = 'Error when getting contact with email ' . $from; + $this->errors[] = $this->error; + break; + } elseif ($result == 0) { + dol_syslog("Contact with email " . $from . " was not found. We try to create it."); + $contactstatic = new Contact($this->db); + + // Create contact + $contactstatic->email = $from; + $operationslog .= '
We set property email='.dol_escape_htmltag($from); + + // Overwrite values with values extracted from source email + $errorforthisaction = $this->overwritePropertiesOfObject($contactstatic, $operation['actionparam'], $messagetext, $subject, $header, $operationslog); + + if ($errorforthisaction) { + $errorforactions++; + } else { + // Search country by name or code + if (!empty($contactstatic->country)) { + require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; + $result = getCountry('', 3, $this->db, '', 1, $contactstatic->country); + if ($result == 'NotDefined') { + $errorforactions++; + $this->error = "Error country not found by this name '" . $contactstatic->country . "'"; + } elseif (!($result > 0)) { + $errorforactions++; + $this->error = "Error when search country by this name '" . $contactstatic->country . "'"; + $this->errors[] = $this->db->lasterror(); + } else { + $contactstatic->country_id = $result; + $operationslog .= '
We set property country_id='.dol_escape_htmltag($result); + } + } elseif (!empty($contactstatic->country_code)) { + require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; + $result = getCountry($contactstatic->country_code, 3, $this->db); + if ($result == 'NotDefined') { + $errorforactions++; + $this->error = "Error country not found by this code '" . $contactstatic->country_code . "'"; + } elseif (!($result > 0)) { + $errorforactions++; + $this->error = "Error when search country by this code '" . $contactstatic->country_code . "'"; + $this->errors[] = $this->db->lasterror(); + } else { + $contactstatic->country_id = $result; + $operationslog .= '
We set property country_id='.dol_escape_htmltag($result); + } + } + + if (!$errorforactions) { + // Search state by name or code (for country if defined) + if (!empty($contactstatic->state)) { + require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php'; + $result = dol_getIdFromCode($this->db, $contactstatic->state, 'c_departements', 'nom', 'rowid'); + if (empty($result)) { + $errorforactions++; + $this->error = "Error state not found by this name '" . $contactstatic->state . "'"; + } elseif (!($result > 0)) { + $errorforactions++; + $this->error = "Error when search state by this name '" . $contactstatic->state . "'"; + $this->errors[] = $this->db->lasterror(); + } else { + $contactstatic->state_id = $result; + $operationslog .= '
We set property state_id='.dol_escape_htmltag($result); + } + } elseif (!empty($contactstatic->state_code)) { + require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php'; + $result = dol_getIdFromCode($this->db, $contactstatic->state_code, 'c_departements', 'code_departement', 'rowid'); + if (empty($result)) { + $errorforactions++; + $this->error = "Error state not found by this code '" . $contactstatic->state_code . "'"; + } elseif (!($result > 0)) { + $errorforactions++; + $this->error = "Error when search state by this code '" . $contactstatic->state_code . "'"; + $this->errors[] = $this->db->lasterror(); + } else { + $contactstatic->state_id = $result; + $operationslog .= '
We set property state_id='.dol_escape_htmltag($result); + } + } + } + + if (!$errorforactions) { + $result = $contactstatic->create($user); + if ($result <= 0) { + $errorforactions++; + $this->error = $contactstatic->error; + $this->errors = $contactstatic->errors; + } else { + $operationslog .= '
Contact created -> id = '.dol_escape_htmltag($contactstatic->id); + } + } + } + } + } + } } elseif ($operation['type'] == 'recordevent') { // Create event $actioncomm = new ActionComm($this->db); @@ -2277,7 +2389,7 @@ class EmailCollector extends CommonObject 'fields' => array('ref'), 'class' => 'recruitment/class/recruitmentjobposition.class.php', 'object' => 'RecruitmentJobPosition'), - 'recruitment/recruitmentjobposition' => array('table' => 'recruitment_recruitmentcandidature', + 'recruitment/recruitmentcandidature' => array('table' => 'recruitment_recruitmentcandidature', 'fields' => array('ref'), 'class' => 'recruitment/class/recruitmentcandidature.class.php', 'object' => ' RecruitmentCandidature'), @@ -2322,7 +2434,7 @@ class EmailCollector extends CommonObject 'class' => 'compta/facture/class/facture.class.php', 'object' => 'Facture'), 'fournisseur/facture' => array('table' => 'facture_fourn', - 'fields' => array('ref', ref_client), + 'fields' => array('ref', 'ref_client'), 'class' => 'fourn/class/fournisseur.facture.class.php', 'object' => 'FactureFournisseur'), 'produit' => array('table' => 'product', @@ -3025,13 +3137,14 @@ class EmailCollector extends CommonObject * Check if the same file name already exists in the upload folder, * append increment number to the original filename */ - while (file_exists($destdir."/" . $file_name . "." . $extension)) { - $file_name = (string) $file_name_original . ' (' . $num . ')'; + while (file_exists($destdir."/".$file_name.".".$extension)) { + $file_name = $file_name_original . ' (' . $num . ')'; $file_name_complete = $file_name . "." . $extension; $destination = $destdir.'/'.$file_name_complete; $num++; } + $destination = dol_sanitizePathName($destination); file_put_contents($destination, $data); } diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index cdb67a2c37b..50c681150b9 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -106,7 +106,7 @@ class ConferenceOrBooth extends ActionComm 'id' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'ref' => array('type'=>'integer', 'label'=>'Ref', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>2, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'csslist'=>'tdoverflowmax125', 'help'=>"OrganizationEvenLabelName", 'showoncombobox'=>'1',), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'$conf->societe->enabled', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"OrganizationEventLinkToThirdParty", 'picto'=>'company', 'css'=>'tdoverflowmax150 maxwidth500'), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'isModEnabled("societe")', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"OrganizationEventLinkToThirdParty", 'picto'=>'company', 'css'=>'tdoverflowmax150 maxwidth500'), 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1:t.usage_organize_event=1', 'label'=>'Project', 'enabled'=>"isModEnabled('project')", 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1, 'picto'=>'project', 'css'=>'tdoverflowmax150 maxwidth500'), 'note' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>1), 'fk_action' => array('type'=>'sellist:c_actioncomm:libelle:id::module LIKE (\'%@eventorganization\')', 'label'=>'Format', 'enabled'=>'1', 'position'=>60, 'notnull'=>1, 'visible'=>1, 'css'=>'width300'), @@ -217,7 +217,6 @@ class ConferenceOrBooth extends ActionComm $this->socid = $this->fk_soc; $this->datef = $this->datep2; $this->note_private = $this->note; - $this->fk_user_author = $this->fk_user_author; } /** @@ -716,8 +715,8 @@ class ConferenceOrBooth extends ActionComm $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_conferenceorbooth = '.((int) $this->id))); if (is_numeric($result)) { - $this->error = $this->error; - $this->errors = $this->errors; + $this->error = $objectline->error; + $this->errors = $objectline->errors; return $result; } else { $this->lines = $result; diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php b/htdocs/eventorganization/class/conferenceorboothattendee.class.php index abb0046606c..d46f8b54817 100644 --- a/htdocs/eventorganization/class/conferenceorboothattendee.class.php +++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php @@ -108,7 +108,7 @@ class ConferenceOrBoothAttendee extends CommonObject 'email' => array('type'=>'mail', 'label'=>'EmailAttendee', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'autofocusoncreate'=>1, 'searchall'=>1), 'firstname' => array('type'=>'varchar(100)', 'label'=>'Firstname', 'enabled'=>'1', 'position'=>31, 'notnull'=>0, 'visible'=>1, 'index'=>1, 'searchall'=>1), 'lastname' => array('type'=>'varchar(100)', 'label'=>'Lastname', 'enabled'=>'1', 'position'=>32, 'notnull'=>0, 'visible'=>1, 'index'=>1, 'searchall'=>1), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status = 1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'$conf->societe->enabled', 'position'=>40, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"OrganizationEventLinkToThirdParty", 'picto'=>'company', 'css'=>'tdoverflowmax150 maxwidth500'), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status = 1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'isModEnabled("societe")', 'position'=>40, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"OrganizationEventLinkToThirdParty", 'picto'=>'company', 'css'=>'tdoverflowmax150 maxwidth500'), 'email_company' => array('type'=>'mail', 'label'=>'EmailCompany', 'enabled'=>'1', 'position'=>41, 'notnull'=>0, 'visible'=>-2, 'searchall'=>1), 'date_subscription' => array('type'=>'datetime', 'label'=>'DateOfRegistration', 'enabled'=>'1', 'position'=>56, 'notnull'=>1, 'visible'=>1, 'showoncombobox'=>'1',), 'fk_invoice' => array('type'=>'integer:Facture:compta/facture/class/facture.class.php', 'label'=>'Invoice', 'enabled'=>'$conf->facture->enabled', 'position'=>57, 'notnull'=>0, 'visible'=>-1, 'index'=>0, 'picto'=>'bill', 'css'=>'tdoverflowmax150 maxwidth500'), diff --git a/htdocs/eventorganization/conferenceorbooth_card.php b/htdocs/eventorganization/conferenceorbooth_card.php index b6932c2cf09..9928b8af33b 100644 --- a/htdocs/eventorganization/conferenceorbooth_card.php +++ b/htdocs/eventorganization/conferenceorbooth_card.php @@ -568,13 +568,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.$withProjectUrl.'&action=presend&token='.newToken().'&mode=init#formmailbeforetitle'); } - print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.$withProjectUrl.'&action=edit&token='.newToken().'', '', $permissiontoadd); + print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.$withProjectUrl.'&action=edit&token='.newToken(), '', $permissiontoadd); // Clone print dolGetButtonAction('', $langs->trans('ToClone'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.$withProjectUrl.'&socid='.$object->socid.'&action=clone&token='.newToken().'&object=scrumsprint', '', $permissiontoadd); // Delete (need delete permission, or if draft, just need create/modify permission) - print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.$withProjectUrl.'&action=delete&token='.newToken().'', '', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd)); + print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.$withProjectUrl.'&action=delete&token='.newToken(), '', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd)); } print ''."\n"; } diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index ab8c4a28cbc..3e096bcc55d 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1647,7 +1647,7 @@ if ($action == 'create') { dol_print_error($db); } } -} elseif ($id || $ref) { +} elseif ($object->id > 0) { /* *************************************************************************** */ /* */ /* Edit and view mode */ @@ -1657,828 +1657,826 @@ if ($action == 'create') { $num_prod = count($lines); - if ($object->id > 0) { - if (!empty($object->origin) && $object->origin_id > 0) { - $typeobject = $object->origin; - $origin = $object->origin; - $origin_id = $object->origin_id; - $object->fetch_origin(); // Load property $object->commande, $object->propal, ... + if (!empty($object->origin) && $object->origin_id > 0) { + $typeobject = $object->origin; + $origin = $object->origin; + $origin_id = $object->origin_id; + $object->fetch_origin(); // Load property $object->commande, $object->propal, ... + } + + $soc = new Societe($db); + $soc->fetch($object->socid); + + $res = $object->fetch_optionals(); + + $head = shipping_prepare_head($object); + print dol_get_fiche_head($head, 'shipping', $langs->trans("Shipment"), -1, $object->picto); + + $formconfirm = ''; + + // Confirm deleteion + if ($action == 'delete') { + $formquestion = array(); + if ($object->statut == Expedition::STATUS_CLOSED && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { + $formquestion = array( + array( + 'label' => $langs->trans('ShipmentIncrementStockOnDelete'), + 'name' => 'alsoUpdateStock', + 'type' => 'checkbox', + 'value' => 0 + ), + ); + } + $formconfirm = $form->formconfirm( + $_SERVER['PHP_SELF'].'?id='.$object->id, + $langs->trans('DeleteSending'), + $langs->trans("ConfirmDeleteSending", $object->ref), + 'confirm_delete', + $formquestion, + 0, + 1 + ); + } + + // Confirmation validation + if ($action == 'valid') { + $objectref = substr($object->ref, 1, 4); + if ($objectref == 'PROV') { + $numref = $object->getNextNumRef($soc); + } else { + $numref = $object->ref; } - $soc = new Societe($db); - $soc->fetch($object->socid); + $text = $langs->trans("ConfirmValidateSending", $numref); - $res = $object->fetch_optionals(); + if (isModEnabled('notification')) { + require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; + $notify = new Notify($db); + $text .= '
'; + $text .= $notify->confirmMessage('SHIPPING_VALIDATE', $object->socid, $object); + } - $head = shipping_prepare_head($object); - print dol_get_fiche_head($head, 'shipping', $langs->trans("Shipment"), -1, $object->picto); + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('ValidateSending'), $text, 'confirm_valid', '', 0, 1); + } + // Confirm cancelation + if ($action == 'cancel') { + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('CancelSending'), $langs->trans("ConfirmCancelSending", $object->ref), 'confirm_cancel', '', 0, 1); + } - $formconfirm = ''; + // Call Hook formConfirm + $parameters = array('formConfirm' => $formconfirm); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } - // Confirm deleteion - if ($action == 'delete') { - $formquestion = array(); - if ($object->statut == Expedition::STATUS_CLOSED && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { - $formquestion = array( - array( - 'label' => $langs->trans('ShipmentIncrementStockOnDelete'), - 'name' => 'alsoUpdateStock', - 'type' => 'checkbox', - 'value' => 0 - ), - ); + // Print form confirm + print $formconfirm; + + // Calculate totalWeight and totalVolume for all products + // by adding weight and volume of each product line. + $tmparray = $object->getTotalWeightVolume(); + $totalWeight = $tmparray['weight']; + $totalVolume = $tmparray['volume']; + + + if ($typeobject == 'commande' && $object->$typeobject->id && isModEnabled('commande')) { + $objectsrc = new Commande($db); + $objectsrc->fetch($object->$typeobject->id); + } + if ($typeobject == 'propal' && $object->$typeobject->id && isModEnabled("propal")) { + $objectsrc = new Propal($db); + $objectsrc->fetch($object->$typeobject->id); + } + + // Shipment card + $linkback = ''.$langs->trans("BackToList").''; + $morehtmlref = '
'; + // Ref customer shipment + $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->expedition->creer, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->expedition->creer, 'string'.(isset($conf->global->THIRDPARTY_REF_INPUT_SIZE) ? ':'.$conf->global->THIRDPARTY_REF_INPUT_SIZE : ''), '', null, null, '', 1); + // Thirdparty + $morehtmlref .= '
'.$object->thirdparty->getNomUrl(1); + // Project + if (isModEnabled('project')) { + $langs->load("projects"); + $morehtmlref .= '
'; + if (0) { // Do not change on shipment + $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); + if ($action != 'classify') { + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $formconfirm = $form->formconfirm( - $_SERVER['PHP_SELF'].'?id='.$object->id, - $langs->trans('DeleteSending'), - $langs->trans("ConfirmDeleteSending", $object->ref), - 'confirm_delete', - $formquestion, - 0, - 1 - ); - } - - // Confirmation validation - if ($action == 'valid') { - $objectref = substr($object->ref, 1, 4); - if ($objectref == 'PROV') { - $numref = $object->getNextNumRef($soc); - } else { - $numref = $object->ref; - } - - $text = $langs->trans("ConfirmValidateSending", $numref); - - if (isModEnabled('notification')) { - require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; - $notify = new Notify($db); - $text .= '
'; - $text .= $notify->confirmMessage('SHIPPING_VALIDATE', $object->socid, $object); - } - - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('ValidateSending'), $text, 'confirm_valid', '', 0, 1); - } - // Confirm cancelation - if ($action == 'cancel') { - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('CancelSending'), $langs->trans("ConfirmCancelSending", $object->ref), 'confirm_cancel', '', 0, 1); - } - - // Call Hook formConfirm - $parameters = array('formConfirm' => $formconfirm); - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) { - $formconfirm .= $hookmanager->resPrint; - } elseif ($reshook > 0) { - $formconfirm = $hookmanager->resPrint; - } - - // Print form confirm - print $formconfirm; - - // Calculate totalWeight and totalVolume for all products - // by adding weight and volume of each product line. - $tmparray = $object->getTotalWeightVolume(); - $totalWeight = $tmparray['weight']; - $totalVolume = $tmparray['volume']; - - - if ($typeobject == 'commande' && $object->$typeobject->id && isModEnabled('commande')) { - $objectsrc = new Commande($db); - $objectsrc->fetch($object->$typeobject->id); - } - if ($typeobject == 'propal' && $object->$typeobject->id && isModEnabled("propal")) { - $objectsrc = new Propal($db); - $objectsrc->fetch($object->$typeobject->id); - } - - // Shipment card - $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
'; - // Ref customer shipment - $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->expedition->creer, 'string', '', 0, 1); - $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->expedition->creer, 'string'.(isset($conf->global->THIRDPARTY_REF_INPUT_SIZE) ? ':'.$conf->global->THIRDPARTY_REF_INPUT_SIZE : ''), '', null, null, '', 1); - // Thirdparty - $morehtmlref .= '
'.$object->thirdparty->getNomUrl(1); - // Project - if (isModEnabled('project')) { - $langs->load("projects"); - $morehtmlref .= '
'; - if (0) { // Do not change on shipment - $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); - if ($action != 'classify') { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; - } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $objectsrc->socid, $objectsrc->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); - } else { - if (!empty($objectsrc) && !empty($objectsrc->fk_project)) { - $proj = new Project($db); - $proj->fetch($objectsrc->fk_project); - $morehtmlref .= $proj->getNomUrl(1); - if ($proj->title) { - $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; - } + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $objectsrc->socid, $objectsrc->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + } else { + if (!empty($objectsrc) && !empty($objectsrc->fk_project)) { + $proj = new Project($db); + $proj->fetch($objectsrc->fk_project); + $morehtmlref .= $proj->getNomUrl(1); + if ($proj->title) { + $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; } } } - $morehtmlref .= '
'; + } + $morehtmlref .= '
'; - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - print '
'; - print '
'; - print '
'; + print '
'; + print '
'; + print '
'; - print '
'; print $langs->trans('RetainedWarrantyDateLimit'); print 'id.'">'.img_edit($langs->trans('setretainedwarrantyDateLimit'), 1).''; + print ''; $liststatus = array('0'=>$langs->trans("BillShortStatusDraft"), '0,1'=>$langs->trans("BillShortStatusDraft").'+'.$langs->trans("BillShortStatusNotPaid"), '1'=>$langs->trans("BillShortStatusNotPaid"), '1,2'=>$langs->trans("BillShortStatusNotPaid").'+'.$langs->trans("BillShortStatusPaid"), '2'=>$langs->trans("BillShortStatusPaid"), '3'=>$langs->trans("BillShortStatusCanceled")); - print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'width100 onrightofpage', 1); + print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage', 1); print '
'; + print '
'; } - print '});"'; - } - print '>'; - - - // Action column - if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print '
'; - if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->id, $arrayofselected)) { - $selected = 1; + // Output Kanban + $facturestatic->socid = $companystatic->getNomUrl(1, 'company', 15); + $userstatic->fetch($obj->fk_user_author); + $facturestatic->fk_user_author = $userstatic->getNomUrl(1); + print $facturestatic->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print ''; + print '
'.(($offset * $limit) + $i).''; - - print ''; - - print ''; - print ''; - print '
'; - if ($contextpage == 'poslist') { - print dol_escape_htmltag($obj->ref); - } else { - print $facturestatic->getNomUrl(1, '', 200, 0, '', 0, 1); - } - - $filename = dol_sanitizeFileName($obj->ref); - $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($obj->ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->id; - print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir); - print '
'; - - print "
'; - print dol_escape_htmltag($obj->ref_client); - print ''; - print $facturestatic->getLibType(2); - print "'; - print dol_print_date($db->jdate($obj->datef), 'day'); - print ''; - print dol_print_date($db->jdate($obj->date_valid), 'day'); - print ''.dol_print_date($datelimit, 'day'); - if ($facturestatic->hasDelay()) { - print img_warning($langs->trans('Alert').' - '.$langs->trans('Late')); - } - print ''; - if ($obj->project_id > 0) { - print $projectstatic->getNomUrl(1); - } - print ''; - if ($obj->project_id > 0) { - print dol_escape_htmltag($projectstatic->title); - } - print ''; - if ($contextpage == 'poslist') { - print dol_escape_htmltag($companystatic->name); - } else { - print $companystatic->getNomUrl(1, 'customer', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); - } - print ''; - print dol_escape_htmltag($companystatic->name_alias); - print ''; - if ($obj->fk_parent > 0) { - if (!isset($company_url_list[$obj->fk_parent])) { - $companyparent = new Societe($db); - $res = $companyparent->fetch($obj->fk_parent); - if ($res > 0) { - $company_url_list[$obj->fk_parent] = $companyparent->getNomUrl(1); + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->id, $arrayofselected)) { + $selected = 1; } + print ''; } - if (isset($company_url_list[$obj->fk_parent])) { - print $company_url_list[$obj->fk_parent]; + print ''.(($offset * $limit) + $i).''; + + print ''; + + print ''; + print ''; + print '
'; + if ($contextpage == 'poslist') { + print dol_escape_htmltag($obj->ref); + } else { + print $facturestatic->getNomUrl(1, '', 200, 0, '', 0, 1); + } + + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->id; + print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir); + print '
'; + + print "
'; - print dol_escape_htmltag($obj->town); - print ''; - print dol_escape_htmltag($obj->zip); - print '".dol_escape_htmltag($obj->state_name)."'; - $tmparray = getCountry($obj->fk_pays, 'all'); - print $tmparray['label']; - print ''; - if (!is_array($typenArray) || count($typenArray) == 0) { - $typenArray = $formcompany->typent_array(1); - } - print $typenArray[$obj->typent_code]; - print ''; - if (!is_array($conf->cache['staff']) || count($conf->cache['staff']) == 0) { - $conf->cache['staff'] = $formcompany->effectif_array(1); - } - print $conf->cache['staff'][$obj->staff_code]; - print ''; - print $s; - print ''; - print $s; - print ''; - print dol_escape_htmltag($obj->module_source); - print ''; - print dol_escape_htmltag($obj->pos_source); - print ''.price($obj->total_ht)."'.price($obj->total_tva)."'.price($obj->total_localtax1)."'.price($obj->total_localtax2)."'.price($obj->total_ttc)."'; - if ($userstatic->id) { - print $userstatic->getNomUrl(-1); - } else { - print ' '; - } - print "'; - if ($obj->socid > 0) { - $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user); - if ($listsalesrepresentatives < 0) { - dol_print_error($db); + // Customer ref + if (!empty($arrayfields['f.ref_client']['checked'])) { + print ''; + print dol_escape_htmltag($obj->ref_client); + print ''; + print $facturestatic->getLibType(2); + print "'; + print dol_print_date($db->jdate($obj->datef), 'day'); + print ''; + print dol_print_date($db->jdate($obj->date_valid), 'day'); + print ''.dol_print_date($datelimit, 'day'); + if ($facturestatic->hasDelay()) { + print img_warning($langs->trans('Alert').' - '.$langs->trans('Late')); + } + print ''; + if ($obj->project_id > 0) { + print $projectstatic->getNomUrl(1); + } + print ''; + if ($obj->project_id > 0) { + print dol_escape_htmltag($projectstatic->title); + } + print ''; + if ($contextpage == 'poslist') { + print dol_escape_htmltag($companystatic->name); + } else { + print $companystatic->getNomUrl(1, 'customer', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); + } + print ''; + print dol_escape_htmltag($companystatic->name_alias); + print ''; + if ($obj->fk_parent > 0) { + if (!isset($company_url_list[$obj->fk_parent])) { + $companyparent = new Societe($db); + $res = $companyparent->fetch($obj->fk_parent); + if ($res > 0) { + $company_url_list[$obj->fk_parent] = $companyparent->getNomUrl(1); } - //print ''; + } + if (isset($company_url_list[$obj->fk_parent])) { + print $company_url_list[$obj->fk_parent]; } } - //else print $langs->trans("NoSalesRepresentativeAffected"); - } else { - print ' '; + print "'; + print dol_escape_htmltag($obj->town); + print ''; + print dol_escape_htmltag($obj->zip); + print '".dol_escape_htmltag($obj->state_name)."'; + $tmparray = getCountry($obj->fk_pays, 'all'); + print $tmparray['label']; + print ''; + if (!is_array($typenArray) || count($typenArray) == 0) { + $typenArray = $formcompany->typent_array(1); + } + print $typenArray[$obj->typent_code]; + print ''; + if (!is_array($conf->cache['staff']) || count($conf->cache['staff']) == 0) { + $conf->cache['staff'] = $formcompany->effectif_array(1); + } + print $conf->cache['staff'][$obj->staff_code]; + print ''.(!empty($obj->retained_warranty) ? price($obj->retained_warranty).'%' : ' ').''; + print $s; + print ''.(!empty($totalpay) ? price($totalpay, 0, $langs) : ' ').''; + print $s; + print ''; - print (!empty($remaintopay) ? price($remaintopay, 0, $langs) : ' '); - print ''; + print dol_escape_htmltag($obj->module_source); + print ''; + print dol_escape_htmltag($obj->pos_source); + print ''; - if (empty($conf->global->MAIN_SHOW_ONLY_CODE_MULTICURRENCY)) { - print $langs->transnoentitiesnoconv('Currency'.$obj->multicurrency_code); - } else { - print dol_escape_htmltag($obj->multicurrency_code); + // Amount HT + if (!empty($arrayfields['f.total_ht']['checked'])) { + print ''.price($obj->total_ht)."'.price($obj->total_tva)."'.price($obj->total_localtax1)."'.price($obj->total_localtax2)."'.price($obj->total_ttc)."'; - $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); - print "'.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_vat)."'.price($obj->multicurrency_total_ttc)."'.(!empty($multicurrency_totalpay) ?price($multicurrency_totalpay, 0, $langs) : ' ').''; - print (!empty($multicurrency_remaintopay) ? price($multicurrency_remaintopay, 0, $langs) : ' '); - print ''.price($marginInfo['pa_total']).''.price($marginInfo['total_margin']).''.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').''.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').''; + if ($userstatic->id) { + print $userstatic->getNomUrl(-1); } else { - $totalarray['val']['total_mark_rate'] = ''; + print ' '; + } + print "'; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->date_closing), 'dayhour', 'tzuser'); - print ''; - print dol_string_nohtmltag($obj->note_public); - print ''; - print dol_string_nohtmltag($obj->note_private); - print ''; - if (!empty($obj->fk_fac_rec_source)) { - $facrec = new FactureRec($db); - $result = $facrec->fetch($obj->fk_fac_rec_source); - if ($result < 0) { - setEventMessages($facrec->error, $facrec->errors, 'errors'); + if (!empty($arrayfields['sale_representative']['checked'])) { + // Sales representatives + print ''; + if ($obj->socid > 0) { + $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user); + if ($listsalesrepresentatives < 0) { + dol_print_error($db); + } + $nbofsalesrepresentative = count($listsalesrepresentatives); + if ($nbofsalesrepresentative > 6) { + // We print only number + print $nbofsalesrepresentative; + } elseif ($nbofsalesrepresentative > 0) { + $j = 0; + foreach ($listsalesrepresentatives as $val) { + $userstatic->id = $val['id']; + $userstatic->lastname = $val['lastname']; + $userstatic->firstname = $val['firstname']; + $userstatic->email = $val['email']; + $userstatic->statut = $val['statut']; + $userstatic->entity = $val['entity']; + $userstatic->photo = $val['photo']; + $userstatic->login = $val['login']; + $userstatic->office_phone = $val['office_phone']; + $userstatic->office_fax = $val['office_fax']; + $userstatic->user_mobile = $val['user_mobile']; + $userstatic->job = $val['job']; + $userstatic->gender = $val['gender']; + //print '
': + print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2); + $j++; + if ($j < $nbofsalesrepresentative) { + print ' '; + } + //print '
'; + } + } + //else print $langs->trans("NoSalesRepresentativeAffected"); } else { - print $facrec->getNomUrl(); + print ' '; + } + print '
'.(!empty($obj->retained_warranty) ? price($obj->retained_warranty).'%' : ' ').''.(!empty($totalpay) ? price($totalpay, 0, $langs) : ' ').''; + print (!empty($remaintopay) ? price($remaintopay, 0, $langs) : ' '); + print ''; + if (empty($conf->global->MAIN_SHOW_ONLY_CODE_MULTICURRENCY)) { + print $langs->transnoentitiesnoconv('Currency'.$obj->multicurrency_code); + } else { + print dol_escape_htmltag($obj->multicurrency_code); + } + print "'; + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); + print "'.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_vat)."'.price($obj->multicurrency_total_ttc)."'.(!empty($multicurrency_totalpay) ?price($multicurrency_totalpay, 0, $langs) : ' ').''; + print (!empty($multicurrency_remaintopay) ? price($multicurrency_remaintopay, 0, $langs) : ' '); + print ''.price($marginInfo['pa_total']).''.price($marginInfo['total_margin']).''.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').''.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_closing), 'dayhour', 'tzuser'); + print ''; + print dol_string_nohtmltag($obj->note_public); + print ''; + print dol_string_nohtmltag($obj->note_private); + print ''; + if (!empty($obj->fk_fac_rec_source)) { + $facrec = new FactureRec($db); + $result = $facrec->fetch($obj->fk_fac_rec_source); + if ($result < 0) { + setEventMessages($facrec->error, $facrec->errors, 'errors'); + } else { + print $facrec->getNomUrl(); + } + } + print ''; + print $facturestatic->getLibStatut(5, $paiement); + print "'; + if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->id, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print '
'; - print $facturestatic->getLibStatut(5, $paiement); - print "'; - if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->id, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print '
'.$objectlink->getNomUrl(1).''.$objectlink->getNomUrl(1).''.dol_escape_htmltag($objectlink->ref_client).''.dol_print_date($objectlink->date, 'day').''; diff --git a/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php index 1bca663e1ef..c3c774b79e7 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php @@ -47,7 +47,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { ?>
trans("RepeatableInvoice"); ?>getNomUrl(1); ?>getNomUrl(1); ?> date_when, 'day'); ?> hasRight("comm // TODO Mettre ici recup des actions en rapport avec la compta -$resql = ''; -if ($resql) { +$sql = ''; +if ($sql) { print '
'; print ''; print ''.$langs->trans("TasksToDo").''; print "\n"; $i = 0; - while ($i < $db->num_rows($resql)) { - $obj = $db->fetch_object($resql); + $resql = $db->query($sql); + if ($resql) { + $num_rows = $db->num_rows($resql); + while ($i < $num_rows) { + $obj = $db->fetch_object($resql); - print ''; - print ''; - $i++; + print ''; + print ''; + $i++; + } + $db->free($resql); } - $db->free($resql); print "
'.dol_print_date($db->jdate($obj->da), "day").''.$obj->label.'
'.dol_print_date($db->jdate($obj->da), "day").''.$obj->label.'

"; } diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php index ed467ec91f4..d2300128550 100644 --- a/htdocs/compta/localtax/class/localtax.class.php +++ b/htdocs/compta/localtax/class/localtax.class.php @@ -629,4 +629,38 @@ class Localtax extends CommonObject return ''; } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + global $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + if (property_exists($this, 'label')) { + $return .= ' | '.$this->label.''; + } + if (property_exists($this, 'datev')) { + $return .= '
'.$langs->trans("DateEnd").' : '.dol_print_date($this->db->jdate($this->datev), 'day').''; + } + if (property_exists($this, 'datep')) { + $return .= '
'.$langs->trans("DatePayment", '', '', '', '', 5).' : '.dol_print_date($this->db->jdate($this->datep), 'day').''; + } + if (property_exists($this, 'amount')) { + $return .= '
'.$langs->trans("Amount").' : '.price($this->amount).''; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index ad0b86a161d..f25b476fa94 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -18,11 +18,13 @@ * along with this program. If not, see . */ + /** * \file htdocs/compta/localtax/index.php * \ingroup tax - * \brief Index page of IRPF reports + * \brief Index page of localtax reports */ + require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; @@ -257,6 +259,9 @@ llxHeader('', $name); //$textnextyear=" ".img_next().""; //print load_fiche_titre($langs->transcountry($LT,$mysoc->country_code),"$textprevyear ".$langs->trans("Year")." $year_start $textnextyear", 'bill'); +$periodlink = ''; +$exportlink = ''; + report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode); //report_header($name,'',$textprevyear.$langs->trans("Year")." ".$year_start.$textnextyear,'',$description,$builddate,$exportlink,array(),$calcmode); @@ -269,7 +274,7 @@ print load_fiche_titre($langs->transcountry($LTSummary, $mysoc->country_code), ' print ''; print ''; -print '"; +print '"; if ($CalcLT == 0) { print ''; print ''; @@ -441,16 +446,6 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) { // $ $hookmanager->initHooks(array('externalbalance')); $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!is_array($x_coll) && $coll_listbuy == -1) { - $langs->load("errors"); - print ''; - break; - } - if (!is_array($x_paye) && $coll_listbuy == -2) { - print ''; - break; - } - print ''; print ''; diff --git a/htdocs/compta/localtax/list.php b/htdocs/compta/localtax/list.php index ee2e13e1d57..42f4d326811 100644 --- a/htdocs/compta/localtax/list.php +++ b/htdocs/compta/localtax/list.php @@ -35,7 +35,7 @@ if ($user->socid) { } $result = restrictedArea($user, 'tax', '', '', 'charges'); $ltt = GETPOST("localTaxType", 'int'); - +$mode = GETPOST('mode', 'alpha'); /* * View @@ -49,7 +49,14 @@ $url = DOL_URL_ROOT.'/compta/localtax/card.php?action=create&localTaxType='.$ltt if (!empty($socid)) { $url .= '&socid='.$socid; } -$newcardbutton = dolGetButtonTitle($langs->trans('NewLocalTaxPayment', ($ltt + 1)), '', 'fa fa-plus-circle', $url, '', $user->rights->tax->charges->creer); +$param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} +$newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?localTaxType='.$ltt.'&mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?localTaxType='.$ltt.'&mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('NewLocalTaxPayment', ($ltt + 1)), '', 'fa fa-plus-circle', $url, '', $user->rights->tax->charges->creer); print load_fiche_titre($langs->transcountry($ltt == 2 ? "LT2Payments" : "LT1Payments", $mysoc->country_code), $newcardbutton, 'title_accountancy'); @@ -77,19 +84,36 @@ if ($result) { while ($i < $num) { $obj = $db->fetch_object($result); - print ''; - + $localtax_static->label = $obj->label; $localtax_static->id = $obj->rowid; $localtax_static->ref = $obj->rowid; - print "\n"; - print "\n"; - print '\n"; - print '\n"; + $localtax_static->datev = $obj->datev; + $localtax_static->datep = $obj->datep; + $localtax_static->amount = $obj->amount; + $total = $total + $obj->amount; - print ''; - print "\n"; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + } + } else { + print ''; + print "\n"; + print "\n"; + print '\n"; + print '\n"; + print ''; + print "\n"; + } $i++; } print ''; diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index cc39a790527..073365fa876 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -84,7 +84,7 @@ if ($action == 'setnote' && $user->hasRight('facture', 'paiement')) { } } -if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture->paiement) { +if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('facture', 'paiement')) { $db->begin(); $result = $object->delete(); @@ -105,7 +105,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture-> } } -if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->facture->paiement) { +if ($action == 'confirm_validate' && $confirm == 'yes' && $user->hasRight('facture', 'paiement')) { $db->begin(); if ($object->validate($user) > 0) { @@ -175,7 +175,7 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->facture } } -if ($action == 'setnum_paiement' && GETPOST('num_paiement')) { +if ($action == 'setnum_paiement' && GETPOST('num_paiement') && $user->hasRight('facture', 'paiement')) { $res = $object->update_num(GETPOST('num_paiement')); if ($res === 0) { setEventMessages($langs->trans('PaymentNumberUpdateSucceeded'), null, 'mesgs'); @@ -184,7 +184,7 @@ if ($action == 'setnum_paiement' && GETPOST('num_paiement')) { } } -if ($action == 'setdatep' && GETPOST('datepday')) { +if ($action == 'setdatep' && GETPOST('datepday') && $user->hasRight('facture', 'paiement')) { $datepaye = dol_mktime(GETPOST('datephour', 'int'), GETPOST('datepmin', 'int'), GETPOST('datepsec', 'int'), GETPOST('datepmonth', 'int'), GETPOST('datepday', 'int'), GETPOST('datepyear', 'int')); $res = $object->update_date($datepaye); if ($res === 0) { @@ -193,7 +193,8 @@ if ($action == 'setdatep' && GETPOST('datepday')) { setEventMessages($langs->trans('PaymentDateUpdateFailed'), null, 'errors'); } } -if ($action == 'createbankpayment' && !empty($user->rights->facture->paiement)) { + +if ($action == 'createbankpayment' && $user->hasRight('facture', 'paiement')) { $db->begin(); // Create the record into bank for the amount of payment $object diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index e193939cdd6..1e4e7d05a7d 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -1020,4 +1020,43 @@ class RemiseCheque extends CommonObject return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + global $langs; + + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + + if (property_exists($this, 'date_bordereau')) { + $return .= '
'.$langs->trans("DateCreation").' : '.dol_print_date($this->db->jdate($this->date_bordereau), 'day').''; + } + if (property_exists($this, 'nbcheque')) { + $return .= '
'.$langs->trans("Cheque", '', '', '', '', 5).' : '.$this->nbcheque.''; + } + if (property_exists($this, 'account_id')) { + $return .= ' | '.$this->account_id.''; + } + if (method_exists($this, 'LibStatut')) { + $return .= '
'.$this->LibStatut($this->statut, 5).'
'; + } + if (property_exists($this, 'amount')) { + $return .= ' |
'.$langs->trans("Amount").' : '.price($this->amount).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index 054ef800586..38db4fca14b 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -44,6 +44,7 @@ $result = restrictedArea($user, 'banque', '', ''); $search_ref = GETPOST('search_ref', 'alpha'); $search_account = GETPOST('search_account', 'int'); $search_amount = GETPOST('search_amount', 'alpha'); +$mode = GETPOST('mode', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -149,6 +150,9 @@ if ($resql) { $num = $db->num_rows($resql); $i = 0; $param = ''; + if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); + } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.$contextpage; } @@ -160,7 +164,10 @@ if ($resql) { if (!empty($socid)) { $url .= '&socid='.$socid; } - $newcardbutton = dolGetButtonTitle($langs->trans('NewCheckDeposit'), '', 'fa fa-plus-circle', $url, '', $user->rights->banque->cheque); + $newcardbutton = ''; + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewCheckDeposit'), '', 'fa fa-plus-circle', $url, '', $user->rights->banque->cheque); print ''; if ($optioncss != '') { @@ -172,6 +179,8 @@ if ($resql) { print ''; print ''; print ''; + print ''; + print_barre_liste($langs->trans("MenuChequeDeposits"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bank_account', 0, $newcardbutton, '', $limit); @@ -220,42 +229,64 @@ if ($resql) { while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); - print ''; - - // Num ref cheque - print ''; + $checkdepositstatic->nbcheque = $objp->nbcheque; + $checkdepositstatic->amount = $objp->amount; + $checkdepositstatic->date_bordereau = $objp->date_bordereau; - // Date - print ''; // TODO Use date hour + $account = new Account($db); + $account->fetch($objp->bid); + $checkdepositstatic->account_id = $account->getNomUrl(1); - // Bank - print ''; + } } else { - print ' '; + print ''; + + // Num ref cheque + print ''; + + // Date + print ''; // TODO Use date hour + + // Bank + print ''; + + // Number of cheques + print ''; + + // Amount + print ''; + + // Statut + print ''; + + print ''; + + print "\n"; } - print ''; - - // Number of cheques - print ''; - - // Amount - print ''; - - // Statut - print ''; - - print ''; - - print "\n"; $i++; } } else { diff --git a/htdocs/compta/payment_sc/card.php b/htdocs/compta/payment_sc/card.php index 39bac75ba0c..11f7f1e454f 100644 --- a/htdocs/compta/payment_sc/card.php +++ b/htdocs/compta/payment_sc/card.php @@ -46,8 +46,6 @@ $confirm = GETPOST('confirm', 'aZ09'); if ($user->socid) { $socid = $user->socid; } -// TODO ajouter regle pour restreindre acces paiement -//$result = restrictedArea($user, 'facture', $id,''); $object = new PaymentSocialContribution($db); if ($id > 0) { @@ -57,13 +55,15 @@ if ($id > 0) { } } +$result = restrictedArea($user, 'payment_sc', $id, ''); + /* * Actions */ // Delete payment -if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->tax->charges->supprimer) { +if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('tax', 'charges', 'supprimer')) { $db->begin(); $result = $object->delete($user); @@ -77,6 +77,16 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->tax->char } } +/*if ($action == 'setdatep' && GETPOST('datepday') && $user->hasRight('tax', 'charges', 'creer')) { + $datepaye = dol_mktime(GETPOST('datephour', 'int'), GETPOST('datepmin', 'int'), GETPOST('datepsec', 'int'), GETPOST('datepmonth', 'int'), GETPOST('datepday', 'int'), GETPOST('datepyear', 'int')); + $res = $object->update_date($datepaye); + if ($res === 0) { + setEventMessages($langs->trans('PaymentDateUpdateSucceeded'), null, 'mesgs'); + } else { + setEventMessages($langs->trans('PaymentDateUpdateFailed'), null, 'errors'); + } +}*/ + /* * View diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 959630a5538..24db7fb5b64 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -72,6 +72,7 @@ class BonPrelevement extends CommonObject public $date_trans; public $user_trans; + public $method_trans; public $total; public $fetched; @@ -83,6 +84,15 @@ class BonPrelevement extends CommonObject public $invoice_in_error = array(); public $thirdparty_in_error = array(); + public $amount; + public $note; + public $datec; + + public $date_credit; + public $user_credit; + + public $type; + const STATUS_DRAFT = 0; const STATUS_TRANSFERED = 1; const STATUS_CREDITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type @@ -1856,7 +1866,7 @@ class BonPrelevement extends CommonObject $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$row_country_code.''.$CrLf; $addressline1 = strtr($row_address, array(CHR(13) => ", ", CHR(10) => "")); - $addressline2 = strtr($row_zip.(($row_zip && $row_town) ? ' ' : ''.$row_town), array(CHR(13) => ", ", CHR(10) => "")); + $addressline2 = strtr($row_zip.(($row_zip && $row_town) ? ' ' : (string) $row_town), array(CHR(13) => ", ", CHR(10) => "")); if (trim($addressline1)) { $XML_DEBITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline1), ' '), 70, 'right', 'UTF-8', 1)).''.$CrLf; } @@ -1925,7 +1935,7 @@ class BonPrelevement extends CommonObject $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$row_country_code.''.$CrLf; $addressline1 = strtr($row_address, array(CHR(13) => ", ", CHR(10) => "")); - $addressline2 = strtr($row_zip.(($row_zip && $row_town) ? ' ' : ''.$row_town), array(CHR(13) => ", ", CHR(10) => "")); + $addressline2 = strtr($row_zip.(($row_zip && $row_town) ? ' ' : (string) $row_town), array(CHR(13) => ", ", CHR(10) => "")); if (trim($addressline1)) { $XML_CREDITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline1), ' '), 70, 'right', 'UTF-8', 1)).''.$CrLf; } @@ -2397,4 +2407,38 @@ class BonPrelevement extends CommonObject */ return 0; } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + global $langs; + + + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + + if (property_exists($this, 'date_echeance')) { + $return .= '
'.$langs->trans("Date").' : '.dol_print_date($this->db->jdate($this->date_echeance), 'day').''; + } + if (property_exists($this, 'total')) { + $return .= '
'.$langs->trans("Amount").' : '.price($this->total).''; + } + if (method_exists($this, 'LibStatut')) { + $return .= '
'.$this->LibStatut($this->statut, 5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index 4906313cad1..8d9489bbec7 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -43,6 +43,7 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'directdebitcredittransferlinelist'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$mode = GETPOST('mode', 'alpha'); $type = GETPOST('type', 'aZ09'); @@ -188,12 +189,18 @@ if ($result) { $param = "&statut=".urlencode($statut); $param .= "&search_bon=".urlencode($search_bon); + if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); + } if ($type == 'bank-transfer') { $param .= '&type=bank-transfer'; } if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.urlencode($limit); } + $newcardbutton = ''; + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); print"\n\n"; print ''."\n"; @@ -206,6 +213,8 @@ if ($result) { print ''; print ''; print ''; + print ''; + if ($type != '') { print ''; } @@ -214,7 +223,7 @@ if ($result) { if ($type == 'bank-transfer') { $title = $langs->trans("CreditTransferLines"); } - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'generic', 0, '', '', $limit, 0, 0, 1); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit, 0, 0, 1); $moreforfilter = ''; @@ -262,61 +271,77 @@ if ($result) { $bon->id = $obj->rowid; $bon->ref = $obj->ref; $bon->statut = $obj->status; + $bon->date_echeance = $obj->datec; + $bon->total = $obj->amount; $company->id = $obj->socid; $company->name = $obj->name; $company->email = $obj->email; $company->code_client = $obj->code_client; - print '
'; + if ($mode == 'kanban') { + if ($i == 0) { + print '\n"; + print $bon->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print ''; + print ''; + } + } else { + print ''; - print ''; + print '\n"; - print ''; + + print '\n"; + print ''; + print ''; + + print '\n"; + + + print '\n"; + + print '\n"; + + print '\n"; + + print ''; + + print "\n"; } - print ''; - print img_object($langs->trans($link_title), $link_picto); - print ' '.$obj->invoiceref."\n"; - print ''; - print ''; - - print '\n"; - - - print '\n"; - - print '\n"; - - print '\n"; - - print ''; - - print "\n"; $i++; } } else { diff --git a/htdocs/compta/prelevement/orders_list.php b/htdocs/compta/prelevement/orders_list.php index 01ef33eea9d..bead580ab31 100644 --- a/htdocs/compta/prelevement/orders_list.php +++ b/htdocs/compta/prelevement/orders_list.php @@ -54,6 +54,8 @@ if (!$sortfield) { } $optioncss = GETPOST('optioncss', 'alpha'); +$mode = GETPOST('mode', 'alpha'); + // Get supervariables $statut = GETPOST('statut', 'int'); @@ -147,6 +149,9 @@ if ($result) { $i = 0; $param = ''; + if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); + } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -161,6 +166,8 @@ if ($result) { $selectedfields = ''; $newcardbutton = ''; + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); if ($usercancreate) { $newcardbutton .= dolGetButtonTitle($langs->trans('NewStandingOrder'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/prelevement/create.php?type='.urlencode($type)); } @@ -176,6 +183,8 @@ if ($result) { print ''; print ''; print ''; + print ''; + if ($type != '') { print ''; } @@ -220,27 +229,41 @@ if ($result) { $directdebitorder->id = $obj->rowid; $directdebitorder->ref = $obj->ref; - $directdebitorder->datec = $obj->datec; - $directdebitorder->amount = $obj->amount; + $directdebitorder->date_echeance = $obj->datec; + $directdebitorder->total = $obj->amount; $directdebitorder->statut = $obj->statut; - print ''; + if ($mode == 'kanban') { + if ($i == 0) { + print '\n"; + print $directdebitorder->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print ''; + print ''; + } + } else { + print ''; - print '\n"; + print '\n"; - print '\n"; + print '\n"; - print ''; + print '\n"; - print ''."\n"; + print ''; - print "\n"; + print ''."\n"; + + print "\n"; + } $i++; } } else { diff --git a/htdocs/compta/resultat/result.php b/htdocs/compta/resultat/result.php index 3f3e14e2d61..e49f06034aa 100644 --- a/htdocs/compta/resultat/result.php +++ b/htdocs/compta/resultat/result.php @@ -184,8 +184,8 @@ llxheader('', $langs->trans('ReportInOut')); $formaccounting = new FormAccounting($db); $form = new Form($db); -$textprevyear = ''.img_previous().''; -$textnextyear = ' '.img_next().''; +$textprevyear = ''.img_previous().''; +$textnextyear = '   '.img_next().''; @@ -309,8 +309,8 @@ if ($modecompta == 'CREANCES-DETTES') { if (!is_array($cats) && $cats < 0) { setEventMessages(null, $AccCat->errors, 'errors'); } elseif (is_array($cats) && count($cats) > 0) { + // Loop on each custom group of accounts foreach ($cats as $cat) { - // Loop on each group if (!empty($cat['category_type'])) { // category calculed // When we enter here, $sommes was filled by group of accounts @@ -319,10 +319,10 @@ if ($modecompta == 'CREANCES-DETTES') { print ''; - // Year NP - print ''; @@ -335,72 +335,97 @@ if ($modecompta == 'CREANCES-DETTES') { // Previous Fiscal year (N-1) foreach ($sommes as $code => $det) { - $vars[$code] = $det['NP']; + $vars[$code] = empty($det['NP']) ? 0 : $det['NP']; } $result = strtr($formula, $vars); + $result = str_replace('--', '+', $result); - //var_dump($result); - //$r = $AccCat->calculate($result); - $r = dol_eval($result, 1, 1, '1'); - //var_dump($r); + if (preg_match('/[a-z]/i', $result)) { + $r = 'Error bad formula: '.$result; + $rshort = 'Err'; + print ''; + } else { + //var_dump($result); + //$r = $AccCat->calculate($result); + $r = dol_eval($result, 1, 1, '1'); - print ''; + print ''; + } // Year N $code = $cat['code']; // code of categorie ('VTE', 'MAR', ...) - $sommes[$code]['NP'] += $r; + if (empty($sommes[$code]['NP'])) { + $sommes[$code]['NP'] = $r; + } else { + $sommes[$code]['NP'] += $r; + } // Current fiscal year (N) if (is_array($sommes) && !empty($sommes)) { foreach ($sommes as $code => $det) { - $vars[$code] = $det['N']; + $vars[$code] = empty($det['N']) ? 0 : $det['N']; } } $result = strtr($formula, $vars); + $result = str_replace('--', '+', $result); //$r = $AccCat->calculate($result); - $r = dol_eval($result, 1, 1, 1); + $r = dol_eval($result, 1, 1, '1'); - print ''; - $sommes[$code]['N'] += $r; + print ''; + if (empty($sommes[$code]['N'])) { + $sommes[$code]['N'] = $r; + } else { + $sommes[$code]['N'] += $r; + } // Detail by month foreach ($months as $k => $v) { if (($k + 1) >= $date_startmonth) { foreach ($sommes as $code => $det) { - $vars[$code] = $det['M'][$k]; + $vars[$code] = empty($det['M'][$k]) ? 0 : $det['M'][$k]; } $result = strtr($formula, $vars); + $result = str_replace('--', '+', $result); //$r = $AccCat->calculate($result); - $r = dol_eval($result, 1, 1, 1); + $r = dol_eval($result, 1, 1, '1'); print ''; - $sommes[$code]['M'][$k] += $r; + if (empty($sommes[$code]['M'][$k])) { + $sommes[$code]['M'][$k] = $r; + } else { + $sommes[$code]['M'][$k] += $r; + } } } + foreach ($months as $k => $v) { if (($k + 1) < $date_startmonth) { foreach ($sommes as $code => $det) { - $vars[$code] = $det['M'][$k]; + $vars[$code] = empty($det['M'][$k]) ? 0 : $det['M'][$k]; } $result = strtr($formula, $vars); + $result = str_replace('--', '+', $result); //$r = $AccCat->calculate($result); - $r = dol_eval($result, 1, 1, 1); + $r = dol_eval($result, 1, 1, '1'); print ''; - $sommes[$code]['M'][$k] += $r; + if (empty($sommes[$code]['M'][$k])) { + $sommes[$code]['M'][$k] = $r; + } else { + $sommes[$code]['M'][$k] += $r; + } } } print "\n"; //var_dump($sommes); - } else // normal category - { + } else { // normal category $code = $cat['code']; // Category code we process $totCat = array(); @@ -414,27 +439,37 @@ if ($modecompta == 'CREANCES-DETTES') { // Set $cpts with array of accounts in the category/group $cpts = $AccCat->getCptsCat($cat['rowid']); // We should loop over empty $cpts array, else the category _code_ is used in the formula, which leads to wrong result if the code is a number. - if (empty($cpts)) $cpts[] = array(); - + if (empty($cpts)) { + $cpts[] = array(); + } $arrayofaccountforfilter = array(); foreach ($cpts as $i => $cpt) { // Loop on each account. - $arrayofaccountforfilter[] = $cpt['account_number']; + if (isset($cpt['account_number'])) { + $arrayofaccountforfilter[] = $cpt['account_number']; + } } // N-1 if (!empty($arrayofaccountforfilter)) { - $return = $AccCat->getSumDebitCredit($arrayofaccountforfilter, $date_start_previous, $date_end_previous, $cat['dc'] ? $cat['dc'] : 0); - + $return = $AccCat->getSumDebitCredit($arrayofaccountforfilter, $date_start_previous, $date_end_previous, empty($cat['dc']) ? 0 : $cat['dc']); if ($return < 0) { setEventMessages(null, $AccCat->errors, 'errors'); $resultNP = 0; } else { - foreach ($cpts as $i => $cpt) { // Loop on each account. + foreach ($cpts as $i => $cpt) { // Loop on each account found $resultNP = empty($AccCat->sdcperaccount[$cpt['account_number']]) ? 0 : $AccCat->sdcperaccount[$cpt['account_number']]; - $totCat['NP'] += $resultNP; - $sommes[$code]['NP'] += $resultNP; + if (empty($totCat['NP'])) { + $totCat['NP'] = $resultNP; + } else { + $totCat['NP'] += $resultNP; + } + if (empty($sommes[$code]['NP'])) { + $sommes[$code]['NP'] = $resultNP; + } else { + $sommes[$code]['NP'] += $resultNP; + } $totPerAccount[$cpt['account_number']]['NP'] = $resultNP; } } @@ -456,63 +491,88 @@ if ($modecompta == 'CREANCES-DETTES') { } //var_dump($monthtoprocess.'_'.$yeartoprocess); - $return = $AccCat->getSumDebitCredit($cpt['account_number'], $date_start, $date_end, $cat['dc'] ? $cat['dc'] : 0, 'nofilter', $monthtoprocess, $yeartoprocess); - if ($return < 0) { - setEventMessages(null, $AccCat->errors, 'errors'); - $resultM = 0; + if (isset($cpt['account_number'])) { + $return = $AccCat->getSumDebitCredit($cpt['account_number'], $date_start, $date_end, empty($cat['dc']) ? 0 : $cat['dc'], 'nofilter', $monthtoprocess, $yeartoprocess); + if ($return < 0) { + setEventMessages(null, $AccCat->errors, 'errors'); + $resultM = 0; + } else { + $resultM = $AccCat->sdc; + } } else { - $resultM = $AccCat->sdc; + $resultM = 0; + } + if (empty($totCat['M'][$k])) { + $totCat['M'][$k] = $resultM; + } else { + $totCat['M'][$k] += $resultM; + } + if (empty($sommes[$code]['M'][$k])) { + $sommes[$code]['M'][$k] = $resultM; + } else { + $sommes[$code]['M'][$k] += $resultM; + } + if (isset($cpt['account_number'])) { + $totPerAccount[$cpt['account_number']]['M'][$k] = $resultM; } - $totCat['M'][$k] += $resultM; - $sommes[$code]['M'][$k] += $resultM; - $totPerAccount[$cpt['account_number']]['M'][$k] = $resultM; $resultN += $resultM; } - $totCat['N'] += $resultN; - $sommes[$code]['N'] += $resultN; - $totPerAccount[$cpt['account_number']]['N'] = $resultN; + if (empty($totCat)) { + $totCat['N'] = $resultN; + } else { + $totCat['N'] += $resultN; + } + if (empty($sommes[$code]['N'])) { + $sommes[$code]['N'] = $resultN; + } else { + $sommes[$code]['N'] += $resultN; + } + if (isset($cpt['account_number'])) { + $totPerAccount[$cpt['account_number']]['N'] = $resultN; + } } // Now output columns for row $code ('VTE', 'MAR', ...) - print ""; + print ''; // Column group - print ''; // Label of group - print ''; print ''; - print ''; + print ''; // Each month foreach ($totCat['M'] as $k => $v) { @@ -531,30 +591,48 @@ if ($modecompta == 'CREANCES-DETTES') { // Loop on detail of all accounts to output the detail if ($showaccountdetail != 'no') { foreach ($cpts as $i => $cpt) { - $resultNP = $totPerAccount[$cpt['account_number']]['NP']; - $resultN = $totPerAccount[$cpt['account_number']]['N']; + if (isset($cpt['account_number'])) { + $resultNP = $totPerAccount[$cpt['account_number']]['NP']; + $resultN = $totPerAccount[$cpt['account_number']]['N']; + } else { + $resultNP = 0; + $resultN = 0; + } if ($showaccountdetail == 'all' || $resultN != 0) { print ''; print ''; - print ''; print ''; - print ''; + print ''; // Make one call for each month foreach ($months as $k => $v) { if (($k + 1) >= $date_startmonth) { - $resultM = $totPerAccount[$cpt['account_number']]['M'][$k]; + if (isset($cpt['account_number'])) { + $resultM = $totPerAccount[$cpt['account_number']]['M'][$k]; + } else { + $resultM = 0; + } print ''; } } foreach ($months as $k => $v) { if (($k + 1) < $date_startmonth) { - $resultM = $totPerAccount[$cpt['account_number']]['M'][$k]; + if (isset($cpt['account_number'])) { + $resultM = empty($totPerAccount[$cpt['account_number']]['M'][$k]) ? 0 : $totPerAccount[$cpt['account_number']]['M'][$k]; + } else { + $resultM = 0; + } print ''; } } diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 37b3540a0f5..b5e98b3b62e 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -749,4 +749,38 @@ class ChargeSociales extends CommonObject $this->type = 1; $this->type_label = 'Type of social contribution'; } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + global $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + if (property_exists($this, 'fk_project') && !empty($this->fk_project)) { + $return .= ' | '.$this->fk_project.''; + } + if (property_exists($this, 'date_ech')) { + $return .= '
'.$langs->trans("DateEnd").':'.dol_print_date($this->date_ech).''; + } + if (property_exists($this, 'amount')) { + $return .= '
'.$langs->trans("Amount").' : '.price($this->amount).''; + } + if (method_exists($this, 'LibStatut')) { + $return .= '
'.$this->LibStatut($this->paye, 5, $this->alreadypaid).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index f70ed44de0c..a925fe6968d 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -47,6 +47,8 @@ $massaction = GETPOST('massaction', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'sclist'; +$mode = GETPOST('mode', 'alpha'); + $search_ref = GETPOST('search_ref', 'int'); $search_label = GETPOST('search_label', 'alpha'); @@ -294,6 +296,9 @@ $num = $db->num_rows($resql); $i = 0; $param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -367,6 +372,8 @@ if ($search_date_limit_endyear) { } $newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); if ($user->rights->tax->charges->creer) { $newcardbutton .= dolGetButtonTitle($langs->trans('MenuNewSocialContribution'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/sociales/card.php?action=create'); } @@ -382,6 +389,8 @@ print ''; print ''; print ''; print ''; +print ''; + $center = ''; @@ -501,9 +510,9 @@ if (!empty($arrayfields['cs.amount']['checked'])) { // Filter: Status if (!empty($arrayfields['cs.paye']['checked'])) { - print ''; } @@ -576,162 +585,179 @@ while ($i < min($num, $limit)) { $chargesociale_static->ref = $obj->rowid; $chargesociale_static->label = $obj->label; $chargesociale_static->type_label = $obj->type_label; + $chargesociale_static->amount = $obj->amount; + $chargesociale_static->paye = $obj->paye; + $chargesociale_static->date_ech = $obj->date_ech; + if (isModEnabled('project')) { $projectstatic->id = $obj->project_id; $projectstatic->ref = $obj->project_ref; $projectstatic->title = $obj->project_label; } - - print ''; - - // Line number - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; - if (!$i) { - $totalarray['nbfield']++; + $chargesociale_static->fk_project = $projectstatic->getNomUrl(); + print $chargesociale_static->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print ''; + print ''; } - } + } else { + print ''; - // Label - if (!empty($arrayfields['cs.libelle']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Type - if (!empty($arrayfields['cs.fk_type']['checked'])) { - $typelabeltoshow = $obj->type_label; - $typelabelpopup = $obj->type_label; - if (isModEnabled('accounting')) { - $typelabelpopup .= ' - '.$langs->trans("AccountancyCode").': '.$obj->type_accountancy_code; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Date - if (!empty($arrayfields['cs.date_ech']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Date end period - if (!empty($arrayfields['cs.periode']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Project ref - if (!empty($arrayfields['p.ref']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - if (!empty($arrayfields['cs.fk_user']['checked'])) { - // Employee - print ''; + if (!$i) { + $totalarray['nbfield']++; } - print $ustatic->getNomUrl(-1); } - print "\n"; + + // Ref + if (!empty($arrayfields['cs.rowid']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Label + if (!empty($arrayfields['cs.libelle']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Type + if (!empty($arrayfields['cs.fk_type']['checked'])) { + $typelabeltoshow = $obj->type_label; + $typelabelpopup = $obj->type_label; + if (isModEnabled('accounting')) { + $typelabelpopup .= ' - '.$langs->trans("AccountancyCode").': '.$obj->type_accountancy_code; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date + if (!empty($arrayfields['cs.date_ech']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date end period + if (!empty($arrayfields['cs.periode']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Project ref + if (!empty($arrayfields['p.ref']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + if (!empty($arrayfields['cs.fk_user']['checked'])) { + // Employee + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Type + if (!empty($arrayfields['cs.fk_mode_reglement']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Account + if (!empty($arrayfields['cs.fk_account']['checked'])) { + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Amount + if (!empty($arrayfields['cs.amount']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield'; + } + $totalarray['val']['totalttcfield'] += $obj->amount; + } + + // Status + if (!empty($arrayfields['cs.paye']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Buttons + print ''; if (!$i) { $totalarray['nbfield']++; } + + print ''."\n"; } - - // Type - if (!empty($arrayfields['cs.fk_mode_reglement']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Account - if (!empty($arrayfields['cs.fk_account']['checked'])) { - print ''; - if (!$i) $totalarray['nbfield']++; - } - - // Amount - if (!empty($arrayfields['cs.amount']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield'; - } - $totalarray['val']['totalttcfield'] += $obj->amount; - } - - // Status - if (!empty($arrayfields['cs.paye']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Buttons - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - - print ''."\n"; - $i++; } diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index dc0fa94030c..e747c4380a4 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -324,7 +324,7 @@ if ($modecompta == 'CREANCES-DETTES') { } if ($selected_cat === -2) { // Without any category $sql .= " AND cp.fk_product is null"; - } elseif ($selected_cat) { // Into a specific category + } elseif ($selected_cat > 0) { // Into a specific category if ($subcat) { $TListOfCats = $categorie->get_full_arbo('product', $selected_cat, 1); diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index e7c7678b818..c78b41ba274 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -333,6 +333,10 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char $object->id = $object->ref = null; $object->paye = 0; + if (GETPOST('amount', 'alphanohtml')) { + $object->amount = price2num(GETPOST('amount', 'alphanohtml'), 'MT', 2); + } + if (GETPOST('clone_label', 'alphanohtml')) { $object->label = GETPOST('clone_label', 'alphanohtml'); } else { @@ -405,7 +409,7 @@ if ($action == 'create') { $("#label_type_payment").removeClass("fieldrequired"); $(".hide_if_no_auto_create_payment").hide(); } - }; + } $("#radiopayment").click(function() { $("#label").val($(this).data("label")); }); @@ -540,6 +544,7 @@ if ($id > 0) { //$formquestion[] = array('type' => 'date', 'name' => 'clone_date_ech', 'label' => $langs->trans("Date"), 'value' => -1); $formquestion[] = array('type' => 'date', 'name' => 'clone_period', 'label' => $langs->trans("PeriodEndDate"), 'value' => -1); + $formquestion[] = array('type' => 'text', 'name' => 'amount', 'label' => $langs->trans("Amount"), 'value' => price($object->amount), 'morecss' => 'width100'); print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneVAT', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 240); } diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index dffba34d59b..78fb178ff27 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -906,4 +906,39 @@ class Tva extends CommonObject return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + global $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + //$return .= ''; // Can be image + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + if (property_exists($this, 'amount')) { + $return .= ' | '.$langs->trans("Amount").' : '.price($this->amount).''; + } + if (property_exists($this, 'type_payment')) { + $return .= '
'.$langs->trans("Payement").' : '.$this->type_payment.''; + } + if (property_exists($this, 'datev')) { + $return .= '
'.$langs->trans("DateEnd").' : '.dol_print_date($this->datev).''; + } + if (method_exists($this, 'LibStatut')) { + $return .= '
'.$this->LibStatut($this->paiementtype, 5, $this->alreadypaid).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index f0efe305d8c..37e7f75b306 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -229,6 +229,9 @@ llxHeader('', $name); //$textnextyear=" ".img_next($langs->trans("Next"), 'class="valignbottom"').""; //print load_fiche_titre($langs->transcountry("VAT", $mysoc->country_code), $textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, 'bill'); +$periodlink = ''; +$exportlink = ''; + report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode); //report_header($name,'',$textprevyear.$langs->trans("Year")." ".$year_start.$textnextyear,'',$description,$builddate,$exportlink,array(),$calcmode); @@ -242,7 +245,7 @@ if ($refresh === true) { print '
'.$langs->trans("Year")." ".$y."'.$langs->trans("Year")."'.$langs->transcountry($LTCustomer, $mysoc->country_code).''.$langs->transcountry($LTSupplier, $mysoc->country_code).'
'.$langs->trans("ErrorNoAccountancyModuleLoaded").'
'.$langs->trans("FeatureNotYetAvailable").'
'.dol_print_date(dol_mktime(0, 0, 0, $m, 1, $y), "%b %Y").'
".$localtax_static->getNomUrl(1)."".dol_trunc($obj->label, 40)."'.dol_print_date($db->jdate($obj->datev), 'day')."'.dol_print_date($db->jdate($obj->datep), 'day')."'.price($obj->amount).'
'; + print '
'; + } + // Output Kanban + print $localtax_static->getKanbanView(''); + if ($i == ($num - 1)) { + print '
'; + print '
".$localtax_static->getNomUrl(1)."".dol_trunc($obj->label, 40)."'.dol_print_date($db->jdate($obj->datev), 'day')."'.dol_print_date($db->jdate($obj->datep), 'day')."'.price($obj->amount).'
'.$langs->trans("Total").'
'; $checkdepositstatic->id = $objp->rowid; $checkdepositstatic->ref = ($objp->ref ? $objp->ref : $objp->rowid); $checkdepositstatic->statut = $objp->statut; - print $checkdepositstatic->getNomUrl(1); - print ''.dol_print_date($db->jdate($objp->date_bordereau), 'day').''; - if ($objp->bid) { - print ''.img_object($langs->trans("ShowAccount"), 'account').' '.$objp->label.''; + if ($mode == 'kanban') { + if ($i == 0) { + print '
'; + print '
'; + } + // Output Kanban + print $checkdepositstatic->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print '
'; + print '
'; + + print $checkdepositstatic->getNomUrl(1); + print ''.dol_print_date($db->jdate($objp->date_bordereau), 'day').''; + if ($objp->bid) { + print ''.img_object($langs->trans("ShowAccount"), 'account').' '.$objp->label.''; + } else { + print ' '; + } + print ''.$objp->nbcheque.''.price($objp->amount).''; + print $checkdepositstatic->LibStatut($objp->statut, 5); + print '
'.$objp->nbcheque.''.price($objp->amount).''; - print $checkdepositstatic->LibStatut($objp->statut, 5); - print '
'; + print '
'; + } + // Output Kanban - print '
'; - print $bon->getNomUrl(1); - print "
'; - print $line->LibStatut($obj->statut_ligne, 2); - print " "; - print ''; - print substr('000000'.$obj->rowid_ligne, -6); - print ''; + print $bon->getNomUrl(1); + print "'; - $link_to_bill = '/compta/facture/card.php?facid='; - $link_title = 'Invoice'; - $link_picto = 'bill'; - if ($type == 'bank-transfer') { - $link_to_bill = '/fourn/facture/card.php?facid='; - $link_title = 'SupplierInvoice'; - $link_picto = 'supplier_invoice'; + print ''; + print $line->LibStatut($obj->statut_ligne, 2); + print " "; + print ''; + print substr('000000'.$obj->rowid_ligne, -6); + print ''; + $link_to_bill = '/compta/facture/card.php?facid='; + $link_title = 'Invoice'; + $link_picto = 'bill'; + if ($type == 'bank-transfer') { + $link_to_bill = '/fourn/facture/card.php?facid='; + $link_title = 'SupplierInvoice'; + $link_picto = 'supplier_invoice'; + } + print ''; + print img_object($langs->trans($link_title), $link_picto); + print ' '.$obj->invoiceref."'; + print $company->getNomUrl(1); + print "'; + $link_to_tab = '/comm/card.php?socid='; + $link_code = $obj->code_client; + if ($type == 'bank-transfer') { + $link_to_tab = '/fourn/card.php?socid='; + $link_code = $obj->code_fournisseur; + } + print ''.$link_code."'.dol_print_date($db->jdate($obj->datec), 'day')."'.price($obj->amount)." 
'; - print $company->getNomUrl(1); - print "'; - $link_to_tab = '/comm/card.php?socid='; - $link_code = $obj->code_client; - if ($type == 'bank-transfer') { - $link_to_tab = '/fourn/card.php?socid='; - $link_code = $obj->code_fournisseur; - } - print ''.$link_code."'.dol_print_date($db->jdate($obj->datec), 'day')."'.price($obj->amount)." 
'; + print '
'; + } + // Output Kanban - print '
'; - print $directdebitorder->getNomUrl(1); - print "
'.dol_print_date($db->jdate($obj->datec), 'day')."'; + print $directdebitorder->getNomUrl(1); + print "'.price($obj->amount)."'.dol_print_date($db->jdate($obj->datec), 'day')."'; - print $bon->LibStatut($obj->statut, 5); - print ''.price($obj->amount)."'; + print $bon->LibStatut($obj->statut, 5); + print '
'; + // Code and Label + print ''; print dol_escape_htmltag($cat['code']); - print ''; + print ''; print dol_escape_htmltag($cat['label']); print ''.$rshort.''.price($r).''.price($r).''.price($r).''.price($r).''.price($r).''.price($r).'
'; + print ''; print dol_escape_htmltag($cat['code']); print ''; - print dol_escape_htmltag($cat['label']); + $labeltoshow = dol_escape_htmltag($cat['label']); if (count($cpts) > 0 && !empty($cpts[0])) { // Show example of 5 first accounting accounts $i = 0; foreach ($cpts as $cpt) { if ($i > 5) { - print '...)'; + $labeltoshow .= '...)'; break; } if ($i > 0) { - print ', '; + $labeltoshow .= ', '; } else { - print ' ('; + $labeltoshow .= ' ('; } - print dol_escape_htmltag($cpt['account_number']); + $labeltoshow .= dol_escape_htmltag($cpt['account_number']); $i++; } if ($i <= 5) { - print ')'; + $labeltoshow .= ')'; } } else { - print ' - '.$langs->trans("GroupIsEmptyCheckSetup").''; + $labeltoshow .= ' - '.$langs->trans("GroupIsEmptyCheckSetup").''; } + print ''; + print $labeltoshow; print ''.price($totCat['NP']).''.price($totCat['N']).''.price($totCat['N']).'
'; - print '     '.length_accountg($cpt['account_number']); - print ' - '; - print $cpt['account_label']; + + if (isset($cpt['account_number'])) { + $labeldetail = '     '.length_accountg($cpt['account_number']).' - '.$cpt['account_label']; + } else { + $labeldetail = '-'; + } + + print ''; + print dol_escape_htmltag($labeldetail); print ''.price($resultNP).''.price($resultN).''.price($resultN).''.price($resultM).''.price($resultM).''; + print ''; $liststatus = array('0'=>$langs->trans("Unpaid"), '1'=>$langs->trans("Paid")); - print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100 onrightofpage', 1); + print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage', 1); print '
'.(($offset * $limit) + $i).'
'; + print '
'; } - } + // Output Kanban - // Ref - if (!empty($arrayfields['cs.rowid']['checked'])) { - print '
'.$chargesociale_static->getNomUrl(1, '20').'
'.dol_escape_htmltag($obj->label).''.dol_escape_htmltag($typelabeltoshow).''.dol_print_date($db->jdate($obj->date_ech), 'day').''.dol_print_date($db->jdate($obj->periode), 'day').''; - if ($obj->project_id > 0) { - print $projectstatic->getNomUrl(1); - } - print ''; - if (!empty($obj->fk_user)) { - if (!empty($TLoadedUsers[$obj->fk_user])) { - $ustatic = $TLoadedUsers[$obj->fk_user]; - } else { - $ustatic = new User($db); - $ustatic->fetch($obj->fk_user); - $TLoadedUsers[$obj->fk_user] = $ustatic; + // Line number + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { + print ''.(($offset * $limit) + $i).''.$chargesociale_static->getNomUrl(1, '20').''.dol_escape_htmltag($obj->label).''.dol_escape_htmltag($typelabeltoshow).''.dol_print_date($db->jdate($obj->date_ech), 'day').''.dol_print_date($db->jdate($obj->periode), 'day').''; + if ($obj->project_id > 0) { + print $projectstatic->getNomUrl(1); + } + print ''; + if (!empty($obj->fk_user)) { + if (!empty($TLoadedUsers[$obj->fk_user])) { + $ustatic = $TLoadedUsers[$obj->fk_user]; + } else { + $ustatic = new User($db); + $ustatic->fetch($obj->fk_user); + $TLoadedUsers[$obj->fk_user] = $ustatic; + } + print $ustatic->getNomUrl(-1); + } + print "payment_code)).'">'; + if (!empty($obj->payment_code)) { + print $langs->trans("PaymentTypeShort".$obj->payment_code); + } + print ''; + if ($obj->fk_account > 0) { + $bankstatic->id = $obj->fk_account; + $bankstatic->ref = $obj->bref; + $bankstatic->number = $obj->bnumber; + $bankstatic->iban = $obj->iban; + $bankstatic->bic = $obj->bic; + $bankstatic->currency_code = $langs->trans("Currency".$obj->currency_code); + $bankstatic->account_number = $obj->account_number; + $bankstatic->clos = $obj->clos; + + //$accountingjournal->fetch($obj->fk_accountancy_journal); + //$bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); + + $bankstatic->label = $obj->blabel; + print $bankstatic->getNomUrl(1); + } + print ''.price($obj->amount).''.$chargesociale_static->LibStatut($obj->paye, 5, $obj->alreadypayed).'
payment_code)).'">'; - if (!empty($obj->payment_code)) { - print $langs->trans("PaymentTypeShort".$obj->payment_code); - } - print ''; - if ($obj->fk_account > 0) { - $bankstatic->id = $obj->fk_account; - $bankstatic->ref = $obj->bref; - $bankstatic->number = $obj->bnumber; - $bankstatic->iban = $obj->iban; - $bankstatic->bic = $obj->bic; - $bankstatic->currency_code = $langs->trans("Currency".$obj->currency_code); - $bankstatic->account_number = $obj->account_number; - $bankstatic->clos = $obj->clos; - - //$accountingjournal->fetch($obj->fk_accountancy_journal); - //$bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); - - $bankstatic->label = $obj->blabel; - print $bankstatic->getNomUrl(1); - } - print ''.price($obj->amount).''.$chargesociale_static->LibStatut($obj->paye, 5, $obj->alreadypayed).'
'; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -389,16 +392,6 @@ if ($refresh === true) { $hookmanager->initHooks(array('externalbalance')); $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!is_array($x_coll) && $coll_listbuy == -1) { - $langs->load("errors"); - print ''; - break; - } - if (!is_array($x_paye) && $coll_listbuy == -2) { - print ''; - break; - } - print ''; print ''; diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 1c70cf93c22..c839625a705 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -44,6 +44,7 @@ $massaction = GETPOST('massaction', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'salestaxeslist'; +$mode = GETPOST('mode', 'alpha'); $search_ref = GETPOST('search_ref', 'alpha'); $search_label = GETPOST('search_label', 'alpha'); @@ -230,6 +231,9 @@ if (!$resql) { $num = $db->num_rows($resql); $param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER['PHP_SELF']) { $param .= '&contextpage='.$contextpage; } @@ -317,7 +321,10 @@ $url = DOL_URL_ROOT.'/compta/tva/card.php?action=create'; if (!empty($socid)) { $url .= '&socid='.$socid; } -$newcardbutton = dolGetButtonTitle($langs->trans('NewVATPayment'), '', 'fa fa-plus-circle', $url, '', $user->rights->tax->charges->creer); +$newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('NewVATPayment'), '', 'fa fa-plus-circle', $url, '', $user->rights->tax->charges->creer); print_barre_liste($langs->trans("VATDeclarations"), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); $varpage = empty($contextpage) ? $_SERVER['PHP_SELF'] : $contextpage; @@ -398,9 +405,9 @@ if (!empty($arrayfields['t.amount']['checked'])) { // Status if (!empty($arrayfields['t.status']['checked'])) { - print ''; } @@ -461,116 +468,134 @@ while ($i < min($num, $limit)) { $tva_static->id = $obj->rowid; $tva_static->ref = $obj->rowid; $tva_static->label = $obj->label; + $tva_static->paiementtype = $obj->paye; + $tva_static->type_payment = $obj->payment_code; + $tva_static->datev = $obj->datev; + $tva_static->amount = $obj->amount; - print ''; - - // No - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; - if (!$i) { - $totalarray['nbfield']++; + print $tva_static->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print ''; + print ''; } - } + } else { + print ''; - // Label - if (!empty($arrayfields['t.label']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // No + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Date end period - if (!empty($arrayfields['t.datev']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Ref + if (!empty($arrayfields['t.rowid']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Date payment - /*if (!empty($arrayfields['t.datep']['checked'])) { - print ''; - if (!$i) $totalarray['nbfield']++; - }*/ - - // Type - if (!empty($arrayfields['t.fk_typepayment']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Label + if (!empty($arrayfields['t.label']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Account - if (!empty($arrayfields['t.fk_account']['checked'])) { - print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - print ''; - if (!$i) $totalarray['nbfield']++; - } - // Amount - if (!empty($arrayfields['t.amount']['checked'])) { - $total = $total + $obj->amount; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - $totalarray['pos'][$totalarray['nbfield']] = 'amount'; - if (empty($totalarray['val']['amount'])) { - $totalarray['val']['amount'] = $obj->amount; - } else { - $totalarray['val']['amount'] += $obj->amount; - } - } + // Date payment + /*if (!empty($arrayfields['t.datep']['checked'])) { + print ''; + if (!$i) $totalarray['nbfield']++; + }*/ - if (!empty($arrayfields['t.status']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Type + if (!empty($arrayfields['t.fk_typepayment']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } + + // Account + if (!empty($arrayfields['t.fk_account']['checked'])) { + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Amount if (!empty($arrayfields['t.amount']['checked'])) { - $totalarray['pos'][$totalarray['nbfield']] = ''; + $total = $total + $obj->amount; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + $totalarray['pos'][$totalarray['nbfield']] = 'amount'; + if (empty($totalarray['val']['amount'])) { + $totalarray['val']['amount'] = $obj->amount; + } else { + $totalarray['val']['amount'] += $obj->amount; + } } + + if (!empty($arrayfields['t.status']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!empty($arrayfields['t.amount']['checked'])) { + $totalarray['pos'][$totalarray['nbfield']] = ''; + } + } + + // Buttons + print ''; + + print ''; } - // Buttons - print ''; - - print ''; - $i++; } diff --git a/htdocs/contact/canvas/default/actions_contactcard_default.class.php b/htdocs/contact/canvas/default/actions_contactcard_default.class.php index 846f7440f97..f126b8c32a0 100644 --- a/htdocs/contact/canvas/default/actions_contactcard_default.class.php +++ b/htdocs/contact/canvas/default/actions_contactcard_default.class.php @@ -115,30 +115,5 @@ class ActionsContactCardDefault extends ActionsContactCardCommon $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1); } } - - if ($action == 'list') { - $this->LoadListDatas($limit, $offset, $sortfield, $sortorder); - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Fetch datas list and save into ->list_datas - * - * @param int $limit Limit number of responses - * @param int $offset Offset for first response - * @param string $sortfield Sort field - * @param string $sortorder Sort order ('ASC' or 'DESC') - * @return void - */ - public function LoadListDatas($limit, $offset, $sortfield, $sortorder) - { - // phpcs:enable - global $conf, $langs; - - //$this->getFieldList(); - - $this->list_datas = array(); } } diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index c5184a18454..6cf7d3051f3 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -362,7 +362,7 @@ if (empty($reshook)) { if (!$error) { $contactid = GETPOST("contactid", 'int'); $object->fetch($contactid); - $object->fetchRoles($contactid); + $object->fetchRoles(); // Photo save $dir = $conf->societe->multidir_output[$object->entity]."/contact/".$object->id."/photos"; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 4659fe08c17..67b3ce2a38a 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1700,8 +1700,8 @@ class Contact extends CommonObject * Adds it to non existing supplied categories. * Existing categories are left untouch. * - * @param int[]|int $categories Category or categories IDs - * @return void + * @param int[]|int $categories Category or categories IDs + * @return int <0 if KO, >0 if OK */ public function setCategories($categories) { @@ -1789,6 +1789,8 @@ class Contact extends CommonObject $sql = "SELECT sc.fk_socpeople as id, sc.fk_c_type_contact"; $sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact tc"; $sql .= ", ".MAIN_DB_PREFIX."societe_contacts sc"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."socpeople sp"; + $sql .= " ON sc.fk_socpeople = sp.rowid AND sp.statut = 1"; $sql .= " WHERE sc.fk_soc =".((int) $this->socid); $sql .= " AND sc.fk_c_type_contact=tc.rowid"; $sql .= " AND tc.element = '".$this->db->escape($element)."'"; diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 852f00349c0..a025ef81b97 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -73,6 +73,7 @@ $search_firstlast_only = GETPOST("search_firstlast_only", 'alpha'); $search_lastname = GETPOST("search_lastname", 'alpha'); $search_firstname = GETPOST("search_firstname", 'alpha'); $search_societe = GETPOST("search_societe", 'alpha'); +$search_societe_alias = GETPOST("search_societe_alias", 'alpha'); $search_poste = GETPOST("search_poste", 'alpha'); $search_phone_perso = GETPOST("search_phone_perso", 'alpha'); $search_phone_pro = GETPOST("search_phone_pro", 'alpha'); @@ -193,6 +194,7 @@ foreach ($object->fields as $key => $val) { // Add none object fields for "search in all" if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { $fieldstosearchall['s.nom'] = "ThirdParty"; + $fieldstosearchall['s.name_alias'] = "AliasNames"; } // Definition of fields for list @@ -214,6 +216,7 @@ foreach ($object->fields as $key => $val) { $arrayfields['country.code_iso'] = array('label'=>"Country", 'position'=>66, 'checked'=>0); if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { $arrayfields['s.nom'] = array('label'=>"ThirdParty", 'position'=>113, 'checked'=> 1); + $arrayfields['s.name_alias'] = array('label'=>"AliasNameShort", 'position'=>114, 'checked'=> 1); } $arrayfields['unsubscribed'] = array( @@ -278,6 +281,7 @@ if (empty($reshook)) { $search_lastname = ""; $search_firstname = ""; $search_societe = ""; + $search_societe_alias = ""; $search_town = ""; $search_address = ""; $search_zip = ""; @@ -353,6 +357,9 @@ if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES) $contactstatic->loadCacheOfProspStatus(); } +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + // Select every potentiels, and note each potentiels which fit in search parameters $tab_level = array(); $sql = "SELECT code, label, sortorder"; @@ -373,7 +380,7 @@ if ($resql) { dol_print_error($db); } -$sql = "SELECT s.rowid as socid, s.nom as name,"; +$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias as alias,"; $sql .= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.address, p.zip, p.town, p.poste, p.email,"; $sql .= " p.socialnetworks, p.photo,"; $sql .= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.datec as date_creation, p.tms as date_update,"; @@ -406,6 +413,10 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_stcommcontact as st ON st.id = p.fk_stco if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; } +// Add fields from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; $sql .= ' WHERE p.entity IN ('.getEntity('contact').')'; if (empty($user->rights->societe->client->voir) && !$socid) { //restriction $sql .= " AND (sc.fk_user = ".((int) $user->id)." OR p.fk_soc IS NULL)"; @@ -545,8 +556,15 @@ if ($search_lastname) { if ($search_firstname) { $sql .= natural_search('p.firstname', $search_firstname); } -if ($search_societe) { - $sql .= natural_search(empty($conf->global->SOCIETE_DISABLE_CONTACTS) ? 's.nom' : 'p.fk_soc', $search_societe); +if (empty($arrayfields['s.name_alias']['checked']) && $search_societe) { + $sql .= natural_search(array("s.nom", "s.name_alias"), $search_societe); +} else { + if ($search_societe) { + $sql .= natural_search('s.nom', $search_societe); + } + if ($search_societe_alias) { + $sql .= natural_search('s.name_alias', $search_societe_alias); + } } if ($search_country) { $sql .= " AND p.fk_pays IN (".$db->sanitize($search_country).')'; @@ -716,6 +734,9 @@ if ($search_firstname != '') { if ($search_societe != '') { $param .= '&search_societe='.urlencode($search_societe); } +if ($search_societe_alias != '') { + $param .= '&search_societe_alias='.urlencode($search_societe_alias); +} if ($search_address != '') { $param .= '&search_address='.urlencode($search_address); } @@ -993,6 +1014,12 @@ if (!empty($arrayfields['p.fk_soc']['checked']) || !empty($arrayfields['s.nom'][ print ''; print ''; } +// Alias +if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; +} if (!empty($arrayfields['p.priv']['checked'])) { print ''; } if (!empty($arrayfields['p.import_key']['checked'])) { @@ -1114,6 +1141,9 @@ if (!empty($arrayfields['p.fk_soc']['checked'])) { if (!empty($arrayfields['s.nom']['checked'])) { print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $begin, $param, '', $sortfield, $sortorder); } +if (!empty($arrayfields['s.name_alias']['checked'])) { + print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], "s.name_alias", $begin, $param, '', $sortfield, $sortorder); +} if (!empty($arrayfields['p.priv']['checked'])) { print_liste_field_titre($arrayfields['p.priv']['label'], $_SERVER["PHP_SELF"], "p.priv", $begin, $param, '', $sortfield, $sortorder, 'center '); } @@ -1347,7 +1377,7 @@ while ($i < min($num, $limit)) { if ($obj->socid) { $objsoc = new Societe($db); $objsoc->fetch($obj->socid); - print $objsoc->getNomUrl(1); + print $objsoc->getNomUrl(1, '', 100, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); } else { print ' '; } @@ -1357,6 +1387,16 @@ while ($i < min($num, $limit)) { } } + // Alias name + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Private/Public if (!empty($arrayfields['p.priv']['checked'])) { print ''; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 220356310fa..123366fd630 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -427,6 +427,7 @@ if (empty($reshook)) { } else { $idprod = GETPOST('idprod', 'int'); } + $tva_tx = GETPOST('tva_tx', 'alpha'); $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS'); @@ -474,11 +475,11 @@ if (empty($reshook)) { $prod->fetch($idprod); // Update if prices fields are defined - $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); + /*$tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); if (empty($tva_tx)) { $tva_npr = 0; - } + }*/ $price_min = $prod->price_min; $price_min_ttc = $prod->price_min_ttc; @@ -500,14 +501,14 @@ if (empty($reshook)) { if (count($prodcustprice->lines) > 0) { $price_min = price($prodcustprice->lines[0]->price_min); $price_min_ttc = price($prodcustprice->lines[0]->price_min_ttc); - $tva_tx = $prodcustprice->lines[0]->tva_tx; + /*$tva_tx = $prodcustprice->lines[0]->tva_tx; if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) { $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; } $tva_npr = $prodcustprice->lines[0]->recuperableonly; if (empty($tva_tx)) { $tva_npr = 0; - } + }*/ } } } @@ -699,7 +700,7 @@ if (empty($reshook)) { $date_end_real_update = $objectline->date_end_real; } - $vat_rate = GETPOST('eltva_tx'); + $vat_rate = GETPOST('eltva_tx', 'alpha'); // Define info_bits $info_bits = 0; if (preg_match('/\*/', $vat_rate)) { @@ -1513,7 +1514,7 @@ if ($action == 'create') { // print ''; //} print ''; - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print ''; } print ''; @@ -1594,7 +1595,7 @@ if ($action == 'create') { // Quantity print ''; // Unit - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print ''; } // Discount @@ -1701,7 +1702,7 @@ if ($action == 'create') { if (empty($senderissupplier)) { print $form->select_produits((!empty($object->lines[$cursorline - 1]->fk_product) ? $object->lines[$cursorline - 1]->fk_product : 0), 'idprod'); } else { - print $form->select_produits_fournisseurs((!empty($object->lines[$cursorline - 1]->fk_product) ? $object->lines[$cursorline - 1]->fk_product : 0), 'idprod'); + $form->select_produits_fournisseurs((!empty($object->lines[$cursorline - 1]->fk_product) ? $object->lines[$cursorline - 1]->fk_product : 0), 'idprod'); } } print '
'; @@ -1739,7 +1740,7 @@ if ($action == 'create') { print ''; // Unit - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print ''; @@ -1765,7 +1766,7 @@ if ($action == 'create') { if (isModEnabled('margin') && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) { $colspan++; } - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $colspan++; } @@ -2046,11 +2047,12 @@ if ($action == 'create') { $dateSelector = 1; print "\n"; - print ' + print ' + '; print '
'; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 1846d911cef..420d314cd43 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -232,7 +232,7 @@ 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'=>'$conf->societe->enabled', 'visible'=>-1, 'notnull'=>1, 'position'=>70), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'isModEnabled("societe")', 'visible'=>-1, 'notnull'=>1, 'position'=>70), 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Project', 'enabled'=>"isModEnabled('project')", '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), @@ -2789,6 +2789,38 @@ class Contrat extends CommonObject return ($error ? 1: 0); } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + global $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + //$return .= ''; // Can be image + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + if (property_exists($this, 'societe')) { + $return .= '
'.$this->societe.''; + } + if (property_exists($this, 'date_contrat')) { + $return .= '
'.$langs->trans("DateContract").' : '.dol_print_date($this->date_contrat).''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 4b49840f681..7ea26bf6f1b 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -51,6 +51,7 @@ $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'contractlist'; // To manage different context of search +$mode = GETPOST('mode', 'alpha'); $search_name = GETPOST('search_name', 'alpha'); $search_email = GETPOST('search_email', 'alpha'); @@ -510,6 +511,9 @@ if ($socid > 0) { } $param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -606,7 +610,10 @@ $url = DOL_URL_ROOT.'/contrat/card.php?action=create'; if (!empty($socid)) { $url .= '&socid='.((int) $socid); } -$newcardbutton = dolGetButtonTitle($langs->trans('NewContractSubscription'), '', 'fa fa-plus-circle', $url, '', $user->rights->contrat->creer); +$newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('NewContractSubscription'), '', 'fa fa-plus-circle', $url, '', $user->rights->contrat->creer); print ''; if ($optioncss != '') { @@ -618,6 +625,7 @@ print ''; print ''; print ''; print ''; +print ''; print_barre_liste($langs->trans("Contracts"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'contract', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -909,212 +917,227 @@ while ($i < min($num, $limit)) { $socstatic->country_code = $cacheCountryIDCode[$obj->country_id]['code']; $socstatic->country = $cacheCountryIDCode[$obj->country_id]['label']; } - - - print '
'; - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } - // Ref - if (!empty($arrayfields['c.ref']['checked'])) { - print ''; - - print ''; - } - - // Ref thirdparty - if (!empty($arrayfields['c.ref_customer']['checked'])) { - print ''; - } - if (!empty($arrayfields['c.ref_supplier']['checked'])) { - print ''; - } - if (!empty($arrayfields['s.nom']['checked'])) { - print ''; } - print ''; - } - // Email - if (!empty($arrayfields['s.email']['checked'])) { - print ''; - } - // Town - if (!empty($arrayfields['s.town']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Zip - if (!empty($arrayfields['s.zip']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // State - if (!empty($arrayfields['state.nom']['checked'])) { - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Country - if (!empty($arrayfields['country.code_iso']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Type ent - if (!empty($arrayfields['typent.code']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['sale_representative']['checked'])) { - // Sales representatives - print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; } - print ''; - } - // Date - if (!empty($arrayfields['c.date_contrat']['checked'])) { - print ''; - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['c.datec']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['c.tms']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date lower end date - if (!empty($arrayfields['lower_planned_end_date']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Status - if (!empty($arrayfields['status']['checked'])) { - print ''; - print ''; - print ''; - print ''; - } - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } - print "\n"; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->contrat->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; + print $formfile->getDocumentsLink($contracttmp->element, $filename, $filedir); + print ''; + + print ''; + } + + // Ref thirdparty + if (!empty($arrayfields['c.ref_customer']['checked'])) { + print ''; + } + if (!empty($arrayfields['c.ref_supplier']['checked'])) { + print ''; + } + if (!empty($arrayfields['s.nom']['checked'])) { + print ''; + } + // Email + if (!empty($arrayfields['s.email']['checked'])) { + print ''; + } + // Town + if (!empty($arrayfields['s.town']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Zip + if (!empty($arrayfields['s.zip']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // State + if (!empty($arrayfields['state.nom']['checked'])) { + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Type ent + if (!empty($arrayfields['typent.code']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['sale_representative']['checked'])) { + // Sales representatives + print ''; + } + // Date + if (!empty($arrayfields['c.date_contrat']['checked'])) { + print ''; + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['c.datec']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date modification + if (!empty($arrayfields['c.tms']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date lower end date + if (!empty($arrayfields['lower_planned_end_date']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Status + if (!empty($arrayfields['status']['checked'])) { + print ''; + print ''; + print ''; + print ''; + } + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } + + print "\n"; + } $i++; } diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 23c2159bc8f..ab041e63385 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1708,6 +1708,66 @@ if (!$error && ($massaction == 'increaseholiday' || ($action == 'increaseholiday } } +//if (!$error && $massaction == 'clonetasks' && $user->rights->projet->creer) { +if (!$error && ($massaction == 'clonetasks' || ($action == 'clonetasks' && $confirm == 'yes'))) { + $num = 0; + + dol_include_once('/projet/class/task.class.php'); + + $origin_task = new Task($db); + $clone_task = new Task($db); + + foreach (GETPOST('selected') as $task) { + $origin_task->fetch($task, $ref = '', $loadparentdata = 0); + + $defaultref = ''; + $obj = empty($conf->global->PROJECT_TASK_ADDON) ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON; + if (!empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT . "/core/modules/project/task/" . $conf->global->PROJECT_TASK_ADDON . ".php")) { + require_once DOL_DOCUMENT_ROOT . "/core/modules/project/task/" . $conf->global->PROJECT_TASK_ADDON . '.php'; + $modTask = new $obj; + $defaultref = $modTask->getNextValue(0, $clone_task); + } + + if (!$error) { + $clone_task->fk_project = GETPOST('projectid', 'int'); + $clone_task->ref = $defaultref; + $clone_task->label = $origin_task->label; + $clone_task->description = $origin_task->description; + $clone_task->planned_workload = $origin_task->planned_workload; + $clone_task->fk_task_parent = $origin_task->fk_task_parent; + $clone_task->date_c = dol_now(); + $clone_task->date_start = $origin_task->date_start; + $clone_task->date_end = $origin_task->date_end; + $clone_task->progress = $origin_task->progress; + + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost(null, $clone_task); + + $taskid = $clone_task->create($user); + + if ($taskid > 0) { + $result = $clone_task->add_contact(GETPOST("userid", 'int'), 'TASKEXECUTIVE', 'internal'); + $num++; + } else { + if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + $langs->load("projects"); + setEventMessages($langs->trans('NewTaskRefSuggested'), '', 'warnings'); + $duplicate_code_error = true; + } else { + setEventMessages($clone_task->error, $clone_task->errors, 'errors'); + } + $action = 'list'; + $error++; + } + } + } + + if (!$error) { + setEventMessage($langs->trans('NumberOfTasksCloned', $num)); + header("Refresh: 1;URL=".DOL_URL_ROOT.'/projet/tasks.php?id=' . GETPOST('projectid', 'int')); + } +} + $parameters['toselect'] = (empty($toselect) ? array() : $toselect); $parameters['uploaddir'] = $uploaddir; $parameters['massaction'] = $massaction; diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 4829b32a72a..ea45580e163 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -155,7 +155,7 @@ class box_activity extends ModeleBoxes while ($j < count($data)) { $this->info_box_contents[$line][0] = array( 'td' => 'class="left" width="16"', - 'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&search_status=".$data[$j]->fk_statut, + 'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&search_status=".((int) $data[$j]->fk_statut), 'tooltip' => $langs->trans("Proposals")." ".$propalstatic->LibStatut($data[$j]->fk_statut, 0), 'logo' => 'object_propal' ); @@ -169,7 +169,7 @@ class box_activity extends ModeleBoxes 'td' => 'class="right"', 'text' => $data[$j]->nb, 'tooltip' => $langs->trans("Proposals")." ".$propalstatic->LibStatut($data[$j]->fk_statut, 0), - 'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&search_status=".$data[$j]->fk_statut, + 'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&search_status=".((int) $data[$j]->fk_statut), ); $totalnb += $data[$j]->nb; @@ -185,6 +185,13 @@ class box_activity extends ModeleBoxes $line++; $j++; } + if (count($data) == 0) { + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoRecordedProposals"), + ); + $line++; + } } } @@ -273,6 +280,13 @@ class box_activity extends ModeleBoxes $line++; $j++; } + if (count($data) == 0) { + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoRecordedOrders"), + ); + $line++; + } } } @@ -329,11 +343,11 @@ class box_activity extends ModeleBoxes if (!empty($data)) { $j = 0; while ($j < count($data)) { - $billurl = "search_status=2&paye=1"; + $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), - 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", + 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", 'logo' => 'bill', ); @@ -346,7 +360,7 @@ class box_activity extends ModeleBoxes 'td' => 'class="right"', 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0), 'text' => $data[$j]->nb, - 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", + 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", ); $this->info_box_contents[$line][3] = array( @@ -369,6 +383,7 @@ class box_activity extends ModeleBoxes 'td' => 'class="center"', 'text'=>$langs->trans("NoRecordedInvoices"), ); + $line++; } } @@ -412,11 +427,11 @@ class box_activity extends ModeleBoxes $j = 0; while ($j < count($data)) { - $billurl = "search_status=".$data[$j]->fk_statut."&paye=0"; + $billurl = "search_status=".$data[$j]->fk_statut."&paye=0"; $this->info_box_contents[$line][0] = array( 'td' => 'class="left" width="16"', 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0), - 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", + 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", 'logo' => 'bill', ); @@ -446,8 +461,9 @@ class box_activity extends ModeleBoxes if (count($data) == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', - 'text'=>$langs->trans("NoRecordedInvoices"), + 'text'=>$langs->trans("NoRecordedUnpaidInvoices"), ); + $line++; } } } diff --git a/htdocs/core/boxes/box_dolibarr_state_board.php b/htdocs/core/boxes/box_dolibarr_state_board.php index 9a2e94b8a1d..6152b167863 100644 --- a/htdocs/core/boxes/box_dolibarr_state_board.php +++ b/htdocs/core/boxes/box_dolibarr_state_board.php @@ -20,7 +20,7 @@ /** * \file htdocs/core/boxes/box_dolibarr_state_board.php - * \ingroup + * \ingroup core * \brief Module Dolibarr state base */ diff --git a/htdocs/core/boxes/box_graph_invoices_peryear.php b/htdocs/core/boxes/box_graph_invoices_peryear.php index 5a9b84829f2..9ea2fe5a130 100644 --- a/htdocs/core/boxes/box_graph_invoices_peryear.php +++ b/htdocs/core/boxes/box_graph_invoices_peryear.php @@ -142,7 +142,7 @@ class box_graph_invoices_peryear extends ModeleBoxes $px2->SetData($data2); unset($data2); $i = $startyear; - $legend = array(); + /*$legend = array(); while ($i <= $endyear) { if ($startmonth != 1) { $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); @@ -150,7 +150,7 @@ class box_graph_invoices_peryear extends ModeleBoxes $legend[] = $i; } $i++; - } + }*/ $px2->SetLegend([$langs->trans("AmountOfBillsHT")]); $px2->SetMaxValue($px2->GetCeilMaxValue()); $px2->SetWidth($WIDTH); diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index 80d465f0f87..6c3db843523 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -175,7 +175,6 @@ class box_project extends ModeleBoxes $this->info_box_contents[$i][] = array( 'td' => 'class="liste_total"', 'text' => $langs->trans("Total")." ".$textHead, - 'text' => " ", ); $this->info_box_contents[$i][] = array( 'td' => 'class="right liste_total" ', diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 67443a7bdb8..1ed16b2e1ce 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -157,13 +157,14 @@ class Canvas } /** - * Return the template to display canvas (if it exists) + * Return if a template exists to display as canvas (if it exists) * * @param string $action Action code * @return int 0=Canvas template file does not exist, 1=Canvas template file exists */ public function displayCanvasExists($action) { + // template_dir should be '/'.$this->dirmodule.'/canvas/'.$this->canvas.'/tpl/', for example '/mymodule/canvas/product/tpl' if (empty($this->template_dir)) { return 0; } diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php index 960d2ac4744..4a743e5b070 100644 --- a/htdocs/core/class/comment.class.php +++ b/htdocs/core/class/comment.class.php @@ -351,16 +351,18 @@ class Comment extends CommonObject /** - * Load comments linked with current task + * Load comments linked with current task into ->comments * * @param string $element_type Element type * @param int $fk_element Id of element - * @return array Comment array + * @return int Result */ public function fetchAllFor($element_type, $fk_element) { global $db, $conf; + $this->comments = array(); + if (!empty($element_type) && !empty($fk_element)) { $sql = "SELECT"; $sql .= " c.rowid"; diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 82012400f68..7c136f446d9 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -651,7 +651,7 @@ abstract class CommonDocGenerator ); // Units - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $resarray['line_unit'] = $outputlangs->trans($line->getLabelOfUnit('long')); $resarray['line_unit_short'] = $outputlangs->trans($line->getLabelOfUnit('short')); } @@ -687,7 +687,7 @@ abstract class CommonDocGenerator $resql = $this->db->fetch_object($resql); foreach ($extralabels as $key => $label) { - $resarray['line_product_supplier_'.$key] = $resql->{$key}; + $resarray['line_product_supplier_'.$key] = $resql->$key; } } } @@ -1016,12 +1016,10 @@ abstract class CommonDocGenerator * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref - * @return null + * @return void */ public function prepareArrayColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { - global $conf; - $this->defineColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -1110,10 +1108,10 @@ abstract class CommonDocGenerator } /** - * get column position rank from column key + * get column position rank from column key * - * @param string $colKey the column key - * @return int rank on success and -1 on error + * @param string $colKey the column key + * @return int rank on success and -1 on error */ public function getColumnRank($colKey) { @@ -1126,11 +1124,11 @@ abstract class CommonDocGenerator /** * get column position rank from column key * - * @param string $newColKey the new column key - * @param array $defArray a single column definition array - * @param string $targetCol target column used to place the new column beside - * @param bool $insertAfterTarget insert before or after target column ? - * @return int new rank on success and -1 on error + * @param string $newColKey the new column key + * @param array $defArray a single column definition array + * @param string $targetCol target column used to place the new column beside + * @param bool $insertAfterTarget insert before or after target column ? + * @return int new rank on success and -1 on error */ public function insertNewColumnDef($newColKey, $defArray, $targetCol = false, $insertAfterTarget = false) { @@ -1171,11 +1169,11 @@ abstract class CommonDocGenerator /** * print standard column content * - * @param TCPDF $pdf pdf object - * @param float $curY curent Y position - * @param string $colKey the column key - * @param string $columnText column text - * @return null + * @param TCPDF $pdf pdf object + * @param float $curY curent Y position + * @param string $colKey the column key + * @param string $columnText column text + * @return int <0 if KO, >= if OK */ public function printStdColumnContent($pdf, &$curY, $colKey, $columnText = '') { @@ -1193,7 +1191,7 @@ abstract class CommonDocGenerator } if (!$reshook) { if (empty($columnText)) { - return; + return 0; } $pdf->SetXY($this->getColumnContentXStart($colKey), $curY); // Set curent position $colDef = $this->cols[$colKey]; @@ -1206,22 +1204,24 @@ abstract class CommonDocGenerator // restore cell padding $pdf->setCellPaddings($curentCellPaddinds['L'], $curentCellPaddinds['T'], $curentCellPaddinds['R'], $curentCellPaddinds['B']); } + + return 0; } /** * print description column content * - * @param TCPDF $pdf pdf object - * @param float $curY curent Y position - * @param string $colKey the column key - * @param object $object CommonObject - * @param int $i the $object->lines array key - * @param Translate $outputlangs Output language - * @param int $hideref hide ref - * @param int $hidedesc hide desc - * @param int $issupplierline if object need supplier product - * @return null + * @param TCPDF $pdf pdf object + * @param float $curY curent Y position + * @param string $colKey the column key + * @param object $object CommonObject + * @param int $i the $object->lines array key + * @param Translate $outputlangs Output language + * @param int $hideref hide ref + * @param int $hidedesc hide desc + * @param int $issupplierline if object need supplier product + * @return void */ public function printColDescContent($pdf, &$curY, $colKey, $object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $issupplierline = 0) { @@ -1265,7 +1265,7 @@ abstract class CommonDocGenerator global $hookmanager; if (empty($object->table_element)) { - return; + return ''; } $extrafieldsKeyPrefix = "options_"; @@ -1288,7 +1288,8 @@ abstract class CommonDocGenerator } $extrafields = $this->extrafieldsCache; - $extrafieldOutputContent = $extrafields->showOutputField($extrafieldKey, $object->array_options[$extrafieldOptionsKey], '', $object->table_element); + $extrafieldOutputContent = ''; + if (isset($object->array_options[$extrafieldOptionsKey])) $extrafieldOutputContent = $extrafields->showOutputField($extrafieldKey, $object->array_options[$extrafieldOptionsKey], '', $object->table_element); // TODO : allow showOutputField to be pdf public friendly, ex: in a link to object, clean getNomUrl to remove link and images... like a getName methode ... if ($extrafields->attributes[$object->table_element]['type'][$extrafieldKey] == 'link') { @@ -1317,10 +1318,10 @@ abstract class CommonDocGenerator /** * display extrafields columns content * - * @param object $object line of common object - * @param Translate $outputlangs Output language - * @param array $params array of additionals parameters - * @return double max y value + * @param object $object line of common object + * @param Translate $outputlangs Output language + * @param array $params array of additionals parameters + * @return string Html string */ public function getExtrafieldsInHtml($object, $outputlangs, $params = array()) { @@ -1330,7 +1331,7 @@ abstract class CommonDocGenerator return; } - // Load extrafiels if not allready does + // Load extrafields if not allready done if (empty($this->extrafieldsCache)) { $this->extrafieldsCache = new ExtraFields($this->db); } @@ -1366,7 +1367,6 @@ abstract class CommonDocGenerator $params = $params + $defaultParams; - /** * @var $extrafields ExtraFields */ @@ -1593,18 +1593,16 @@ abstract class CommonDocGenerator * @param object $object common object det * @param Translate $outputlangs langs * @param int $hidedetails Do not show line details - * @return null + * @return int <0 if KO, >=0 if OK */ public function defineColumnExtrafield($object, $outputlangs, $hidedetails = 0) { - global $conf; - if (!empty($hidedetails)) { - return; + return 0; } if (empty($object->table_element)) { - return; + return 0; } // Load extrafiels if not allready does @@ -1674,5 +1672,7 @@ abstract class CommonDocGenerator $this->insertNewColumnDef("options_".$key, $def); } } + + return 1; } } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index d9b86ae01da..93a3e1b5536 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -16,6 +16,7 @@ * Copyright (C) 2018 Josep Lluís Amador * Copyright (C) 2021 Gauthier VERDOL * Copyright (C) 2021 Grégory Blémand + * Copyright (C) 2023 Lenin Rivas * * 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 @@ -2072,7 +2073,7 @@ abstract class CommonObject $sql .= " WHERE ".$id_field." = ".((int) $id); - dol_syslog(__METHOD__."", LOG_DEBUG); + dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { if ($trigkey) { @@ -3338,6 +3339,8 @@ abstract class CommonObject $row = $this->db->fetch_row($resql); return $row[0]; } + + return 0; } /** @@ -3361,6 +3364,8 @@ abstract class CommonObject $row = $this->db->fetch_row($resql); return $row[0]; } + + return 0; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -3406,6 +3411,8 @@ abstract class CommonObject return $row[0]; } } + + return 0; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -3796,7 +3803,7 @@ abstract class CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Add objects linked in llx_element_element. + * Add an object link into llx_element_element. * * @param string $origin Linked element type * @param int $origin_id Linked element id @@ -4118,6 +4125,21 @@ abstract class CommonObject } } + /** + * Clear the cache saying that all linked object were already loaded. So next fetchObjectLinked will reload all links. + * + * @return int <0 if KO, >0 if OK + * @see fetchObjectLinked() + */ + public function clearObjectLinkedCache() + { + if ($this->id > 0 && !empty($this->linkedObjectsFullLoaded[$this->id])) { + unset($this->linkedObjectsFullLoaded[$this->id]); + } + + return 1; + } + /** * Update object linked of a current object * @@ -4518,6 +4540,8 @@ abstract class CommonObject $row = $this->db->fetch_row($resql); return $row[0]; } + + return 0; } /** @@ -5100,7 +5124,7 @@ abstract class CommonObject print ''; } print ''; - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print ''; } print ''; @@ -5238,7 +5262,7 @@ abstract class CommonObject $this->tpl['total_ht'] = price($line->total_ht); $this->tpl['multicurrency_price'] = price($line->multicurrency_subprice); $this->tpl['qty'] = (($line->info_bits & 2) != 2) ? $line->qty : ' '; - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $this->tpl['unit'] = $langs->transnoentities($line->getLabelOfUnit('long')); } $this->tpl['remise_percent'] = (($line->info_bits & 2) != 2) ? vatrate($line->remise_percent, true) : ' '; @@ -5717,15 +5741,16 @@ abstract class CommonObject * * @param string $fieldname Name of field * @param string $alternatevalue Alternate value to use + * @param string $type Type of data * @return string|string[] Default value (can be an array if the GETPOST return an array) **/ - public function getDefaultCreateValueFor($fieldname, $alternatevalue = null) + public function getDefaultCreateValueFor($fieldname, $alternatevalue = null, $type = 'alphanohtml') { global $conf, $_POST; // If param here has been posted, we use this value first. if (GETPOSTISSET($fieldname)) { - return GETPOST($fieldname, 'alphanohtml', 3); + return GETPOST($fieldname, $type, 3); } if (isset($alternatevalue)) { @@ -5751,6 +5776,9 @@ abstract class CommonObject } // TODO Ad here a scan into table llx_overwrite_default with a filter on $this->element and $fieldname + // store content into $conf->cache['overwrite_default'] + + return ''; } @@ -6442,9 +6470,9 @@ abstract class CommonObject return -1; } elseif ($value == '') { $new_array_languages[$key] = null; + } else { + $new_array_languages[$key] = $value; } - //dol_syslog("double value"." sur ".$attributeLabel."(".$value." is '".$attributeType."')", LOG_DEBUG); - $new_array_languages[$key] = $value; break; /*case 'select': // Not required, we chosed value='0' for undefined values if ($value=='-1') @@ -7807,7 +7835,7 @@ abstract class CommonObject * clear validation message result for a field * * @param string $fieldKey Key of attribute to clear - * @return null + * @return void */ public function clearFieldError($fieldKey) { @@ -7820,12 +7848,14 @@ abstract class CommonObject * * @param string $fieldKey Key of attribute * @param string $msg the field error message - * @return null + * @return void */ public function setFieldError($fieldKey, $msg = '') { global $langs; - if (empty($msg)) { $msg = $langs->trans("UnknowError"); } + if (empty($msg)) { + $msg = $langs->trans("UnknowError"); + } $this->error = $this->validateFieldsErrors[$fieldKey] = $msg; } @@ -9942,7 +9972,7 @@ abstract class CommonObject * @param int[]|int $categories Category ID or array of Categories IDs * @param string $type_categ Category type ('customer', 'supplier', 'website_page', ...) definied into const class Categorie type * @param boolean $remove_existing True: Remove existings categories from Object if not supplies by $categories, False: let them - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, >0 if OK */ public function setCategoriesCommon($categories, $type_categ = '', $remove_existing = true) { diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 56e9e88b1dc..74d8b089223 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -499,9 +499,9 @@ class Conf // Exception: Some dir are not the name of module. So we keep exception here for backward compatibility. // Sous module bons d'expedition - $this->expedition_bon->enabled = (!empty($this->global->MAIN_SUBMODULE_EXPEDITION) ? $this->global->MAIN_SUBMODULE_EXPEDITION : 0); + $this->expedition_bon->enabled = (empty($this->global->MAIN_SUBMODULE_EXPEDITION) ? 0 : $this->global->MAIN_SUBMODULE_EXPEDITION); // Sub module delivery note Sous module bons de livraison - $this->delivery_note->enabled = (!empty($this->global->MAIN_SUBMODULE_DELIVERY) ? $this->global->MAIN_SUBMODULE_DELIVERY : 0); + $this->delivery_note->enabled = (empty($this->global->MAIN_SUBMODULE_DELIVERY) ? 0 : $this->global->MAIN_SUBMODULE_DELIVERY); // Module fournisseur if (!empty($this->fournisseur)) { diff --git a/htdocs/core/class/ctyperesource.class.php b/htdocs/core/class/ctyperesource.class.php index be83877098c..88f6960a9f9 100644 --- a/htdocs/core/class/ctyperesource.class.php +++ b/htdocs/core/class/ctyperesource.class.php @@ -468,8 +468,4 @@ class CtyperesourceLine public $label; public $active; - - /** - * @var mixed Sample line property 2 - */ } diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index 052d5ae7e1c..9f5ea960c9a 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -419,7 +419,7 @@ class DiscountAbsolute * When discount is from a credit note used to reduce payment of an invoice, we link using rowidinvoice * * @param int $rowidline Invoice line id (To use discount into invoice lines) - * @param int $rowidinvoice Invoice id (To use discount as a credit note to reduc payment of invoice) + * @param int $rowidinvoice Invoice id (To use discount as a credit note to reduce payment of invoice) * @return int <0 if KO, >0 if OK */ public function link_to_invoice($rowidline, $rowidinvoice) diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index 67f9cbcbf89..f53498fafe8 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -157,11 +157,7 @@ class DolEditor define('REQUIRE_CKEDITOR', '1'); } - if (!empty($conf->global->FCKEDITOR_SKIN)) { - $skin = $conf->global->FCKEDITOR_SKIN; - } else { - $skin = 'moono-lisa'; // default with ckeditor 4.6 : moono-lisa - } + $skin = getDolGlobalString('FCKEDITOR_SKIN', 'moono-lisa'); // default with ckeditor 4.6 : moono-lisa $pluginstodisable = 'elementspath,save,flash,div,specialchar,anchor'; if (!empty($conf->dol_optimize_smallscreen)) { @@ -183,31 +179,31 @@ class DolEditor $htmlencode_force = preg_match('/_encoded$/', $this->toolbarname) ? 'true' : 'false'; - $out .= ''."\n"; + $out .= ''."\n"; $out .= ''; } diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 7f5c2887e8b..b2bb2a5f8fa 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -449,6 +449,15 @@ class FormFile $titletoshow = ($title == 'none' ? '' : $title); } + $submodulepart = $modulepart; + + // modulepart = 'nameofmodule' or 'nameofmodule:NameOfObject' + $tmp = explode(':', $modulepart); + if (!empty($tmp[1])) { + $modulepart = $tmp[0]; + $submodulepart = $tmp[1]; + } + // Show table if ($genallowed) { $modellist = array(); @@ -648,15 +657,6 @@ class FormFile $modellist = ModelePDFUserGroup::liste_modeles($this->db); } } else { - $submodulepart = $modulepart; - - // modulepart = 'nameofmodule' or 'nameofmodule:NameOfObject' - $tmp = explode(':', $modulepart); - if (!empty($tmp[1])) { - $modulepart = $tmp[0]; - $submodulepart = $tmp[1]; - } - // For normalized standard modules $file = dol_buildpath('/core/modules/'.$modulepart.'/modules_'.strtolower($submodulepart).'.php', 0); if (file_exists($file)) { diff --git a/htdocs/core/class/html.formpropal.class.php b/htdocs/core/class/html.formpropal.class.php index e23e71a8124..894bedebe00 100644 --- a/htdocs/core/class/html.formpropal.class.php +++ b/htdocs/core/class/html.formpropal.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2022 Josep Lluís Amador * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -132,6 +133,16 @@ class FormPropal print ''; $i++; } + // Option for Signed+Billed + if ($mode == 'customer') { + if ($selected != '' && $selected == "2,4") { + print ''; + } print ''; print ajax_combobox($htmlname, array(), 0, 0, 'resolve', ($showempty < 0 ? (string) $showempty : '-1'), $morecss); diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index c57ee0c5106..60499845de0 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -339,8 +339,8 @@ class FormSetup /** * Method used to test module builder convertion to this form usage * - * @param array $params an array of arrays of params from old modulBuilder params - * @return null + * @param array $params an array of arrays of params from old modulBuilder params + * @return void */ public function addItemsFromParamsArray($params) { @@ -662,7 +662,7 @@ class FormSetupItem { global $conf; if (isset($conf->global->{$this->confKey})) { - $this->fieldValue = $conf->global->{$this->confKey}; + $this->fieldValue = getDolGlobalString($this->confKey); return true; } else { $this->fieldValue = null; @@ -683,7 +683,8 @@ class FormSetupItem /** * Save const value based on htdocs/core/actions_setmoduleoptions.inc.php - * @return int -1 if KO, 1 if OK + * + * @return int -1 if KO, 1 if OK */ public function saveConfValue() { @@ -714,10 +715,13 @@ class FormSetupItem return 1; } } + + return 0; } /** * Set an override function for saving data + * * @param callable $callBack a callable function * @return void */ @@ -1005,6 +1009,7 @@ class FormSetupItem * set the type from string : used for old module builder setup conf style conversion and tests * because this two class will quickly evolve it's important to not set directly $this->type (will be protected) so this method exist * to be sure we can manage evolution easily + * * @param string $type possible values based on old module builder setup : 'string', 'textarea', 'category:'.Categorie::TYPE_CUSTOMER', 'emailtemplate', 'thirdparty_type' * @deprecated yes this setTypeFromTypeString came deprecated because it exists only for manage setup convertion * @return bool @@ -1012,11 +1017,13 @@ class FormSetupItem public function setTypeFromTypeString($type) { $this->type = $type; + return true; } /** * Add error + * * @param array|string $errors the error text * @return null */ @@ -1034,7 +1041,9 @@ class FormSetupItem } /** - * @return bool|string Generate the output html for this item + * generateOutputField + * + * @return bool|string Generate the output html for this item */ public function generateOutputField() { diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index eb0c7668d8c..a34861e17d6 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -362,7 +362,7 @@ class FormTicket print ' '; } diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 011d8a380ef..9ad06ba137c 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -982,7 +982,7 @@ class Ldap * * @param string $filterrecord Record * @param string $attribute Attributes - * @return void + * @return array|boolean */ public function getAttributeValues($filterrecord, $attribute) { @@ -1025,7 +1025,7 @@ class Ldap * @param array $attributeArray Array of fields required. Note this array must also contains field $useridentifier (Ex: sn,userPassword) * @param int $activefilter '1' or 'user'=use field this->filter as filter instead of parameter $search, 'group'=use field this->filtergroup as filter, 'member'=use field this->filtermember as filter * @param array $attributeAsArray Array of fields wanted as an array not a string - * @return array Array of [id_record][ldap_field]=value + * @return array|int Array of [id_record][ldap_field]=value */ public function getRecords($search, $userDn, $useridentifier, $attributeArray, $activefilter = 0, $attributeAsArray = array()) { @@ -1239,10 +1239,10 @@ class Ldap /** * Load all attribute of a LDAP user * - * @param User $user User to search for. Not used if a filter is provided. - * @param string $filter Filter for search. Must start with &. - * Examples: &(objectClass=inetOrgPerson) &(objectClass=user)(objectCategory=person) &(isMemberOf=cn=Sales,ou=Groups,dc=opencsi,dc=com) - * @return int >0 if OK, <0 if KO + * @param User|string $user Not used. + * @param string $filter Filter for search. Must start with &. + * Examples: &(objectClass=inetOrgPerson) &(objectClass=user)(objectCategory=person) &(isMemberOf=cn=Sales,ou=Groups,dc=opencsi,dc=com) + * @return int >0 if OK, <0 if KO */ public function fetch($user, $filter) { @@ -1342,7 +1342,7 @@ class Ldap * UserAccountControl Flgs to more human understandable form... * * @param string $uacf UACF - * @return void + * @return array */ public function parseUACF($uacf) { @@ -1382,7 +1382,7 @@ class Ldap } //Return human friendly flags - return($retval); + return $retval; } /** @@ -1414,7 +1414,7 @@ class Ldap $retval = "UNKNOWN_TYPE_".$samtype; } - return($retval); + return $retval; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/core/class/lessc.class.php b/htdocs/core/class/lessc.class.php index 40c4d21abaa..0452cab45aa 100644 --- a/htdocs/core/class/lessc.class.php +++ b/htdocs/core/class/lessc.class.php @@ -1011,6 +1011,7 @@ class Lessc if ($list[0] == "list" && isset($list[2][$idx - 1])) { return $list[2][$idx - 1]; } + return ''; } protected function lib_isnumber($value) @@ -1305,6 +1306,7 @@ class Lessc if (!is_null($color = $this->coerceColor($value))) { return isset($color[4]) ? $color[4] : 1; } + return ''; } // set the alpha of the color @@ -1835,6 +1837,7 @@ class Lessc } return null; } + return null; } // make something string like into a string @@ -1930,6 +1933,8 @@ class Lessc array_unshift($strRight[2], $left); return $strRight; } + + return ''; } @@ -1953,6 +1958,8 @@ class Lessc if ($op == '+' || $op == '*') { return $this->op_color_number($op, $rgt, $lft); } + + return array(); } protected function op_color_number($op, $lft, $rgt) @@ -2755,7 +2762,7 @@ class lessc_parser // media if ($this->literal('@media')) { - if (($this->mediaQueryList($mediaQueries) || true) + if ($this->mediaQueryList($mediaQueries) && $this->literal('{') ) { $media = $this->pushSpecialBlock("media"); @@ -2769,7 +2776,7 @@ class lessc_parser if ($this->literal("@", false) && $this->keyword($dirName)) { if ($this->isDirective($dirName, $this->blockDirectives)) { - if (($this->openString("{", $dirValue, null, array(";")) || true) && + if ($this->openString("{", $dirValue, null, array(";")) && $this->literal("{") ) { $dir = $this->pushSpecialBlock("directive"); @@ -2807,7 +2814,7 @@ class lessc_parser // opening parametric mixin if ($this->tag($tag, true) && $this->argumentDef($args, $isVararg) && - ($this->guards($guards) || true) && + $this->guards($guards) && $this->literal('{') ) { $block = $this->pushBlock($this->fixTags(array($tag))); @@ -2870,8 +2877,8 @@ class lessc_parser // mixin if ($this->mixinTags($tags) && - ($this->argumentDef($argv, $isVararg) || true) && - ($this->keyword($suffix) || true) && $this->end() + $this->argumentDef($argv, $isVararg) && + $this->keyword($suffix) && $this->end() ) { $tags = $this->fixTags($tags); $this->append(array('mixin', $tags, $argv, $suffix), $s); @@ -3133,7 +3140,7 @@ class lessc_parser } // an import statement - protected function import(&$out) + protected function import(&$out, $value = '') { if (!$this->literal('@import')) { return false; @@ -3147,6 +3154,8 @@ class lessc_parser $out = array("import", $value); return true; } + + return false; } protected function mediaQueryList(&$out) @@ -3165,7 +3174,7 @@ class lessc_parser $expressions = null; $parts = array(); - if (($this->literal("only") && ($only = true) || $this->literal("not") && ($not = true) || true) && $this->keyword($mediaType)) { + if ((($this->literal("only") && ($only = true)) || ($this->literal("not") && ($not = true))) && $this->keyword($mediaType)) { $prop = array("mediaType"); if (isset($only)) { $prop[] = "only"; @@ -3204,7 +3213,7 @@ class lessc_parser $value = null; if ($this->literal("(") && $this->keyword($feature) && - ($this->literal(":") && $this->expression($value) || true) && + ($this->literal(":") && $this->expression($value)) && $this->literal(")") ) { $out = array("mediaExp", $feature); diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index bf6d6b08b49..fc562913c08 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -658,6 +658,11 @@ class Notify $reshook = $hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { + if (!empty($hookmanager->resArray['files'])) { + $filename_list = $hookmanager->resArray['files']['file']; + $mimetype_list = $hookmanager->resArray['files']['mimefile']; + $mimefilename_list = $hookmanager->resArray['files']['filename']; + } if (!empty($hookmanager->resArray['subject'])) { $subject .= $hookmanager->resArray['subject']; } @@ -901,6 +906,11 @@ class Notify $parameters = array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list); $reshook = $hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { + if (!empty($hookmanager->resArray['files'])) { + $filename_list = $hookmanager->resArray['files']['file']; + $mimetype_list = $hookmanager->resArray['files']['mimefile']; + $mimefilename_list = $hookmanager->resArray['files']['filename']; + } if (!empty($hookmanager->resArray['subject'])) { $subject .= $hookmanager->resArray['subject']; } diff --git a/htdocs/core/class/openid.class.php b/htdocs/core/class/openid.class.php index 79cf9137a99..7198f532358 100644 --- a/htdocs/core/class/openid.class.php +++ b/htdocs/core/class/openid.class.php @@ -178,7 +178,7 @@ class SimpleOpenID /** * SetOpenIDServer * - * @return void + * @return array */ public function GetError() { @@ -225,7 +225,7 @@ class SimpleOpenID * splitResponse * * @param string $response Server - * @return void + * @return array */ public function splitResponse($response) { diff --git a/htdocs/core/class/rssparser.class.php b/htdocs/core/class/rssparser.class.php index 66e9241d9f5..da3257b09c9 100644 --- a/htdocs/core/class/rssparser.class.php +++ b/htdocs/core/class/rssparser.class.php @@ -175,7 +175,7 @@ class RssParser /** * getItems * - * @return string + * @return array */ public function getItems() { @@ -801,8 +801,8 @@ class RssParser /** * Function to convert an XML object into an array * - * @param SimpleXMLElement $xml Xml - * @return void + * @param SimpleXMLElement $xml Xml + * @return array|string */ function xml2php($xml) { diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php index 154b2b2158a..60cdc5d5226 100644 --- a/htdocs/core/class/stats.class.php +++ b/htdocs/core/class/stats.class.php @@ -55,7 +55,7 @@ abstract class Stats global $conf, $user, $langs; if ($startyear > $endyear) { - return -1; + return array(); } $datay = array(); @@ -156,7 +156,7 @@ abstract class Stats global $conf, $user, $langs; if ($startyear > $endyear) { - return -1; + return array(); } $datay = array(); @@ -237,7 +237,7 @@ abstract class Stats /** * @param int $year year number - * @return int value + * @return array array of values */ protected abstract function getAverageByMonth($year); @@ -251,7 +251,7 @@ abstract class Stats public function getAverageByMonthWithPrevYear($endyear, $startyear) { if ($startyear > $endyear) { - return -1; + return array(); } $datay = array(); diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 568ef7b4ace..2315428b37a 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -834,7 +834,6 @@ class Translate 'ja'=>'ja_JP', 'lo'=>'lo_LA', 'nb'=>'nb_NO', - 'fa'=>'fa_IR', 'sq'=>'sq_AL', 'sr'=>'sr_RS', 'sv'=>'sv_SE', @@ -933,8 +932,10 @@ class Translate $fonc = 'numberwords'; if (file_exists($newdir.'/functions_'.$fonc.'.lib.php')) { include_once $newdir.'/functions_'.$fonc.'.lib.php'; - $newnumber = numberwords_getLabelFromNumber($this, $number, $isamount); - break; + if (function_exists('numberwords_getLabelFromNumber')) { + $newnumber = numberwords_getLabelFromNumber($this, $number, $isamount); + break; + } } } diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index d58854ed9d0..0241431c8b7 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -34,6 +34,9 @@ class Utils */ public $db; + public $error; + public $errors; + public $output; // Used by Cron method to return message public $result; // Used by Cron method to return data diff --git a/htdocs/core/class/vcard.class.php b/htdocs/core/class/vcard.class.php index dbe505a894b..7b5a320f678 100644 --- a/htdocs/core/class/vcard.class.php +++ b/htdocs/core/class/vcard.class.php @@ -31,7 +31,7 @@ */ function encode($string) { - return str_replace(";", "\;", (dol_quoted_printable_encode(utf8_decode($string)))); + return str_replace(";", "\;", (dol_quoted_printable_encode($string))); } @@ -100,14 +100,14 @@ class vCard /** * @var string encoding */ - public $encoding = "ISO-8859-1;ENCODING=QUOTED-PRINTABLE"; + public $encoding = "ENCODING=QUOTED-PRINTABLE"; /** * mise en forme du numero de telephone * * @param int $number numero de telephone - * @param string $type Type + * @param string $type Type ('cell') * @return void */ public function setPhoneNumber($number, $type = "") @@ -117,22 +117,25 @@ class vCard if ($type != "") { $key .= ";".$type; } - $key .= ";CHARSET=".$this->encoding; - $this->properties[$key] = encode($number); + $key .= ";VALUE=uri"; + //$key .= ";".$this->encoding; + $this->properties[$key] = 'tel:'.$number; } /** * mise en forme de la photo * warning NON TESTE ! * - * @param string $type Type + * @param string $type Type 'image/jpeg' or 'JPEG' * @param string $photo Photo * @return void */ public function setPhoto($type, $photo) { // $type = "GIF" | "JPEG" - $this->properties["PHOTO;TYPE=$type;ENCODING=BASE64"] = base64_encode($photo); + //$this->properties["PHOTO;MEDIATYPE=$type;ENCODING=BASE64"] = base64_encode($photo); + $this->properties["PHOTO;MEDIATYPE=$type"] = $photo; // must be url of photo + //$this->properties["PHOTO;TYPE=$type;ENCODING=BASE64"] = base64_encode($photo); // must be content of image } /** @@ -143,7 +146,7 @@ class vCard */ public function setFormattedName($name) { - $this->properties["FN;CHARSET=".$this->encoding] = encode($name); + $this->properties["FN;".$this->encoding] = encode($name); } /** @@ -152,13 +155,14 @@ class vCard * @param string $family Family name * @param string $first First name * @param string $additional Additional (e.g. second name, nick name) - * @param string $prefix Prefix (e.g. "Mr.", "Ms.", "Prof.") + * @param string $prefix Title prefix (e.g. "Mr.", "Ms.", "Prof.") * @param string $suffix Suffix (e.g. "sen." for senior, "jun." for junior) * @return void */ public function setName($family = "", $first = "", $additional = "", $prefix = "", $suffix = "") { - $this->properties["N;CHARSET=".$this->encoding] = encode($family).";".encode($first).";".encode($additional).";".encode($prefix).";".encode($suffix); + //$this->properties["N;".$this->encoding] = encode($family).";".encode($first).";".encode($additional).";".encode($prefix).";".encode($suffix); + $this->properties["N"] = encode($family).";".encode($first).";".encode($additional).";".encode($prefix).";".encode($suffix); $this->filename = "$first%20$family.vcf"; if (empty($this->properties["FN"])) { $this->setFormattedName(trim("$prefix $first $additional $family $suffix")); @@ -173,12 +177,13 @@ class vCard */ public function setBirthday($date) { - // $date format is YYYY-MM-DD - RFC 2425 and RFC 2426 - $this->properties["BDAY"] = dol_print_date($date, 'dayrfc'); + // $date format is YYYY-MM-DD - RFC 2425 and RFC 2426 for vcard v3 + // $date format is YYYYMMDD or ISO8601 for vcard v4 + $this->properties["BDAY"] = dol_print_date($date, 'dayxcard'); } /** - * mise en forme de l'adresse + * Address * * @param string $postoffice Postoffice * @param string $extended Extended @@ -188,25 +193,29 @@ class vCard * @param string $zip Zip * @param string $country Country * @param string $type Type + * @param string $label Label * @return void */ - public function setAddress($postoffice = "", $extended = "", $street = "", $city = "", $region = "", $zip = "", $country = "", $type = "HOME;POSTAL") + public function setAddress($postoffice = "", $extended = "", $street = "", $city = "", $region = "", $zip = "", $country = "", $type = "", $label = "") { // $type may be DOM | INTL | POSTAL | PARCEL | HOME | WORK or any combination of these: e.g. "WORK;PARCEL;POSTAL" $key = "ADR"; if ($type != "") { $key .= ";".$type; } - $key .= ";CHARSET=".$this->encoding; - $this->properties[$key] = ";".encode($extended).";".encode($street).";".encode($city).";".encode($region).";".encode($zip).";".encode($country); + if ($label != "") { + $key .= ';LABEL="'.encode($label).'"'; + } + $key .= ";".$this->encoding; + $this->properties[$key] = encode($postoffice).";".encode($extended).";".encode($street).";".encode($city).";".encode($region).";".encode($zip).";".encode($country); - //if ($this->properties["LABEL;".$type.";CHARSET=".$this->encoding] == '') { + //if ($this->properties["LABEL;".$type.";".$this->encoding] == '') { //$this->setLabel($postoffice, $extended, $street, $city, $region, $zip, $country, $type); //} } /** - * mise en forme du label + * Address (old standard) * * @param string $postoffice Postoffice * @param string $extended Extended @@ -217,8 +226,9 @@ class vCard * @param string $country Country * @param string $type Type * @return void + * @deprecated */ - public function setLabel($postoffice = "", $extended = "", $street = "", $city = "", $region = "", $zip = "", $country = "", $type = "HOME;POSTAL") + public function setLabel($postoffice = "", $extended = "", $street = "", $city = "", $region = "", $zip = "", $country = "", $type = "HOME") { $label = ""; if ($postoffice != "") { @@ -243,7 +253,7 @@ class vCard $country .= "$country\r\n"; } - $this->properties["LABEL;$type;CHARSET=".$this->encoding] = encode($label); + $this->properties["LABEL;$type;".$this->encoding] = encode($label); } /** @@ -253,7 +263,7 @@ class vCard * @param string $type (optional) The type of the e-mail (typical "PREF;INTERNET" or "INTERNET") * @return void */ - public function setEmail($address, $type = "TYPE=INTERNET;PREF") + public function setEmail($address, $type = "") { $key = "EMAIL"; if ($type != "") { @@ -270,7 +280,7 @@ class vCard */ public function setNote($note) { - $this->properties["NOTE;CHARSET=".$this->encoding] = encode($note); + $this->properties["NOTE;".$this->encoding] = encode($note); } /** @@ -281,7 +291,7 @@ class vCard */ public function setTitle($title) { - $this->properties["TITLE;CHARSET=".$this->encoding] = encode($title); + $this->properties["TITLE;".$this->encoding] = encode($title); } @@ -293,7 +303,7 @@ class vCard */ public function setOrg($org) { - $this->properties["ORG;CHARSET=".$this->encoding] = encode($org); + $this->properties["ORG;".$this->encoding] = encode($org); } @@ -305,7 +315,7 @@ class vCard */ public function setProdId($prodid) { - $this->properties["PRODID;CHARSET=".$this->encoding] = encode($prodid); + $this->properties["PRODID"] = encode($prodid); } @@ -317,7 +327,7 @@ class vCard */ public function setUID($uid) { - $this->properties["UID;CHARSET=".$this->encoding] = encode($uid); + $this->properties["UID"] = encode($uid); } @@ -346,13 +356,14 @@ class vCard public function getVCard() { $text = "BEGIN:VCARD\r\n"; - $text .= "VERSION:3.0\r\n"; + $text .= "VERSION:4.0\r\n"; // With V4, all encoding are UTF-8 //$text.= "VERSION:2.1\r\n"; foreach ($this->properties as $key => $value) { - $text .= "$key:$value\r\n"; + $newkey = preg_replace('/-.*$/', '', $key); // remove suffix -twitter, -facebook, ... + $text .= $newkey.":".$value."\r\n"; } - $text .= "REV:".date("Y-m-d")."T".date("H:i:s")."Z\r\n"; - $text .= "MAILER: Dolibarr\r\n"; + $text .= "REV:".date("Ymd")."T".date("His")."Z\r\n"; + //$text .= "MAILER: Dolibarr\r\n"; $text .= "END:VCARD\r\n"; return $text; } @@ -367,6 +378,165 @@ class vCard return $this->filename; } + /** + * Return a VCARD string + * See RFC https://datatracker.ietf.org/doc/html/rfc6350 + * + * @param Object $object Object (User or Contact) + * @param Societe|null $company Company. May be null + * @param Translate $langs Lang object + * @param string $urlphoto Full public URL of photo + * @return string String + */ + public function buildVCardString($object, $company, $langs, $urlphoto = '') + { + global $dolibarr_main_instance_unique_id; + + $this->setProdId('Dolibarr '.DOL_VERSION); + + $this->setUid('DOLIBARR-USERID-'.dol_trunc(md5('vcard'.$dolibarr_main_instance_unique_id), 8, 'right', 'UTF-8', 1).'-'.$object->id); + $this->setName($object->lastname, $object->firstname, "", $object->civility_code, ""); + $this->setFormattedName($object->getFullName($langs, 1)); + + if ($urlphoto) { + $mimetype = dol_mimetype($urlphoto); + if ($mimetype) { + $this->setPhoto($mimetype, $urlphoto); + } + } + + if ($object->office_phone) { + $this->setPhoneNumber($object->office_phone, "TYPE=WORK,VOICE"); + } + /* disabled + if ($object->personal_mobile) { + $this->setPhoneNumber($object->personal_mobile, "TYPE=CELL,VOICE"); + }*/ + if ($object->user_mobile) { + $this->setPhoneNumber($object->user_mobile, "TYPE=CELL,VOICE"); + } + if ($object->office_fax) { + $this->setPhoneNumber($object->office_fax, "TYPE=WORK,FAX"); + } + + if (!empty($object->socialnetworks)) { + foreach ($object->socialnetworks as $key => $val) { + $urlsn = ''; + if ($key == 'linkedin') { + if (!preg_match('/^http/', $val)) { + $urlsn = 'https://www.'.$key.'.com/company/'.urlencode($val); + } else { + $urlsn = $val; + } + } elseif ($key == 'youtube') { + if (!preg_match('/^http/', $val)) { + $urlsn = 'https://www.'.$key.'.com/user/'.urlencode($val); + } else { + $urlsn = $val; + } + } else { + if (!preg_match('/^http/', $val)) { + $urlsn = 'https://www.'.$key.'.com/'.urlencode($val); + } else { + $urlsn = $val; + } + } + if ($urlsn) { + $this->properties["SOCIALPROFILE;TYPE=WORK-".$key] = $key.':'.$urlsn; + } + } + } + + $country = $object->country_code ? $object->country : ''; + + if ($object->address || $object->town || $object->state || $object->zip || $object->country) { + $this->setAddress("", "", $object->address, $object->town, $object->state, $object->zip, $country, ""); + //$this->setLabel("", "", $object->address, $object->town, $object->state, $object->zip, $country, "TYPE=HOME"); + } + + if ($object->email) { + $this->setEmail($object->email, "TYPE=WORK"); + } + /* disabled + if ($object->personal_email) { + $this->setEmail($object->personal_email, "TYPE=HOME"); + } */ + if ($object->note_public) { + $this->setNote($object->note_public); + } + if ($object->job) { + $this->setTitle($object->job); + } + + // For user, $object->url is not defined + // For contact, $object->url is not defined + if (!empty($object->url)) { + $this->setURL($object->url, ""); + } + + if (is_object($company)) { + // Si user linked to a thirdparty and not a physical people + if ($company->typent_code != 'TE_PRIVATE') { + $this->setOrg($company->name); + } + + $this->setURL($company->url, ""); + + if ($company->phone && $company->phone != $object->office_phone) { + $this->setPhoneNumber($company->phone, "TYPE=WORK,VOICE"); + } + if ($company->fax && $company->fax != $object->office_fax) { + $this->setPhoneNumber($company->fax, "TYPE=WORK,FAX"); + } + if ($company->address || $company->town || $company->state || $company->zip || $company->country) { + $this->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK"); + } + + if ($company->email && $company->email != $object->email) { + $this->setEmail($company->email, "TYPE=WORK"); + } + + /* + if (!empty($company->socialnetworks)) { + foreach ($company->socialnetworks as $key => $val) { + $urlsn = ''; + if ($key == 'linkedin') { + if (!preg_match('/^http/', $val)) { + $urlsn = 'https://www.'.$key.'.com/company/'.urlencode($val); + } else { + $urlsn = $val; + } + } elseif ($key == 'youtube') { + if (!preg_match('/^http/', $val)) { + $urlsn = 'https://www.'.$key.'.com/user/'.urlencode($val); + } else { + $urlsn = $val; + } + } else { + if (!preg_match('/^http/', $val)) { + $urlsn = 'https://www.'.$key.'.com/'.urlencode($val); + } else { + $urlsn = $val; + } + } + if ($urlsn) { + $this->properties["socialProfile;type=".$key] = $urlsn; + } + } + } + */ + } + + // Birthday + if ($object->birth) { + $this->setBirthday($object->birth); + } + + // Return VCard string + return $this->getVCard(); + } + + /* Example from Microsoft Outlook 2019 BEGIN:VCARD diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index e2659e224a4..30b3ea76975 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/db/Database.interface.php'; */ abstract class DoliDB implements Database { - /** @var bool|resource|SQLite3|PgSql\connection Database handler */ + /** @var bool|resource|mysqli|SQLite3|PgSql\connection Database handler */ public $db; /** @var string Database type */ public $type; @@ -37,8 +37,10 @@ abstract class DoliDB implements Database public $forcecharset = 'utf8'; /** @var string Collate used to force collate when creating database */ public $forcecollate = 'utf8_unicode_ci'; + /** @var resource Resultset of last query */ private $_results; + /** @var bool true if connected, else false */ public $connected; /** @var bool true if database selected, else false */ @@ -73,7 +75,8 @@ abstract class DoliDB implements Database /** - * Return the DB prefix + * Return the DB prefix found into prefix_db (if it was set manually by doing $dbhandler->prefix_db=...). + * Otherwise return MAIN_DB_PREFIX (common use). * * @return string The DB prefix */ diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 7d184dc06cf..d34aca48ed9 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -36,10 +36,12 @@ class DoliDBMysqli extends DoliDB public $db; //! Database type public $type = 'mysqli'; + //! Database label const LABEL = 'MySQL or MariaDB'; //! Version min database const VERSIONMIN = '5.0.3'; + /** @var bool|mysqli_result Resultset of last query */ private $_results; diff --git a/htdocs/core/doxygen.php b/htdocs/core/doxygen.php index ac66362a89f..1e66b348ef8 100644 --- a/htdocs/core/doxygen.php +++ b/htdocs/core/doxygen.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2008-2022 Laurent Destailleur * Copyright (C) 2009 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -20,10 +20,10 @@ /** * \file htdocs/core/doxygen.php * \ingroup core - * \mainpage Dolibarr project + * \mainpage Dolibarr documentation of source code * * This is source documentation for Dolibarr ERP/CRM.
- * This documentation can be built or updated running the script dolibarr-doxygen-build.pl or from Eclipse with Doxygen plugin.
+ * This documentation can be built or updated running the script build/doxygen/dolibarr-doxygen-build.pl or from Eclipse with Doxygen plugin.
*
* Dolibarr official web site: www.dolibarr.org
*
diff --git a/htdocs/core/filemanagerdol/browser/default/frmfolders.php b/htdocs/core/filemanagerdol/browser/default/frmfolders.php index d8d1fae179a..a1b03693324 100644 --- a/htdocs/core/filemanagerdol/browser/default/frmfolders.php +++ b/htdocs/core/filemanagerdol/browser/default/frmfolders.php @@ -53,7 +53,7 @@ top_httphead(); --> diff --git a/htdocs/core/filemanagerdol/connectors/php/connector.lib.php b/htdocs/core/filemanagerdol/connectors/php/connector.lib.php index 608c2ba4cd6..75c4d1e3e08 100644 --- a/htdocs/core/filemanagerdol/connectors/php/connector.lib.php +++ b/htdocs/core/filemanagerdol/connectors/php/connector.lib.php @@ -343,7 +343,8 @@ function FileUpload($resourceType, $currentFolder, $sCommand, $CKEcallback = '') include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; //var_dump($sFileName); var_dump(image_format_supported($sFileName));exit; - $isImageValid = (image_format_supported($sFileName) >= 0 ? true : false); + $imgsupported = image_format_supported($sFileName); + $isImageValid = ($imgsupported >= 0 ? true : false); if (!$isImageValid) { $sErrorNumber = '202'; } @@ -387,7 +388,7 @@ function FileUpload($resourceType, $currentFolder, $sCommand, $CKEcallback = '') if (file_exists($sFilePath)) { //previous checks failed, try once again - if (isset($isImageValid) && $isImageValid === -1 && IsImageValid($sFilePath, $sExtension) === false) { + if (isset($isImageValid) && $imgsupported === -1 && IsImageValid($sFilePath, $sExtension) === false) { dol_syslog("connector.lib.php IsImageValid is ko"); @unlink($sFilePath); $sErrorNumber = '202'; diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 71bcc082961..92895793082 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1084,11 +1084,12 @@ function purgeSessions($mysessionid) /** * Enable a module * - * @param string $value Name of module to activate - * @param int $withdeps Activate/Disable also all dependencies - * @return array array('nbmodules'=>nb modules activated with success, 'errors=>array of error messages, 'nbperms'=>Nb permission added); + * @param string $value Name of module to activate + * @param int $withdeps Activate/Disable also all dependencies + * @param int $noconfverification Remove verification of $conf variable for module + * @return array array('nbmodules'=>nb modules activated with success, 'errors=>array of error messages, 'nbperms'=>Nb permission added); */ -function activateModule($value, $withdeps = 1) +function activateModule($value, $withdeps = 1, $noconfverification = 0) { global $db, $langs, $conf, $mysoc; @@ -1144,8 +1145,10 @@ function activateModule($value, $withdeps = 1) } $const_name = $objMod->const_name; - if (!empty($conf->global->$const_name)) { - return $ret; + if ($noconfverification == 0) { + if (!empty($conf->global->$const_name)) { + return $ret; + } } $result = $objMod->init(); // Enable module diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 8e539fceac4..cacd22269ad 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -194,7 +194,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen $("#'.$htmlnamejquery.'").attr("data-tvatx", ui.item.tva_tx); $("#'.$htmlnamejquery.'").attr("data-default-vat-code", ui.item.default_vat_code); '; - if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) { + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { $script .= ' // For customer price when PRODUIT_CUSTOMER_PRICES_BY_QTY is on console.log("PRODUIT_CUSTOMER_PRICES_BY_QTY is on, propagate also prices by quantity into data-pbqxxx properties"); @@ -480,8 +480,11 @@ function ajax_combobox($htmlname, $events = array(), $minLengthToAutocomplete = '; @@ -111,7 +111,7 @@ print $langs->trans('ReductionShort'); if (in_array($object->element, array('propal', 'commande', 'facture')) && $object->status == $object::STATUS_DRAFT) { global $mysoc; - if (empty($disableedit)) { + if (empty($disableedit) && GETPOST('mode', 'aZ09') != 'remiseforalllines') { print 'id.'">'.img_edit($langs->trans("UpdateForAllLines"), 0, 'class="clickvatforalllines opacitymedium paddingleft cursorpointer"').''; } //print ''; diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 14197b6d052..be24a555a3c 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -255,11 +255,48 @@ if (isModEnabled('accounting') && $line->fk_accounting_account > 0) { } print ''; +// Vendor price ref if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier' || $object->element == 'invoice_supplier_rec') { // We must have same test in printObjectLines print '
'; } + +$tooltiponprice = ''; +$tooltiponpriceend = ''; +if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $tooltiponprice = $langs->transcountry("TotalHT", $mysoc->country_code).'='.price($line->total_ht); + $tooltiponprice .= '
'.$langs->transcountry("TotalVAT", ($senderissupplier ? $object->thirdparty->country_code : $mysoc->country_code)).'='.price($line->total_tva); + if (is_object($object->thirdparty)) { + if ($senderissupplier) { + $seller = $object->thirdparty; + $buyer = $mysoc; + } else { + $seller = $mysoc; + $buyer = $object->thirdparty; + } + + if ($mysoc->useLocalTax(1)) { + if (($seller->country_code == $buyer->country_code) || $line->total_localtax1 || $seller->useLocalTax(1)) { + $tooltiponprice .= '
'.$langs->transcountry("TotalLT1", $seller->country_code).'='.price($line->total_localtax1); + } else { + $tooltiponprice .= '
'.$langs->transcountry("TotalLT1", $seller->country_code).'='.$langs->trans($senderissupplier ? "NotUsedForThisVendor" : "NotUsedForThisCustomer").''; + } + } + if ($mysoc->useLocalTax(2)) { + if (($seller->country_code == $buyer->thirdparty->country_code) || $line->total_localtax2 || $seller->useLocalTax(2)) { + $tooltiponprice .= '
'.$langs->transcountry("TotalLT2", $seller->country_code).'='.price($line->total_localtax2); + } else { + $tooltiponprice .= '
'.$langs->transcountry("TotalLT2", $seller->country_code).'='.$langs->trans($senderissupplier ? "NotUsedForThisVendor" : "NotUsedForThisCustomer").''; + } + } + } + $tooltiponprice .= '
'.$langs->transcountry("TotalTTC", $mysoc->country_code).'='.price($line->total_ttc); + + $tooltiponprice = ''; + $tooltiponpriceend = ''; +} + // VAT Rate print ' @@ -344,53 +382,24 @@ if ($usemargins && isModEnabled('margin') && empty($user->socid)) { special_code == 3) { ?> '; $coldisplay++; - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $tooltiponprice = $langs->transcountry("TotalHT", $mysoc->country_code).'='.price($line->total_ht); - $tooltiponprice .= '
'.$langs->transcountry("TotalVAT", ($senderissupplier ? $object->thirdparty->country_code : $mysoc->country_code)).'='.price($line->total_tva); - if (is_object($object->thirdparty)) { - if ($senderissupplier) { - $seller = $object->thirdparty; - $buyer = $mysoc; - } else { - $seller = $mysoc; - $buyer = $object->thirdparty; - } - - if ($mysoc->useLocalTax(1)) { - if (($seller->country_code == $buyer->country_code) || $line->total_localtax1 || $seller->useLocalTax(1)) { - $tooltiponprice .= '
'.$langs->transcountry("TotalLT1", $seller->country_code).'='.price($line->total_localtax1); - } else { - $tooltiponprice .= '
'.$langs->transcountry("TotalLT1", $seller->country_code).'='.$langs->trans($senderissupplier ? "NotUsedForThisSupplier" : "NotUsedForThisCustomer").''; - } - } - if ($mysoc->useLocalTax(2)) { - if (($seller->country_code == $buyer->thirdparty->country_code) || $line->total_localtax2 || $seller->useLocalTax(2)) { - $tooltiponprice .= '
'.$langs->transcountry("TotalLT2", $seller->country_code).'='.price($line->total_localtax2); - } else { - $tooltiponprice .= '
'.$langs->transcountry("TotalLT2", $seller->country_code).'='.$langs->trans($senderissupplier ? "NotUsedForThisSupplier" : "NotUsedForThisCustomer").''; - } - } - } - $tooltiponprice .= '
'.$langs->transcountry("TotalTTC", $mysoc->country_code).'='.price($line->total_ttc); - - print ''; - } + print $tooltiponprice; print price($sign * $line->total_ht); - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - print ''; - } + print $tooltiponpriceend; print ''; if (isModEnabled("multicurrency") && $this->multicurrency_code != $conf->currency) { print ''; $coldisplay++; } } + +// Price inc tax if ($outputalsopricetotalwithtax) { print ''; $coldisplay++; @@ -405,6 +414,7 @@ if ($this->statut == 0 && !empty($object_rights->creer) && $action != 'selectlin } } + // Asset info if (isModEnabled('asset') && $object->element == 'invoice_supplier') { print ''; } + // Edit picto print ''; + // Delete picto print ''; + // Move up-down picto if ($num > 1 && $conf->browser->layout != 'phone' && ($this->situation_counter == 1 || !$this->situation_cycle_ref) && empty($disablemove)) { print ''; print ''; print ''; } print ''; - print ''; print ''; - $donationstatic->id = $objp->rowid; - $donationstatic->ref = $objp->rowid; - $donationstatic->lastname = $objp->lastname; - $donationstatic->firstname = $objp->firstname; - print ""; - if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) { - $company = new Societe($db); - $result = $company->fetch($objp->socid); if (!empty($objp->socid) && $company->id > 0) { - print ""; + $donationstatic->societe = $company->getNomUrl(1); + } else { + $donationstatic->societe = $objp->societe; + } + + print $donationstatic->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print ''; + print ''; + } + } else { + print ''; + $donationstatic->id = $objp->rowid; + $donationstatic->ref = $objp->rowid; + $donationstatic->lastname = $objp->lastname; + $donationstatic->firstname = $objp->firstname; + print ""; + if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) { + if (!empty($objp->socid) && $company->id > 0) { + print ""; + } else { + print ""; + } } else { print ""; } - } else { - print ""; - } - print ""; - print ''; - if (isModEnabled('project')) { - print ""; + print ''; + if (isModEnabled('project')) { + print "\n"; } - print "\n"; + print ''; + print ''; + print ''; + print ""; } - print ''; - print ''; - print ''; - print ""; $i++; } print "
' . $langs->trans("Year") . " " . $y . '' . $langs->trans("Year") . '' . $langs->trans("VATToPay") . '' . $langs->trans("VATToCollect") . '' . $langs->trans("Balance") . '
' . $langs->trans("ErrorNoAccountancyModuleLoaded") . '
' . $langs->trans("FeatureNotYetAvailable") . '
' . dol_print_date(dol_mktime(0, 0, 0, $m, 1, $y), "%b %Y") . ''; + print ''; $liststatus = array('0' => $langs->trans("Unpaid"), '1' => $langs->trans("Paid")); - print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'onrightofpage'); + print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage'); print '
'.(($offset * $limit) + $i).'
'; + print '
'; } - } + // Output Kanban - // Ref - if (!empty($arrayfields['t.rowid']['checked'])) { - print '
'; - print $tva_static->getNomUrl(1); - $filename = dol_sanitizeFileName($tva_static->ref); - $filedir = $conf->tax->dir_output.'/vat/'.dol_sanitizeFileName($tva_static->ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$tva_static->id; - print $formfile->getDocumentsLink($tva_static->element, $filename, $filedir, '', 'valignmiddle paddingleft2imp'); - print '
'.dol_trunc($obj->label, 40).''.(($offset * $limit) + $i).''.dol_print_date($db->jdate($obj->datev), 'day').''; + print $tva_static->getNomUrl(1); + $filename = dol_sanitizeFileName($tva_static->ref); + $filedir = $conf->tax->dir_output.'/vat/'.dol_sanitizeFileName($tva_static->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$tva_static->id; + print $formfile->getDocumentsLink($tva_static->element, $filename, $filedir, '', 'valignmiddle paddingleft2imp'); + print ''.dol_print_date($db->jdate($obj->datep), 'day').''; - if (!empty($obj->payment_code)) print $langs->trans("PaymentTypeShort".$obj->payment_code); - print ''.dol_trunc($obj->label, 40).''; - if ($obj->fk_account > 0) { - $bankstatic->id = $obj->fk_account; - $bankstatic->ref = $obj->bref; - $bankstatic->number = $obj->bnumber; - $bankstatic->iban = $obj->iban; - $bankstatic->bic = $obj->bic; - $bankstatic->currency_code = $langs->trans("Currency".$obj->currency_code); - $bankstatic->account_number = $obj->account_number; - $bankstatic->clos = $obj->clos; - - //$accountingjournal->fetch($obj->fk_accountancy_journal); - //$bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); - - $bankstatic->label = $obj->blabel; - print $bankstatic->getNomUrl(1); + // Date end period + if (!empty($arrayfields['t.datev']['checked'])) { + print ''.dol_print_date($db->jdate($obj->datev), 'day').'' . price($obj->amount) . ''.dol_print_date($db->jdate($obj->datep), 'day').'' . $tva_static->LibStatut($obj->paye, 5, $obj->alreadypayed) . ''; + if (!empty($obj->payment_code)) print $langs->trans("PaymentTypeShort".$obj->payment_code); + print ''; + if ($obj->fk_account > 0) { + $bankstatic->id = $obj->fk_account; + $bankstatic->ref = $obj->bref; + $bankstatic->number = $obj->bnumber; + $bankstatic->iban = $obj->iban; + $bankstatic->bic = $obj->bic; + $bankstatic->currency_code = $langs->trans("Currency".$obj->currency_code); + $bankstatic->account_number = $obj->account_number; + $bankstatic->clos = $obj->clos; + + //$accountingjournal->fetch($obj->fk_accountancy_journal); + //$bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); + + $bankstatic->label = $obj->blabel; + print $bankstatic->getNomUrl(1); + } + print '' . price($obj->amount) . '' . $tva_static->LibStatut($obj->paye, 5, $obj->alreadypayed) . '
'; + print ''; + print ''; $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate")); @@ -1034,8 +1061,8 @@ if (!empty($arrayfields['p.tms']['checked'])) { } // Status if (!empty($arrayfields['p.statut']['checked'])) { - print ''; - print $form->selectarray('search_status', array('-1'=>'', '0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $search_status, 0, 0, 0, '', 0, 0, 0, '', 'minwidth75 onrightofpage'); + print ''; + print $form->selectarray('search_status', array('-1'=>'', '0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $search_status, 0, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage'); print ''; + print dol_escape_htmltag($obj->alias); + print ''.$contactstatic->LibPubPriv($obj->priv).''.$langs->trans("PriceUHTCurrency").''.$langs->trans("Qty").''.$langs->trans("Unit").''.$langs->trans("ReductionShort").''.$objp->qty.''.$langs->trans($object->lines[$cursorline - 1]->getLabelOfUnit()).''; print $form->selectUnits($objp->fk_unit, "unit"); print '
'; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print ''; - print $contracttmp->getNomUrl(1); - if ($obj->nb_late) { - print img_warning($langs->trans("Late")); - } - if (!empty($obj->note_private) || !empty($obj->note_public)) { - print ' '; - print ''.img_picto($langs->trans("ViewPrivateNote"), 'note').''; - print ''; + //mode kanban + if ($mode == 'kanban') { + if ($i == 0) { + print '
'; + print '
'; } - $filename = dol_sanitizeFileName($obj->ref); - $filedir = $conf->contrat->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; - print $formfile->getDocumentsLink($contracttmp->element, $filename, $filedir); - print '
'.$contracttmp->getFormatedCustomerRef($obj->ref_customer).''.dol_escape_htmltag($obj->ref_supplier).''; - if ($obj->socid > 0) { - // TODO Use a cache for this string - print $socstatic->getNomUrl(1, ''); + // Output Kanban + $contracttmp->societe = $socstatic->getNomUrl(); + $contracttmp->date_contrat = $obj->date_contrat; + print $contracttmp->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print ''; + print '
'.dol_print_email($obj->email, 0, $obj->socid, 0, 0, 1, 1).''; - print $obj->town; - print ''; - print $obj->zip; - print '".$obj->state_name."'; - print dol_escape_htmltag($socstatic->country); - print ''; - if (count($typenArray) == 0) { - $typenArray = $formcompany->typent_array(1); - } - print $typenArray[$obj->typent_code]; - print ''; - if ($obj->socid > 0) { - $listsalesrepresentatives = $socstatic->getSalesRepresentatives($user); - if ($listsalesrepresentatives < 0) { - dol_print_error($db); - } - $nbofsalesrepresentative = count($listsalesrepresentatives); - if ($nbofsalesrepresentative > 6) { - // We print only number - print $nbofsalesrepresentative; - } elseif ($nbofsalesrepresentative > 0) { - $userstatic = new User($db); - $j = 0; - foreach ($listsalesrepresentatives as $val) { - $userstatic->id = $val['id']; - $userstatic->lastname = $val['lastname']; - $userstatic->firstname = $val['firstname']; - $userstatic->email = $val['email']; - $userstatic->statut = $val['statut']; - $userstatic->entity = $val['entity']; - $userstatic->photo = $val['photo']; - $userstatic->login = $val['login']; - $userstatic->phone = $val['phone']; - $userstatic->job = $val['job']; - $userstatic->gender = $val['gender']; - - //print '
': - print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2); - $j++; - if ($j < $nbofsalesrepresentative) { - print ' '; - } - //print '
'; + } else { + print '
'; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; } + print ''; } - //else print $langs->trans("NoSalesRepresentativeAffected"); - } else { - print ' '; + print ''.dol_print_date($db->jdate($obj->date_contrat), 'day', 'tzserver').''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->lower_planned_end_date), 'day', 'tzuser'); - print ''.($obj->nb_initial > 0 ? $obj->nb_initial : '').''.($obj->nb_running > 0 ? $obj->nb_running : '').''.($obj->nb_expired > 0 ? $obj->nb_expired : '').''.($obj->nb_closed > 0 ? $obj->nb_closed : '').''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; + // Ref + if (!empty($arrayfields['c.ref']['checked'])) { + print ''; + print $contracttmp->getNomUrl(1); + if ($obj->nb_late) { + print img_warning($langs->trans("Late")); + } + if (!empty($obj->note_private) || !empty($obj->note_public)) { + print ' '; + print ''.img_picto($langs->trans("ViewPrivateNote"), 'note').''; + print ''; } - print ''; - } - print '
'.$contracttmp->getFormatedCustomerRef($obj->ref_customer).''.dol_escape_htmltag($obj->ref_supplier).''; + if ($obj->socid > 0) { + // TODO Use a cache for this string + print $socstatic->getNomUrl(1, ''); + } + print ''.dol_print_email($obj->email, 0, $obj->socid, 0, 0, 1, 1).''; + print $obj->town; + print ''; + print $obj->zip; + print '".$obj->state_name."'; + print dol_escape_htmltag($socstatic->country); + print ''; + if (count($typenArray) == 0) { + $typenArray = $formcompany->typent_array(1); + } + print $typenArray[$obj->typent_code]; + print ''; + if ($obj->socid > 0) { + $listsalesrepresentatives = $socstatic->getSalesRepresentatives($user); + if ($listsalesrepresentatives < 0) { + dol_print_error($db); + } + $nbofsalesrepresentative = count($listsalesrepresentatives); + if ($nbofsalesrepresentative > 6) { + // We print only number + print $nbofsalesrepresentative; + } elseif ($nbofsalesrepresentative > 0) { + $userstatic = new User($db); + $j = 0; + foreach ($listsalesrepresentatives as $val) { + $userstatic->id = $val['id']; + $userstatic->lastname = $val['lastname']; + $userstatic->firstname = $val['firstname']; + $userstatic->email = $val['email']; + $userstatic->statut = $val['statut']; + $userstatic->entity = $val['entity']; + $userstatic->photo = $val['photo']; + $userstatic->login = $val['login']; + $userstatic->phone = $val['phone']; + $userstatic->job = $val['job']; + $userstatic->gender = $val['gender']; + + //print '
': + print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2); + $j++; + if ($j < $nbofsalesrepresentative) { + print ' '; + } + //print '
'; + } + } + //else print $langs->trans("NoSalesRepresentativeAffected"); + } else { + print ' '; + } + print '
'.dol_print_date($db->jdate($obj->date_contrat), 'day', 'tzserver').''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->lower_planned_end_date), 'day', 'tzuser'); + print ''.($obj->nb_initial > 0 ? $obj->nb_initial : '').''.($obj->nb_running > 0 ? $obj->nb_running : '').''.($obj->nb_expired > 0 ? $obj->nb_expired : '').''.($obj->nb_closed > 0 ? $obj->nb_closed : '').''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print '
'.$langs->trans('PriceUHTCurrency').''.$langs->trans('Qty').''.$langs->trans('Unit').''.$langs->trans('ReductionShort').''; print ($line->ref_fourn ? $line->ref_fourn : $line->ref_supplier); print ''; $coldisplay++; @@ -276,8 +313,9 @@ if (price2num($line->total_localtax2)) { if (empty($positiverates)) { $positiverates = '0'; } +print $tooltiponprice; print vatrate($positiverates.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''), '%', $line->info_bits); -//print vatrate($line->tva_tx.($line->vat_src_code?(' ('.$line->vat_src_code.')'):''), '%', $line->info_bits); +print $tooltiponpriceend; ?> subprice); ?>marque_tx, 'MT')).'%'; ?> trans('Option'); ?> '.price($sign * $line->multicurrency_total_ht).''.price($sign * $line->total_ttc).''; $coldisplay++; @@ -434,6 +444,7 @@ if ($this->statut == 0 && !empty($object_rights->creer) && $action != 'selectlin print ''; $coldisplay++; if (($line->info_bits & 2) == 2 || !empty($disableedit)) { @@ -443,6 +454,7 @@ if ($this->statut == 0 && !empty($object_rights->creer) && $action != 'selectlin } print ''; $coldisplay++; if (!$situationinvoicelinewithparent && empty($disableremove)) { // For situation invoice, deletion is not possible if there is a parent company. @@ -452,6 +464,7 @@ if ($this->statut == 0 && !empty($object_rights->creer) && $action != 'selectlin } print ''; $coldisplay++; diff --git a/htdocs/core/tpl/passwordforgotten.tpl.php b/htdocs/core/tpl/passwordforgotten.tpl.php index 3fdbcd14ef3..e9d7de9a1bf 100644 --- a/htdocs/core/tpl/passwordforgotten.tpl.php +++ b/htdocs/core/tpl/passwordforgotten.tpl.php @@ -76,7 +76,7 @@ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $disablenofollow = 0; } -print top_htmlhead('', $titleofpage, 0, 0, $arrayofjs, array(), 1, $disablenofollow); +top_htmlhead('', $titleofpage, 0, 0, $arrayofjs, array(), 1, $disablenofollow); $colorbackhmenu1 = '60,70,100'; // topmenu @@ -253,7 +253,7 @@ if ($mode == 'dolibarr' || !$disabled) { diff --git a/htdocs/core/tpl/passwordreset.tpl.php b/htdocs/core/tpl/passwordreset.tpl.php index 1f35b1a251a..e9d518dba64 100644 --- a/htdocs/core/tpl/passwordreset.tpl.php +++ b/htdocs/core/tpl/passwordreset.tpl.php @@ -77,7 +77,7 @@ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $disablenofollow = 0; } -print top_htmlhead('', $titleofpage, 0, 0, $arrayofjs, array(), 1, $disablenofollow); +top_htmlhead('', $titleofpage, 0, 0, $arrayofjs, array(), 1, $disablenofollow); $colorbackhmenu1 = '60,70,100'; // topmenu @@ -292,7 +292,7 @@ if ($mode == 'dolibarr' || !$disabled) { diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index abaadfc85a8..b6bd9bb73a8 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -90,6 +90,9 @@ class InterfaceWorkflowManager extends DolibarrTriggers $this->error = $newobject->error; $this->errors[] = $newobject->error; } + + $object->clearObjectLinkedCache(); + return $ret; } } @@ -111,6 +114,9 @@ class InterfaceWorkflowManager extends DolibarrTriggers $this->error = $newobject->error; $this->errors[] = $newobject->error; } + + $object->clearObjectLinkedCache(); + return $ret; } } diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index be78b6ecc18..ae53b01e19b 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -931,7 +931,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->sendtoid = 0; } else { // TODO Merge all previous cases into this generic one - // $action = BILL_DELETE, TICKET_CREATE, TICKET_MODIFY, TICKET_DELETE, CONTACT_SENTBYMAIL, RECRUITMENTCANDIDATURE_MODIFY, ... + // $action = PASSWORD, BILL_DELETE, TICKET_CREATE, TICKET_MODIFY, TICKET_DELETE, CONTACT_SENTBYMAIL, RECRUITMENTCANDIDATURE_MODIFY, ... // Can also be a value defined by an external module like SENTBYSMS, COMPANY_SENTBYSMS, MEMBER_SENTBYSMS, ... // Note: We are here only if $conf->global->MAIN_AGENDA_ACTIONAUTO_action is on (tested at begining of this function). // Note that these key can be set in agenda setup, only if defined into llx_c_action_trigger diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 30f195b550b..aaccb39e68e 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -448,7 +448,7 @@ print '  '; -print $form->selectarray('search_status', array('0'=>$langs->trans("Disabled"), '1'=>$langs->trans("Scheduled")), $search_status, 1, 0, 0, '', 0, 0, 0, '', 'onrightofpage'); +print $form->selectarray('search_status', array('0'=>$langs->trans("Disabled"), '1'=>$langs->trans("Scheduled")), $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage'); print ''; $searchpicto = $form->showFilterButtons(); print $searchpicto; diff --git a/htdocs/dav/dav.class.php b/htdocs/dav/dav.class.php index 012708c8960..a0375210271 100644 --- a/htdocs/dav/dav.class.php +++ b/htdocs/dav/dav.class.php @@ -251,7 +251,7 @@ class CdavLib */ public function getFullCalendarObjects($calendarId, $bCalendarData) { - $calid = ($calendarId * 1); + $calid = (int) $calendarId; $calevents = array(); if (!$this->user->rights->agenda->myactions->read) { diff --git a/htdocs/debugbar/class/DataCollector/DolConfigCollector.php b/htdocs/debugbar/class/DataCollector/DolConfigCollector.php index 715d20abcf9..0920b140dbc 100644 --- a/htdocs/debugbar/class/DataCollector/DolConfigCollector.php +++ b/htdocs/debugbar/class/DataCollector/DolConfigCollector.php @@ -1,4 +1,25 @@ + * + * 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/debugbar/class/DataCollector/DolConfigCollector.php + * \brief Class for debugbar collection + * \ingroup debugbar + */ use \DebugBar\DataCollector\ConfigCollector; diff --git a/htdocs/debugbar/class/DataCollector/DolExceptionsCollector.php b/htdocs/debugbar/class/DataCollector/DolExceptionsCollector.php index 15d433fd050..38d2b971dde 100644 --- a/htdocs/debugbar/class/DataCollector/DolExceptionsCollector.php +++ b/htdocs/debugbar/class/DataCollector/DolExceptionsCollector.php @@ -1,4 +1,25 @@ + * + * 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/debugbar/class/DataCollector/DolexceptionsCollector.php + * \brief Class for debugbar collection + * \ingroup debugbar + */ use \DebugBar\DataCollector\ExceptionsCollector; diff --git a/htdocs/debugbar/class/DataCollector/DolLogsCollector.php b/htdocs/debugbar/class/DataCollector/DolLogsCollector.php index d21cdd6233f..44885296bae 100644 --- a/htdocs/debugbar/class/DataCollector/DolLogsCollector.php +++ b/htdocs/debugbar/class/DataCollector/DolLogsCollector.php @@ -1,4 +1,25 @@ + * + * 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/debugbar/class/DataCollector/DolLogsCollector.php + * \brief Class for debugbar collection + * \ingroup debugbar + */ use DebugBar\DataCollector\MessagesCollector; use Psr\Log\LogLevel; diff --git a/htdocs/debugbar/class/DataCollector/DolMemoryCollector.php b/htdocs/debugbar/class/DataCollector/DolMemoryCollector.php index b52ac8ff8c4..3372e89c2b6 100644 --- a/htdocs/debugbar/class/DataCollector/DolMemoryCollector.php +++ b/htdocs/debugbar/class/DataCollector/DolMemoryCollector.php @@ -1,17 +1,37 @@ + * + * 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/debugbar/class/DataCollector/DolMemoryCollector.php + * \brief Class for debugbar collection + * \ingroup debugbar + */ use \DebugBar\DataCollector\MemoryCollector; /** * DolMemoryCollector class */ - class DolMemoryCollector extends MemoryCollector { /** * Return value of indicator * - * @return void + * @return array */ public function collect() { @@ -28,7 +48,7 @@ class DolMemoryCollector extends MemoryCollector /** * Return widget settings * - * @return void + * @return array */ public function getWidgets() { diff --git a/htdocs/debugbar/class/DataCollector/DolMessagesCollector.php b/htdocs/debugbar/class/DataCollector/DolMessagesCollector.php index 1fcf60c8ba6..733009e77c6 100644 --- a/htdocs/debugbar/class/DataCollector/DolMessagesCollector.php +++ b/htdocs/debugbar/class/DataCollector/DolMessagesCollector.php @@ -1,4 +1,25 @@ + * + * 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/debugbar/class/DataCollector/DolMessagesCollector.php + * \brief Class for debugbar collection + * \ingroup debugbar + */ use \DebugBar\DataCollector\MessagesCollector; diff --git a/htdocs/debugbar/class/DataCollector/DolPhpCollector.php b/htdocs/debugbar/class/DataCollector/DolPhpCollector.php index 3d6536bd258..bca2b2a7071 100644 --- a/htdocs/debugbar/class/DataCollector/DolPhpCollector.php +++ b/htdocs/debugbar/class/DataCollector/DolPhpCollector.php @@ -1,4 +1,25 @@ + * + * 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/debugbar/class/DataCollector/DolPhpCollector.php + * \brief Class for debugbar collection + * \ingroup debugbar + */ use DebugBar\DataCollector\DataCollector; use DebugBar\DataCollector\Renderable; diff --git a/htdocs/debugbar/class/DataCollector/DolQueryCollector.php b/htdocs/debugbar/class/DataCollector/DolQueryCollector.php index ca5aa284dd2..8cc55e34df9 100644 --- a/htdocs/debugbar/class/DataCollector/DolQueryCollector.php +++ b/htdocs/debugbar/class/DataCollector/DolQueryCollector.php @@ -1,4 +1,25 @@ + * + * 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/debugbar/class/DataCollector/DolQueryCollector.php + * \brief Class for debugbar collection + * \ingroup debugbar + */ use DebugBar\DataCollector\AssetProvider; use DebugBar\DataCollector\DataCollector; diff --git a/htdocs/debugbar/class/DataCollector/DolRequestDataCollector.php b/htdocs/debugbar/class/DataCollector/DolRequestDataCollector.php index 938643802d5..4ddcac9af7c 100644 --- a/htdocs/debugbar/class/DataCollector/DolRequestDataCollector.php +++ b/htdocs/debugbar/class/DataCollector/DolRequestDataCollector.php @@ -1,4 +1,25 @@ + * + * 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/debugbar/class/DataCollector/DolRequestDataCollector.php + * \brief Class for debugbar collection + * \ingroup debugbar + */ use \DebugBar\DataCollector\RequestDataCollector; diff --git a/htdocs/debugbar/class/DataCollector/DolTimeDataCollector.php b/htdocs/debugbar/class/DataCollector/DolTimeDataCollector.php index ed5e979d539..d16622d329f 100644 --- a/htdocs/debugbar/class/DataCollector/DolTimeDataCollector.php +++ b/htdocs/debugbar/class/DataCollector/DolTimeDataCollector.php @@ -1,4 +1,25 @@ + * + * 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/debugbar/class/DataCollector/DolTimeDataCollector.php + * \brief Class for debugbar collection + * \ingroup debugbar + */ use \DebugBar\DataCollector\TimeDataCollector; diff --git a/htdocs/debugbar/class/DataCollector/DolibarrCollector.php b/htdocs/debugbar/class/DataCollector/DolibarrCollector.php index 3193fe26176..11cedbe2b93 100644 --- a/htdocs/debugbar/class/DataCollector/DolibarrCollector.php +++ b/htdocs/debugbar/class/DataCollector/DolibarrCollector.php @@ -1,4 +1,25 @@ + * + * 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/debugbar/class/DataCollector/DolibarrCollector.php + * \brief Class for debugbar collection + * \ingroup debugbar + */ use DebugBar\DataCollector\AssetProvider; use DebugBar\DataCollector\DataCollector; diff --git a/htdocs/debugbar/class/DebugBar.php b/htdocs/debugbar/class/DebugBar.php index bf797e638f7..6181ad7cd60 100644 --- a/htdocs/debugbar/class/DebugBar.php +++ b/htdocs/debugbar/class/DebugBar.php @@ -1,4 +1,25 @@ + * + * 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/debugbar/class/DebugBar.php + * \brief Class for debugbar + * \ingroup debugbar + */ dol_include_once('/debugbar/class/autoloader.php'); diff --git a/htdocs/debugbar/class/TraceableDB.php b/htdocs/debugbar/class/TraceableDB.php index a5f76f71aa7..8e28b0c59bd 100644 --- a/htdocs/debugbar/class/TraceableDB.php +++ b/htdocs/debugbar/class/TraceableDB.php @@ -1,4 +1,25 @@ + * + * 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/debugbar/class/DataCollector/TraceableDB.php + * \brief Class for debugbar DB + * \ingroup debugbar + */ require_once DOL_DOCUMENT_ROOT.'/core/db/DoliDB.class.php'; @@ -649,7 +670,7 @@ class TraceableDB extends DoliDB */ public function free($resultset = null) { - return $this->db->free($resultset); + $this->db->free($resultset); } /** diff --git a/htdocs/document.php b/htdocs/document.php index 4f6652fafda..eccf49de0be 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -286,9 +286,10 @@ $hookmanager->initHooks(array('document')); $parameters = array('ecmfile' => $ecmfile, 'modulepart' => $modulepart, 'original_file' => $original_file, 'entity' => $entity, 'refname' => $refname, 'fullpath_original_file' => $fullpath_original_file, 'filename' => $filename, 'fullpath_original_file_osencoded' => $fullpath_original_file_osencoded); -$reshook = $hookmanager->executeHooks('downloadDocument', $parameters); // Note that $action and $object may have been +$object = new stdClass(); +$reshook = $hookmanager->executeHooks('downloadDocument', $parameters, $object, $action); // Note that $action and $object may have been if ($reshook < 0) { - $errors = $hookmanager->error.(is_array($hookmanager->errors) ? (!empty($hookmanager->error) ? ', ' : '').join($separator, $hookmanager->errors) : ''); + $errors = $hookmanager->error.(is_array($hookmanager->errors) ? (!empty($hookmanager->error) ? ', ' : '').join(', ', $hookmanager->errors) : ''); dol_syslog("document.php - Errors when executing the hook 'downloadDocument' : ".$errors); print "ErrorDownloadDocumentHooks: ".$errors; exit; diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 459c892a1d9..ec22c82543f 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -52,7 +52,7 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); - +$socid = GETPOST('socid', 'int'); $amount = price2num(GETPOST('amount', 'alphanohtml'), 'MT'); $donation_date = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0); @@ -63,6 +63,13 @@ if ($id > 0 || $ref) { $object->fetch($id, $ref); } +if (!empty($socid) && $socid > 0) { + $soc = new Societe($db); + if ($socid > 0) { + $soc->fetch($socid); + } +} + $extrafields = new ExtraFields($db); // fetch optionals attributes and labels diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 333f9673175..c1d09a6cdd0 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -206,7 +206,7 @@ class Don extends CommonObject */ public function initAsSpecimen() { - global $conf, $user, $langs; + global $conf; $now = dol_now(); @@ -224,10 +224,10 @@ class Don extends CommonObject $num_socs = $this->db->num_rows($resql); $i = 0; while ($i < $num_socs) { - $i++; - $row = $this->db->fetch_row($resql); $socids[$i] = $row[0]; + + $i++; } } @@ -237,7 +237,7 @@ class Don extends CommonObject $this->specimen = 1; $this->lastname = 'Doe'; $this->firstname = 'John'; - $this->socid = 1; + $this->socid = empty($socids[0]) ? 0 : $socids[0]; $this->date = $now; $this->date_valid = $now; $this->amount = 100.90; @@ -1141,4 +1141,39 @@ class Don extends CommonObject return (float) $this->amount - $sum_amount; } } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + global $langs; + + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + if (property_exists($this, 'date')) { + $return .= ' | '.$langs->trans("Date").' : '.dol_print_date($this->date).''; + } + if (property_exists($this, 'societe') && !empty($this->societe)) { + $return .= '
'.$langs->trans("Company").' : '.$this->societe.''; + } + if (property_exists($this, 'amount')) { + $return .= '
'.$langs->trans("Amount").' : '.price($this->amount).''; + } + if (method_exists($this, 'LibStatut')) { + $return .= '
'.$this->LibStatut($this->labelStatus, 5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/don/list.php b/htdocs/don/list.php index ac704571daa..eb487be4768 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -42,6 +42,7 @@ $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $type = GETPOST('type', 'aZ'); +$mode = GETPOST('mode', 'alpha'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -59,6 +60,7 @@ $search_status = (GETPOST("search_status", 'intcomma') != '') ? GETPOST("search_ $search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $search_ref = GETPOST('search_ref', 'alpha'); $search_company = GETPOST('search_company', 'alpha'); +$search_thirdparty = GETPOST('search_thirdparty', 'alpha'); $search_name = GETPOST('search_name', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); @@ -71,6 +73,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_all = ""; $search_ref = ""; $search_company = ""; + $search_thirdparty = ""; $search_name = ""; $search_amount = ""; $search_status = ''; @@ -153,6 +156,9 @@ if ($resql) { $i = 0; $param = ''; + if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); + } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -179,6 +185,8 @@ if ($resql) { } $newcardbutton = ''; + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); if ($user->rights->don->creer) { $newcardbutton .= dolGetButtonTitle($langs->trans('NewDonation'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/don/card.php?action=create'); } @@ -193,6 +201,9 @@ if ($resql) { print ''; print ''; print ''; + print ''; + + print_barre_liste($langs->trans("Donations"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'object_donation', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -232,14 +243,14 @@ if ($resql) { print '
'; + print ''; $liststatus = array( Don::STATUS_DRAFT=>$langs->trans("DonationStatusPromiseNotValidated"), Don::STATUS_VALIDATED=>$langs->trans("DonationStatusPromiseValidated"), Don::STATUS_PAID=>$langs->trans("DonationStatusPaid"), Don::STATUS_CANCELED=>$langs->trans("Canceled") ); - print $form->selectarray('search_status', $liststatus, $search_status, -4, 0, 0, '', 0, 0, 0, '', 'maxwidth100 onrightofpage'); + print $form->selectarray('search_status', $liststatus, $search_status, -4, 0, 0, '', 0, 0, 0, '', 'search_status maxwidth100 onrightofpage'); print ''; $searchpicto = $form->showFilterAndCheckAddButtons(0); @@ -267,44 +278,70 @@ if ($resql) { while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); + $donationstatic->setVarsFromFetchObj($objp); + $company = new Societe($db); + $result = $company->fetch($objp->socid); + + if ($mode == 'kanban') { + if ($i == 0) { + print '
'; + print '
'; + } + // Output Kanban + $donationstatic->amount = $objp->amount; + $donationstatic->date = $objp->datedon; + $donationstatic->labelStatus = $objp->status; + $donationstatic->id = $objp->rowid; + $donationstatic->ref = $objp->rowid; - print '
".$donationstatic->getNomUrl(1)."".$company->getNomUrl(1)."
".$donationstatic->getNomUrl(1)."".$company->getNomUrl(1)."".$objp->societe."".$objp->societe."".$objp->societe."".$donationstatic->getFullName($langs)."'.dol_print_date($db->jdate($objp->datedon), 'day').'"; - if ($objp->pid) { - $projectstatic->id = $objp->pid; - $projectstatic->ref = $objp->ref; - $projectstatic->id = $objp->pid; - $projectstatic->public = $objp->public; - $projectstatic->title = $objp->title; - print $projectstatic->getNomUrl(1); - } else { - print ' '; + print "".$donationstatic->getFullName($langs)."'.dol_print_date($db->jdate($objp->datedon), 'day').'"; + if ($objp->pid) { + $projectstatic->id = $objp->pid; + $projectstatic->ref = $objp->ref; + $projectstatic->id = $objp->pid; + $projectstatic->public = $objp->public; + $projectstatic->title = $objp->title; + print $projectstatic->getNomUrl(1); + } else { + print ' '; + } + print "'.price($objp->amount).''.$donationstatic->LibStatut($objp->status, 5).'
'.price($objp->amount).''.$donationstatic->LibStatut($objp->status, 5).'
"; diff --git a/htdocs/don/payment/card.php b/htdocs/don/payment/card.php index 19f40bc984e..416e848d271 100644 --- a/htdocs/don/payment/card.php +++ b/htdocs/don/payment/card.php @@ -181,7 +181,7 @@ if ($resql) { // Expected to pay print '
'.price($objp->d_amount).''.$don->getLibStatut(4, $objp->amount).''.$don->getLibStatut(4).''.price($objp->amount).'
'; + print '
'; - // Linked documents - if ($typeobject == 'commande' && $object->$typeobject->id && isModEnabled('commande')) { - print ''; - print '\n"; - print ''; - } - if ($typeobject == 'propal' && $object->$typeobject->id && isModEnabled("propal")) { - print ''; - print '\n"; - print ''; - } - - // Date creation - print ''; - print '\n"; - print ''; - - // Delivery date planned - print ''; - print ''; - - // Weight + // Linked documents + if ($typeobject == 'commande' && $object->$typeobject->id && isModEnabled('commande')) { print ''; - - // Width - print ''; - - // Height - print ''; - - // Depth - print ''; - - // Volume - print ''; + print $langs->trans("RefOrder").''; print '\n"; print ''; - - // Other attributes - $cols = 2; - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - - print '
'; - print $langs->trans("RefOrder").''; - print $objectsrc->getNomUrl(1, 'commande'); - print "
'; - print $langs->trans("RefProposal").''; - print $objectsrc->getNomUrl(1, 'expedition'); - print "
'.$langs->trans("DateCreation").''.dol_print_date($object->date_creation, "dayhour")."
'; - print ''; - - if ($action != 'editdate_livraison') { - print ''; - } - print '
'; - print $langs->trans('DateDeliveryPlanned'); - print 'id.'">'.img_edit($langs->trans('SetDeliveryDate'), 1).'
'; - print '
'; - if ($action == 'editdate_livraison') { - print ''; - print ''; - print ''; - print $form->selectDate($object->date_delivery ? $object->date_delivery : -1, 'liv_', 1, 1, '', "setdate_livraison", 1, 0); - print ''; - print ''; - } else { - print $object->date_delivery ? dol_print_date($object->date_delivery, 'dayhour') : ' '; - } - print '
'; - print $form->editfieldkey("Weight", 'trueWeight', $object->trueWeight, $object, $user->rights->expedition->creer); - print ''; - - if ($action == 'edittrueWeight') { - print '
'; - print ''; - print ''; - print ''; - print ''; - print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units, 0, 2); - print ' '; - print ' '; - print '
'; - } else { - print $object->trueWeight; - print ($object->trueWeight && $object->weight_units != '') ? ' '.measuringUnitString(0, "weight", $object->weight_units) : ''; - } - - // Calculated - if ($totalWeight > 0) { - if (!empty($object->trueWeight)) { - print ' ('.$langs->trans("SumOfProductWeights").': '; - } - print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); - if (!empty($object->trueWeight)) { - print ')'; - } - } - print '
'.$form->editfieldkey("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->expedition->creer).''; - print $form->editfieldval("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->expedition->creer); - print ($object->trueWidth && $object->width_units != '') ? ' '.measuringUnitString(0, "size", $object->width_units) : ''; - print '
'.$form->editfieldkey("Height", 'trueHeight', $object->trueHeight, $object, $user->rights->expedition->creer).''; - if ($action == 'edittrueHeight') { - print '
'; - print ''; - print ''; - print ''; - print ''; - print $formproduct->selectMeasuringUnits("size_units", "size", $object->size_units, 0, 2); - print ' '; - print ' '; - print '
'; - } else { - print $object->trueHeight; - print ($object->trueHeight && $object->height_units != '') ? ' '.measuringUnitString(0, "size", $object->height_units) : ''; - } - - print '
'.$form->editfieldkey("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->expedition->creer).''; - print $form->editfieldval("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->expedition->creer); - print ($object->trueDepth && $object->depth_units != '') ? ' '.measuringUnitString(0, "size", $object->depth_units) : ''; - print '
'; - print $langs->trans("Volume"); - print ''; - $calculatedVolume = 0; - $volumeUnit = 0; - if ($object->trueWidth && $object->trueHeight && $object->trueDepth) { - $calculatedVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth); - $volumeUnit = $object->size_units * 3; - } - // If sending volume not defined we use sum of products - if ($calculatedVolume > 0) { - if ($volumeUnit < 50) { - print showDimensionInBestUnit($calculatedVolume, $volumeUnit, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); - } else { - print $calculatedVolume.' '.measuringUnitString(0, "volume", $volumeUnit); - } - } - if ($totalVolume > 0) { - if ($calculatedVolume) { - print ' ('.$langs->trans("SumOfProductVolumes").': '; - } - print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); - //if (empty($calculatedVolume)) print ' ('.$langs->trans("Calculated").')'; - if ($calculatedVolume) { - print ')'; - } - } + print $objectsrc->getNomUrl(1, 'commande'); print "
'; - - print ''; - print '
'; - print '
'; - - print ''; - - // Sending method - print ''; + } + if ($typeobject == 'propal' && $object->$typeobject->id && isModEnabled("propal")) { + print ''; + print '\n"; print ''; + } - // Tracking Number - print ''; + // Date creation + print ''; + print '\n"; + print ''; - // Incoterms - if (isModEnabled('incoterm')) { - print ''; - print ''; + // Delivery date planned + print ''; + print ''; + + // Weight + print '
'; - print ''; - - if ($action != 'editshipping_method_id') { - print ''; - } - print '
'; - print $langs->trans('SendingMethod'); - print 'id.'">'.img_edit($langs->trans('SetSendingMethod'), 1).'
'; - print '
'; - if ($action == 'editshipping_method_id') { - print '
'; - print ''; - print ''; - $object->fetch_delivery_methods(); - print $form->selectarray("shipping_method_id", $object->meths, $object->shipping_method_id, 1, 0, 0, "", 1); - if ($user->admin) { - print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - } - print ''; - print '
'; - } else { - if ($object->shipping_method_id > 0) { - // Get code using getLabelFromKey - $code = $langs->getLabelFromKey($db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); - print $langs->trans("SendingMethod".strtoupper($code)); - } - } - print '
'; + print $langs->trans("RefProposal").''; + print $objectsrc->getNomUrl(1, 'expedition'); + print "
'.$form->editfieldkey("TrackingNumber", 'tracking_number', $object->tracking_number, $object, $user->rights->expedition->creer).''; - print $form->editfieldval("TrackingNumber", 'tracking_number', $object->tracking_url, $object, $user->rights->expedition->creer, 'safehtmlstring', $object->tracking_number); - print '
'.$langs->trans("DateCreation").''.dol_print_date($object->date_creation, "dayhour")."
'; - print '
'; - print $langs->trans('IncotermLabel'); - print ''; - if ($user->rights->expedition->creer) { - print ''.img_edit().''; - } else { - print ' '; - } - print '
'; - print '
'; - if ($action != 'editincoterm') { - print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); - } else { - print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); - } - print '
'; + print ''; + + if ($action != 'editdate_livraison') { + print ''; + } + print '
'; + print $langs->trans('DateDeliveryPlanned'); + print 'id.'">'.img_edit($langs->trans('SetDeliveryDate'), 1).'
'; + print '
'; + if ($action == 'editdate_livraison') { + print '
'; + print ''; + print ''; + print $form->selectDate($object->date_delivery ? $object->date_delivery : -1, 'liv_', 1, 1, '', "setdate_livraison", 1, 0); + print ''; + print '
'; + } else { + print $object->date_delivery ? dol_print_date($object->date_delivery, 'dayhour') : ' '; + } + print '
'; + print $form->editfieldkey("Weight", 'trueWeight', $object->trueWeight, $object, $user->rights->expedition->creer); + print ''; + + if ($action == 'edittrueWeight') { + print '
'; + print ''; + print ''; + print ''; + print ''; + print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units, 0, 2); + print ' '; + print ' '; + print '
'; + } else { + print $object->trueWeight; + print ($object->trueWeight && $object->weight_units != '') ? ' '.measuringUnitString(0, "weight", $object->weight_units) : ''; + } + + // Calculated + if ($totalWeight > 0) { + if (!empty($object->trueWeight)) { + print ' ('.$langs->trans("SumOfProductWeights").': '; } - - // Other attributes - $parameters = array('colspan' => ' colspan="3"', 'cols' => '3'); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - print "
"; - - print '
'; - print ''; - - print '
'; - - - // Lines of products - - if ($action == 'editline') { - print '
- - - - - '; + print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); + if (!empty($object->trueWeight)) { + print ')'; } - print '
'; + } + print '
'; - print ''; - print ''; - // Adds a line numbering column - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - print ''; - } - // Product/Service - print ''; - // Qty - print ''; - if ($origin && $origin_id > 0) { - print ''; - } - if ($action == 'editline') { - $editColspan = 3; - if (!isModEnabled('stock')) { - $editColspan--; - } - if (empty($conf->productbatch->enabled)) { - $editColspan--; - } - print ''; + // Width + print ''; + + // Height + print ''; + + // Depth + print ''; + + // Volume + print ''; + print ''; - } else { - print ''; - } - if (isModEnabled('stock')) { - print ''; - } - - if (isModEnabled('productbatch')) { - print ''; - } + print $calculatedVolume.' '.measuringUnitString(0, "volume", $volumeUnit); } - print ''; - print ''; - //print ''; - if ($object->statut == 0) { - print ''; - print ''; + } + if ($totalVolume > 0) { + if ($calculatedVolume) { + print ' ('.$langs->trans("SumOfProductVolumes").': '; } - print "\n"; - print ''; + print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); + //if (empty($calculatedVolume)) print ' ('.$langs->trans("Calculated").')'; + if ($calculatedVolume) { + print ')'; + } + } + print "\n"; + print ''; - $outputlangs = $langs; + // Other attributes + $cols = 2; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { - $object->fetch_thirdparty(); - $newlang = ''; - if (empty($newlang) && GETPOST('lang_id', 'aZ09')) { - $newlang = GETPOST('lang_id', 'aZ09'); - } - if (empty($newlang)) { - $newlang = $object->thirdparty->default_lang; - } - if (!empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } + print '
 '.$langs->trans("Products").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyInOtherShipments").''; - if ($object->statut <= 1) { - print $langs->trans("QtyToShip").' - '; - } else { - print $langs->trans("QtyShipped").' - '; - } - if (isModEnabled('stock')) { - print $langs->trans("WarehouseSource").' - '; - } - if (isModEnabled('productbatch')) { - print $langs->trans("Batch"); - } - print '
'.$form->editfieldkey("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->expedition->creer).''; + print $form->editfieldval("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->expedition->creer); + print ($object->trueWidth && $object->width_units != '') ? ' '.measuringUnitString(0, "size", $object->width_units) : ''; + print '
'.$form->editfieldkey("Height", 'trueHeight', $object->trueHeight, $object, $user->rights->expedition->creer).''; + if ($action == 'edittrueHeight') { + print ''; + print ''; + print ''; + print ''; + print ''; + print $formproduct->selectMeasuringUnits("size_units", "size", $object->size_units, 0, 2); + print ' '; + print ' '; + print ''; + } else { + print $object->trueHeight; + print ($object->trueHeight && $object->height_units != '') ? ' '.measuringUnitString(0, "size", $object->height_units) : ''; + } + + print '
'.$form->editfieldkey("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->expedition->creer).''; + print $form->editfieldval("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->expedition->creer); + print ($object->trueDepth && $object->depth_units != '') ? ' '.measuringUnitString(0, "size", $object->depth_units) : ''; + print '
'; + print $langs->trans("Volume"); + print ''; + $calculatedVolume = 0; + $volumeUnit = 0; + if ($object->trueWidth && $object->trueHeight && $object->trueDepth) { + $calculatedVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth); + $volumeUnit = $object->size_units * 3; + } + // If sending volume not defined we use sum of products + if ($calculatedVolume > 0) { + if ($volumeUnit < 50) { + print showDimensionInBestUnit($calculatedVolume, $volumeUnit, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); } else { - if ($object->statut <= 1) { - print ''.$langs->trans("QtyToShip").''.$langs->trans("QtyShipped").''.$langs->trans("WarehouseSource").''.$langs->trans("Batch").''.$langs->trans("CalculatedWeight").''.$langs->trans("CalculatedVolume").''.$langs->trans("Size").'
'; + + print '
'; + print '
'; + print '
'; + + print ''; + + // Sending method + print ''; + print ''; + + // Tracking Number + print ''; + + // Incoterms + if (isModEnabled('incoterm')) { + print ''; + print ''; + } + + // Other attributes + $parameters = array('colspan' => ' colspan="3"', 'cols' => '3'); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + print "
'; + print ''; + + if ($action != 'editshipping_method_id') { + print ''; + } + print '
'; + print $langs->trans('SendingMethod'); + print 'id.'">'.img_edit($langs->trans('SetSendingMethod'), 1).'
'; + print '
'; + if ($action == 'editshipping_method_id') { + print '
'; + print ''; + print ''; + $object->fetch_delivery_methods(); + print $form->selectarray("shipping_method_id", $object->meths, $object->shipping_method_id, 1, 0, 0, "", 1); + if ($user->admin) { + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + } + print ''; + print '
'; + } else { + if ($object->shipping_method_id > 0) { + // Get code using getLabelFromKey + $code = $langs->getLabelFromKey($db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); + print $langs->trans("SendingMethod".strtoupper($code)); + } + } + print '
'.$form->editfieldkey("TrackingNumber", 'tracking_number', $object->tracking_number, $object, $user->rights->expedition->creer).''; + print $form->editfieldval("TrackingNumber", 'tracking_number', $object->tracking_url, $object, $user->rights->expedition->creer, 'safehtmlstring', $object->tracking_number); + print '
'; + print '
'; + print $langs->trans('IncotermLabel'); + print ''; + if ($user->rights->expedition->creer) { + print ''.img_edit().''; + } else { + print ' '; + } + print '
'; + print '
'; + if ($action != 'editincoterm') { + print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); + } else { + print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); + } + print '
"; + + print '
'; + print ''; + + print '
'; + + + // Lines of products + + if ($action == 'editline') { + print '
+ + + + + '; + } + print '
'; + + print '
'; + print ''; + print ''; + print ''; + // Adds a line numbering column + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + print ''; + } + // Product/Service + print ''; + // Qty + print ''; + if ($origin && $origin_id > 0) { + print ''; + } + if ($action == 'editline') { + $editColspan = 3; + if (!isModEnabled('stock')) { + $editColspan--; + } + if (empty($conf->productbatch->enabled)) { + $editColspan--; + } + print ''; + } else { + if ($object->statut <= 1) { + print ''; + } else { + print ''; + } + if (isModEnabled('stock')) { + print ''; } - // Get list of products already sent for same source object into $alreadysent - $alreadysent = array(); - if ($origin && $origin_id > 0) { - $sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.fk_unit, obj.date_start, obj.date_end"; - $sql .= ", ed.rowid as shipmentline_id, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot"; - $sql .= ", e.rowid as shipment_id, e.ref as shipment_ref, e.date_creation, e.date_valid, e.date_delivery, e.date_expedition"; - //if ($conf->delivery_note->enabled) $sql .= ", l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received"; - $sql .= ', p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tosell as product_tosell, p.tobuy as product_tobuy, p.tobatch as product_tobatch'; - $sql .= ', p.description as product_desc'; - $sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; - $sql .= ", ".MAIN_DB_PREFIX."expedition as e"; - $sql .= ", ".MAIN_DB_PREFIX.$origin."det as obj"; - //if ($conf->delivery_note->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."deliverydet as ld ON ld.fk_delivery = l.rowid AND obj.rowid = ld.fk_origin_line"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid"; - $sql .= " WHERE e.entity IN (".getEntity('expedition').")"; - $sql .= " AND obj.fk_".$origin." = ".((int) $origin_id); - $sql .= " AND obj.rowid = ed.fk_origin_line"; - $sql .= " AND ed.fk_expedition = e.rowid"; - //if ($filter) $sql.= $filter; - $sql .= " ORDER BY obj.fk_product"; + if (isModEnabled('productbatch')) { + print ''; + } + } + print ''; + print ''; + //print ''; + if ($object->statut == 0) { + print ''; + print ''; + } + print "\n"; + print ''; - dol_syslog("expedition/card.php get list of shipment lines", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - $i = 0; + $outputlangs = $langs; - while ($i < $num) { - $obj = $db->fetch_object($resql); - if ($obj) { - // $obj->rowid is rowid in $origin."det" table - $alreadysent[$obj->rowid][$obj->shipmentline_id] = array( - 'shipment_ref'=>$obj->shipment_ref, 'shipment_id'=>$obj->shipment_id, 'warehouse'=>$obj->fk_entrepot, 'qty_shipped'=>$obj->qty_shipped, - 'product_tosell'=>$obj->product_tosell, 'product_tobuy'=>$obj->product_tobuy, 'product_tobatch'=>$obj->product_tobatch, - 'date_valid'=>$db->jdate($obj->date_valid), 'date_delivery'=>$db->jdate($obj->date_delivery)); - } - $i++; + if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + $object->fetch_thirdparty(); + $newlang = ''; + if (empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if (empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } + if (!empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + } + + // Get list of products already sent for same source object into $alreadysent + $alreadysent = array(); + if ($origin && $origin_id > 0) { + $sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.fk_unit, obj.date_start, obj.date_end"; + $sql .= ", ed.rowid as shipmentline_id, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot"; + $sql .= ", e.rowid as shipment_id, e.ref as shipment_ref, e.date_creation, e.date_valid, e.date_delivery, e.date_expedition"; + //if ($conf->delivery_note->enabled) $sql .= ", l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received"; + $sql .= ', p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tosell as product_tosell, p.tobuy as product_tobuy, p.tobatch as product_tobatch'; + $sql .= ', p.description as product_desc'; + $sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; + $sql .= ", ".MAIN_DB_PREFIX."expedition as e"; + $sql .= ", ".MAIN_DB_PREFIX.$origin."det as obj"; + //if ($conf->delivery_note->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."deliverydet as ld ON ld.fk_delivery = l.rowid AND obj.rowid = ld.fk_origin_line"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid"; + $sql .= " WHERE e.entity IN (".getEntity('expedition').")"; + $sql .= " AND obj.fk_".$origin." = ".((int) $origin_id); + $sql .= " AND obj.rowid = ed.fk_origin_line"; + $sql .= " AND ed.fk_expedition = e.rowid"; + //if ($filter) $sql.= $filter; + $sql .= " ORDER BY obj.fk_product"; + + dol_syslog("expedition/card.php get list of shipment lines", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + + while ($i < $num) { + $obj = $db->fetch_object($resql); + if ($obj) { + // $obj->rowid is rowid in $origin."det" table + $alreadysent[$obj->rowid][$obj->shipmentline_id] = array( + 'shipment_ref'=>$obj->shipment_ref, 'shipment_id'=>$obj->shipment_id, 'warehouse'=>$obj->fk_entrepot, 'qty_shipped'=>$obj->qty_shipped, + 'product_tosell'=>$obj->product_tosell, 'product_tobuy'=>$obj->product_tobuy, 'product_tobatch'=>$obj->product_tobatch, + 'date_valid'=>$db->jdate($obj->date_valid), 'date_delivery'=>$db->jdate($obj->date_delivery)); } + $i++; } - //var_dump($alreadysent); + } + //var_dump($alreadysent); + } + + print ''; + + // Loop on each product to send/sent + for ($i = 0; $i < $num_prod; $i++) { + $parameters = array('i' => $i, 'line' => $lines[$i], 'line_id' => $line_id, 'num' => $num_prod, 'alreadysent' => $alreadysent, 'editColspan' => !empty($editColspan) ? $editColspan : 0, 'outputlangs' => $outputlangs); + $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } - print ''; + if (empty($reshook)) { + print ''; // id of order line + print ''; - // Loop on each product to send/sent - for ($i = 0; $i < $num_prod; $i++) { - $parameters = array('i' => $i, 'line' => $lines[$i], 'line_id' => $line_id, 'num' => $num_prod, 'alreadysent' => $alreadysent, 'editColspan' => !empty($editColspan) ? $editColspan : 0, 'outputlangs' => $outputlangs); - $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action); - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + // # + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + print ''; } - if (empty($reshook)) { - print ''; // id of order line - print ''; - - // # - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - print ''; - } - - // Predefined product or service - if ($lines[$i]->fk_product > 0) { - // Define output language - if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { - $prod = new Product($db); - $prod->fetch($lines[$i]->fk_product); - $label = (!empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $lines[$i]->product_label; - } else { - $label = (!empty($lines[$i]->label) ? $lines[$i]->label : $lines[$i]->product_label); - } - - print '\n"; + // Predefined product or service + if ($lines[$i]->fk_product > 0) { + // Define output language + if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + $prod = new Product($db); + $prod->fetch($lines[$i]->fk_product); + $label = (!empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $lines[$i]->product_label; } else { - print '\n"; + $label = (!empty($lines[$i]->label) ? $lines[$i]->label : $lines[$i]->product_label); } - $unit_order = ''; - if (!empty($conf->global->PRODUCT_USE_UNITS)) { - $unit_order = measuringUnitString($lines[$i]->fk_unit); + print '\n"; + } else { + print ''; + if (!empty($lines[$i]->label)) { + $text .= ' '.$lines[$i]->label.''; + print $form->textwithtooltip($text, $lines[$i]->description, 3, '', '', $i); + } else { + print $text.' '.nl2br($lines[$i]->description); + } - // Qty in other shipments (with shipment and warehouse used) - if ($origin && $origin_id > 0) { - print '\n"; + } - $j++; - if ($j > 1) { - print '
'; - } - $shipment_static->fetch($shipmentline_var['shipment_id']); - print $shipment_static->getNomUrl(1); - print ' - '.$shipmentline_var['qty_shipped']; - $htmltext = $langs->trans("DateValidation").' : '.(empty($shipmentline_var['date_valid']) ? $langs->trans("Draft") : dol_print_date($shipmentline_var['date_valid'], 'dayhour')); - if (isModEnabled('stock') && $shipmentline_var['warehouse'] > 0) { - $warehousestatic->fetch($shipmentline_var['warehouse']); - $htmltext .= '
'.$langs->trans("FromLocation").' : '.$warehousestatic->getNomUrl(1, '', 0, 1); - } - print ' '.$form->textwithpicto('', $htmltext, 1); + $unit_order = ''; + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + $unit_order = measuringUnitString($lines[$i]->fk_unit); + } + + // Qty ordered + print ''; + + // Qty in other shipments (with shipment and warehouse used) + if ($origin && $origin_id > 0) { + print ''; } + print ''; + } - if ($action == 'editline' && $lines[$i]->id == $line_id) { - // edit mode - print ''; + } else { + // Qty to ship or shipped + print ''; + + // Warehouse source + if (isModEnabled('stock')) { + print ''; + } + + // Batch number managment + if (isModEnabled('productbatch')) { + if (isset($lines[$i]->detail_batch)) { + print ''; + print ''; - } - - // Batch number managment - if (isModEnabled('productbatch')) { - if (isset($lines[$i]->detail_batch)) { - print ''; - print ''; - } else { - print ''; - } - } - } - - // Weight - print ''; - - // Volume - print ''; - - // Size - //print ''; - - if ($action == 'editline' && $lines[$i]->id == $line_id) { - print ''; - } elseif ($object->statut == Expedition::STATUS_DRAFT) { - // edit-delete buttons - print ''; - print ''; - - // Display lines extrafields - if (!empty($rowExtrafieldsStart)) { - print $rowExtrafieldsStart; - print $rowExtrafieldsView; - print $rowEnd; - } - } - print ""; - - // Display lines extrafields. - // $line is a line of shipment - if (!empty($extrafields)) { - $colspan = 6; - if ($origin && $origin_id > 0) { - $colspan++; - } - if (isModEnabled('productbatch')) { - $colspan++; - } - if (isModEnabled('stock')) { - $colspan++; - } - - $line = $lines[$i]; - $line->fetch_optionals(); - - // TODO Show all in same line by setting $display_type = 'line' - if ($action == 'editline' && $line->id == $line_id) { - print $lines[$i]->showOptionals($extrafields, 'edit', array('colspan'=>$colspan), !empty($indiceAsked) ? $indiceAsked : '', '', 0, 'card'); } else { - print $lines[$i]->showOptionals($extrafields, 'view', array('colspan'=>$colspan), !empty($indiceAsked) ? $indiceAsked : '', '', 0, 'card'); + print ''; } } } + + // Weight + print ''; + + // Volume + print ''; + + // Size + //print ''; + + if ($action == 'editline' && $lines[$i]->id == $line_id) { + print ''; + } elseif ($object->statut == Expedition::STATUS_DRAFT) { + // edit-delete buttons + print ''; + print ''; + + // Display lines extrafields + if (!empty($rowExtrafieldsStart)) { + print $rowExtrafieldsStart; + print $rowExtrafieldsView; + print $rowEnd; + } + } + print ""; + + // Display lines extrafields. + // $line is a line of shipment + if (!empty($extrafields)) { + $colspan = 6; + if ($origin && $origin_id > 0) { + $colspan++; + } + if (isModEnabled('productbatch')) { + $colspan++; + } + if (isModEnabled('stock')) { + $colspan++; + } + + $line = $lines[$i]; + $line->fetch_optionals(); + + // TODO Show all in same line by setting $display_type = 'line' + if ($action == 'editline' && $line->id == $line_id) { + print $lines[$i]->showOptionals($extrafields, 'edit', array('colspan'=>$colspan), !empty($indiceAsked) ? $indiceAsked : '', '', 0, 'card'); + } else { + print $lines[$i]->showOptionals($extrafields, 'view', array('colspan'=>$colspan), !empty($indiceAsked) ? $indiceAsked : '', '', 0, 'card'); + } + } } - - // TODO Show also lines ordered but not delivered - - print "
 '.$langs->trans("Products").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyInOtherShipments").''; + if ($object->statut <= 1) { + print $langs->trans("QtyToShip").' - '; + } else { + print $langs->trans("QtyShipped").' - '; + } + if (isModEnabled('stock')) { + print $langs->trans("WarehouseSource").' - '; + } + if (isModEnabled('productbatch')) { + print $langs->trans("Batch"); + } + print ''.$langs->trans("QtyToShip").''.$langs->trans("QtyShipped").''.$langs->trans("WarehouseSource").''.$langs->trans("Batch").''.$langs->trans("CalculatedWeight").''.$langs->trans("CalculatedVolume").''.$langs->trans("Size").'
'.($i + 1).'
'.($i + 1).''; - - // Show product and description - $product_static->type = $lines[$i]->fk_product_type; - $product_static->id = $lines[$i]->fk_product; - $product_static->ref = $lines[$i]->ref; - $product_static->status = $lines[$i]->product_tosell; - $product_static->status_buy = $lines[$i]->product_tobuy; - $product_static->status_batch = $lines[$i]->product_tobatch; - - $product_static->weight = $lines[$i]->weight; - $product_static->weight_units = $lines[$i]->weight_units; - $product_static->length = $lines[$i]->length; - $product_static->length_units = $lines[$i]->length_units; - $product_static->width = !empty($lines[$i]->width) ? $lines[$i]->width : 0; - $product_static->width_units = !empty($lines[$i]->width_units) ? $lines[$i]->width_units : 0; - $product_static->height = !empty($lines[$i]->height) ? $lines[$i]->height : 0; - $product_static->height_units = !empty($lines[$i]->height_units) ? $lines[$i]->height_units : 0; - $product_static->surface = $lines[$i]->surface; - $product_static->surface_units = $lines[$i]->surface_units; - $product_static->volume = $lines[$i]->volume; - $product_static->volume_units = $lines[$i]->volume_units; - - $text = $product_static->getNomUrl(1); - $text .= ' - '.$label; - $description = (getDolGlobalInt('PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE') ? '' : dol_htmlentitiesbr($lines[$i]->description)); - print $form->textwithtooltip($text, $description, 3, '', '', $i); - print_date_range(!empty($lines[$i]->date_start) ? $lines[$i]->date_start : '', !empty($lines[$i]->date_end) ? $lines[$i]->date_end : ''); - if (getDolGlobalInt('PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE')) { - print (!empty($lines[$i]->description) && $lines[$i]->description != $lines[$i]->product) ? '
'.dol_htmlentitiesbr($lines[$i]->description) : ''; - } - print "
'; - if ($lines[$i]->product_type == Product::TYPE_SERVICE) { - $text = img_object($langs->trans('Service'), 'service'); - } else { - $text = img_object($langs->trans('Product'), 'product'); - } - - if (!empty($lines[$i]->label)) { - $text .= ' '.$lines[$i]->label.''; - print $form->textwithtooltip($text, $lines[$i]->description, 3, '', '', $i); - } else { - print $text.' '.nl2br($lines[$i]->description); - } - - print_date_range($lines[$i]->date_start, $lines[$i]->date_end); - print "'; + + // Show product and description + $product_static->type = $lines[$i]->fk_product_type; + $product_static->id = $lines[$i]->fk_product; + $product_static->ref = $lines[$i]->ref; + $product_static->status = $lines[$i]->product_tosell; + $product_static->status_buy = $lines[$i]->product_tobuy; + $product_static->status_batch = $lines[$i]->product_tobatch; + + $product_static->weight = $lines[$i]->weight; + $product_static->weight_units = $lines[$i]->weight_units; + $product_static->length = $lines[$i]->length; + $product_static->length_units = $lines[$i]->length_units; + $product_static->width = !empty($lines[$i]->width) ? $lines[$i]->width : 0; + $product_static->width_units = !empty($lines[$i]->width_units) ? $lines[$i]->width_units : 0; + $product_static->height = !empty($lines[$i]->height) ? $lines[$i]->height : 0; + $product_static->height_units = !empty($lines[$i]->height_units) ? $lines[$i]->height_units : 0; + $product_static->surface = $lines[$i]->surface; + $product_static->surface_units = $lines[$i]->surface_units; + $product_static->volume = $lines[$i]->volume; + $product_static->volume_units = $lines[$i]->volume_units; + + $text = $product_static->getNomUrl(1); + $text .= ' - '.$label; + $description = (getDolGlobalInt('PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE') ? '' : dol_htmlentitiesbr($lines[$i]->description)); + print $form->textwithtooltip($text, $description, 3, '', '', $i); + print_date_range(!empty($lines[$i]->date_start) ? $lines[$i]->date_start : '', !empty($lines[$i]->date_end) ? $lines[$i]->date_end : ''); + if (getDolGlobalInt('PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE')) { + print (!empty($lines[$i]->description) && $lines[$i]->description != $lines[$i]->product) ? '
'.dol_htmlentitiesbr($lines[$i]->description) : ''; + } + print "
'; + if ($lines[$i]->product_type == Product::TYPE_SERVICE) { + $text = img_object($langs->trans('Service'), 'service'); + } else { + $text = img_object($langs->trans('Product'), 'product'); } - // Qty ordered - print ''.$lines[$i]->qty_asked.' '.$unit_order.''; - foreach ($alreadysent as $key => $val) { - if ($lines[$i]->fk_origin_line == $key) { - $j = 0; - foreach ($val as $shipmentline_id => $shipmentline_var) { - if ($shipmentline_var['shipment_id'] == $lines[$i]->fk_expedition) { - continue; // We want to show only "other shipments" - } + print_date_range($lines[$i]->date_start, $lines[$i]->date_end); + print "'.$lines[$i]->qty_asked.' '.$unit_order.''; + foreach ($alreadysent as $key => $val) { + if ($lines[$i]->fk_origin_line == $key) { + $j = 0; + foreach ($val as $shipmentline_id => $shipmentline_var) { + if ($shipmentline_var['shipment_id'] == $lines[$i]->fk_expedition) { + continue; // We want to show only "other shipments" } + + $j++; + if ($j > 1) { + print '
'; + } + $shipment_static->fetch($shipmentline_var['shipment_id']); + print $shipment_static->getNomUrl(1); + print ' - '.$shipmentline_var['qty_shipped']; + $htmltext = $langs->trans("DateValidation").' : '.(empty($shipmentline_var['date_valid']) ? $langs->trans("Draft") : dol_print_date($shipmentline_var['date_valid'], 'dayhour')); + if (isModEnabled('stock') && $shipmentline_var['warehouse'] > 0) { + $warehousestatic->fetch($shipmentline_var['warehouse']); + $htmltext .= '
'.$langs->trans("FromLocation").' : '.$warehousestatic->getNomUrl(1, '', 0, 1); + } + print ' '.$form->textwithpicto('', $htmltext, 1); } } - print '
'; - if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0) { - print ''; - $line = new ExpeditionLigne($db); - foreach ($lines[$i]->detail_batch as $detail_batch) { - print ''; - // Qty to ship or shipped - print ''; - // Batch number managment - if ($lines[$i]->entrepot_id == 0) { - // only show lot numbers from src warehouse when shipping from multiple warehouses - $line->fetch($detail_batch->fk_expeditiondet); - } - $entrepot_id = !empty($detail_batch->entrepot_id)?$detail_batch->entrepot_id:$lines[$i]->entrepot_id; - print ''; - print ''; - } - // add a 0 qty lot row to be able to add a lot + if ($action == 'editline' && $lines[$i]->id == $line_id) { + // edit mode + print ''; - } else { + } elseif (!isModEnabled('stock') && empty($conf->productbatch->enabled)) { // both product batch and stock are not activated. + print ''; + print ''; // Qty to ship or shipped - print ''; - + print ''; // Warehouse source - if (isModEnabled('stock')) { - print ''; + // Batch number managment + print ''; + print ''; + } + + print '
'.$formproduct->selectLotStock($detail_batch->fk_origin_stock, 'batchl'.$detail_batch->fk_expeditiondet.'_'.$detail_batch->fk_origin_stock, '', 1, 0, $lines[$i]->fk_product, $entrepot_id).'
'; + if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0) { + print ''; + $line = new ExpeditionLigne($db); + foreach ($lines[$i]->detail_batch as $detail_batch) { print ''; // Qty to ship or shipped - print ''; + print ''; // Batch number managment - print ''; + if ($lines[$i]->entrepot_id == 0) { + // only show lot numbers from src warehouse when shipping from multiple warehouses + $line->fetch($detail_batch->fk_expeditiondet); + } + $entrepot_id = !empty($detail_batch->entrepot_id)?$detail_batch->entrepot_id:$lines[$i]->entrepot_id; + print ''; print ''; - } elseif (isModEnabled('stock')) { - if ($lines[$i]->fk_product > 0) { - if ($lines[$i]->entrepot_id > 0) { - print ''; - print ''; - // Qty to ship or shipped - print ''; - // Warehouse source - print ''; - // Batch number managment - print ''; - print ''; - } elseif (count($lines[$i]->details_entrepot) > 1) { - print ''; - foreach ($lines[$i]->details_entrepot as $detail_entrepot) { - print ''; - // Qty to ship or shipped - print ''; - // Warehouse source - print ''; - // Batch number managment - print ''; - print ''; - } - } else { - print ''; - print ''; - } - } else { - print ''; + } + // add a 0 qty lot row to be able to add a lot + print ''; + // Qty to ship or shipped + print ''; + // Batch number managment + print ''; + print ''; + } elseif (isModEnabled('stock')) { + if ($lines[$i]->fk_product > 0) { + if ($lines[$i]->entrepot_id > 0) { + print ''; print ''; // Qty to ship or shipped print ''; // Warehouse source - print ''; + print ''; // Batch number managment - print ''; + print ''; print ''; + } elseif (count($lines[$i]->details_entrepot) > 1) { + print ''; + foreach ($lines[$i]->details_entrepot as $detail_entrepot) { + print ''; + // Qty to ship or shipped + print ''; + // Warehouse source + print ''; + // Batch number managment + print ''; + print ''; + } + } else { + print ''; + print ''; } - } elseif (!isModEnabled('stock') && empty($conf->productbatch->enabled)) { // both product batch and stock are not activated. - print ''; + } else { + print ''; print ''; // Qty to ship or shipped - print ''; + print ''; // Warehouse source print ''; // Batch number managment print ''; print ''; } - - print '
'.$formproduct->selectLotStock('', 'batchl'.$line_id.'_0', '', 1, 0, $lines[$i]->fk_product).''.$formproduct->selectLotStock($detail_batch->fk_origin_stock, 'batchl'.$detail_batch->fk_expeditiondet.'_'.$detail_batch->fk_origin_stock, '', 1, 0, $lines[$i]->fk_product, $entrepot_id).'
'.$unit_order.''.$formproduct->selectWarehouses($lines[$i]->entrepot_id, 'entl'.$line_id, '', 1, 0, $lines[$i]->fk_product, '', 1).' - '.$langs->trans("NA").'
'.$unit_order.''.$formproduct->selectWarehouses($detail_entrepot->entrepot_id, 'entl'.$detail_entrepot->line_id, '', 1, 0, $lines[$i]->fk_product, '', 1).' - '.$langs->trans("NA").'
'.$langs->trans("NotEnoughStock").'
'.$formproduct->selectLotStock('', 'batchl'.$line_id.'_0', '', 1, 0, $lines[$i]->fk_product).'
'.$unit_order.''.$formproduct->selectWarehouses($lines[$i]->entrepot_id, 'entl'.$line_id, '', 1, 0, $lines[$i]->fk_product, '', 1).' - '.$langs->trans("NA").'
'.$unit_order.''.$formproduct->selectWarehouses($detail_entrepot->entrepot_id, 'entl'.$detail_entrepot->line_id, '', 1, 0, $lines[$i]->fk_product, '', 1).' - '.$langs->trans("NA").'
'.$langs->trans("NotEnoughStock").'
'.$unit_order.'
'.$lines[$i]->qty_shipped.' '.$unit_order.''; - if ($lines[$i]->entrepot_id > 0) { - $entrepot = new Entrepot($db); - $entrepot->fetch($lines[$i]->entrepot_id); - print $entrepot->getNomUrl(1); - } elseif (count($lines[$i]->details_entrepot) > 1) { - $detail = ''; - foreach ($lines[$i]->details_entrepot as $detail_entrepot) { - if ($detail_entrepot->entrepot_id > 0) { - $entrepot = new Entrepot($db); - $entrepot->fetch($detail_entrepot->entrepot_id); - $detail .= $langs->trans("DetailWarehouseFormat", $entrepot->libelle, $detail_entrepot->qty_shipped).'
'; - } + print '
'.$lines[$i]->qty_shipped.' '.$unit_order.''; + if ($lines[$i]->entrepot_id > 0) { + $entrepot = new Entrepot($db); + $entrepot->fetch($lines[$i]->entrepot_id); + print $entrepot->getNomUrl(1); + } elseif (count($lines[$i]->details_entrepot) > 1) { + $detail = ''; + foreach ($lines[$i]->details_entrepot as $detail_entrepot) { + if ($detail_entrepot->entrepot_id > 0) { + $entrepot = new Entrepot($db); + $entrepot->fetch($detail_entrepot->entrepot_id); + $detail .= $langs->trans("DetailWarehouseFormat", $entrepot->libelle, $detail_entrepot->qty_shipped).'
'; } - print $form->textwithtooltip(img_picto('', 'object_stock').' '.$langs->trans("DetailWarehouseNumber"), $detail); + } + print $form->textwithtooltip(img_picto('', 'object_stock').' '.$langs->trans("DetailWarehouseNumber"), $detail); + } + print '
'; + if ($lines[$i]->product_tobatch) { + $detail = ''; + foreach ($lines[$i]->detail_batch as $dbatch) { // $dbatch is instance of ExpeditionLineBatch + $detail .= $langs->trans("Batch").': '.$dbatch->batch; + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + $detail .= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby, "day"); + } + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + $detail .= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby, "day"); + } + $detail .= ' - '.$langs->trans("Qty").': '.$dbatch->qty; + $detail .= '
'; + } + print $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"), $detail); + } else { + print $langs->trans("NA"); } print '
'; - if ($lines[$i]->product_tobatch) { - $detail = ''; - foreach ($lines[$i]->detail_batch as $dbatch) { // $dbatch is instance of ExpeditionLineBatch - $detail .= $langs->trans("Batch").': '.$dbatch->batch; - if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { - $detail .= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby, "day"); - } - if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { - $detail .= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby, "day"); - } - $detail .= ' - '.$langs->trans("Qty").': '.$dbatch->qty; - $detail .= '
'; - } - print $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"), $detail); - } else { - print $langs->trans("NA"); - } - print '
'; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) { - print $lines[$i]->weight * $lines[$i]->qty_shipped.' '.measuringUnitString(0, "weight", $lines[$i]->weight_units); - } else { - print ' '; - } - print ''; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) { - print $lines[$i]->volume * $lines[$i]->qty_shipped.' '.measuringUnitString(0, "volume", $lines[$i]->volume_units); - } else { - print ' '; - } - print ''.$lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuringUnitString(0, "volume", $lines[$i]->volume_units).''; - print '
'; - print '
'; - print '
'; - print 'id.'">'.img_edit().''; - print ''; - print 'id.'">'.img_delete().''; - print '
'; + if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) { + print $lines[$i]->weight * $lines[$i]->qty_shipped.' '.measuringUnitString(0, "weight", $lines[$i]->weight_units); + } else { + print ' '; + } + print ''; + if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) { + print $lines[$i]->volume * $lines[$i]->qty_shipped.' '.measuringUnitString(0, "volume", $lines[$i]->volume_units); + } else { + print ' '; + } + print ''.$lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuringUnitString(0, "volume", $lines[$i]->volume_units).''; + print '
'; + print '
'; + print '
'; + print 'id.'">'.img_edit().''; + print ''; + print 'id.'">'.img_delete().''; + print '
\n"; - print ''; - print '
'; } + // TODO Show also lines ordered but not delivered + + print "\n"; + print ''; + print ''; + print dol_get_fiche_end(); diff --git a/htdocs/expedition/class/api_shipments.class.php b/htdocs/expedition/class/api_shipments.class.php index 357683ef35a..450fe943d7e 100644 --- a/htdocs/expedition/class/api_shipments.class.php +++ b/htdocs/expedition/class/api_shipments.class.php @@ -686,6 +686,11 @@ class Shipments extends DolibarrApi if (!empty($object->lines) && is_array($object->lines)) { foreach ($object->lines as $line) { + if (is_array($line->detail_batch)) { + foreach ($line->detail_batch as $keytmp2 => $valtmp2) { + unset($line->detail_batch[$keytmp2]->db); + } + } unset($line->tva_tx); unset($line->vat_src_code); unset($line->total_ht); diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index bb2954daa60..dd6dfee55b1 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1911,23 +1911,6 @@ class Expedition extends CommonObject dol_syslog(get_class($this)."::initAsSpecimen"); - // Load array of products prodids - $num_prods = 0; - $prodids = array(); - $sql = "SELECT rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."product"; - $sql .= " WHERE entity IN (".getEntity('product').")"; - $resql = $this->db->query($sql); - if ($resql) { - $num_prods = $this->db->num_rows($resql); - $i = 0; - while ($i < $num_prods) { - $i++; - $row = $this->db->fetch_row($resql); - $prodids[$i] = $row[0]; - } - } - $order = new Commande($this->db); $order->initAsSpecimen(); @@ -1940,7 +1923,7 @@ class Expedition extends CommonObject $this->date = $now; $this->date_creation = $now; $this->date_valid = $now; - $this->date_delivery = $now; + $this->date_delivery = $now + 24 * 3600; $this->date_expedition = $now + 24 * 3600; $this->entrepot_id = 0; diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 0d73dbd3438..26cafe14b5d 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -794,8 +794,8 @@ if (!empty($arrayfields['e.tms']['checked'])) { } // Status if (!empty($arrayfields['e.fk_statut']['checked'])) { - print ''; - print $form->selectarray('search_status', array('0'=>$langs->trans('StatusSendingDraftShort'), '1'=>$langs->trans('StatusSendingValidatedShort'), '2'=>$langs->trans('StatusSendingProcessedShort')), $search_status, 1, 0, 0, '', 0, 0, 0, '', 'onrightofpage'); + print ''; + print $form->selectarray('search_status', array('0'=>$langs->trans('StatusSendingDraftShort'), '1'=>$langs->trans('StatusSendingValidatedShort'), '2'=>$langs->trans('StatusSendingProcessedShort')), $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage'); print ''; } // Status billed diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 9394269a03a..2adf16e4c35 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -329,7 +329,7 @@ if ($id > 0 || !empty($ref)) { $filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')"; } - print ''.$langs->trans('Discounts').''; + print ''.$langs->trans('Discounts').''; $absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount); $absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote); @@ -393,7 +393,7 @@ if ($id > 0 || !empty($ref)) { print 'id.'">'.img_edit($langs->trans('SetAvailability'), 1).''; } print ''; - print ''; + print ''; if ($action == 'editavailability') { $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id, $object->availability_id, 'availability_id', 1); } else { @@ -450,7 +450,7 @@ if ($id > 0 || !empty($ref)) { print 'id.'">'.img_edit($langs->trans('SetDemandReason'), 1).''; } print ''; - print ''; + print ''; if ($action == 'editdemandreason') { $form->formInputReason($_SERVER['PHP_SELF'].'?id='.$object->id, $object->demand_reason_id, 'demand_reason_id', 1); } else { @@ -500,11 +500,11 @@ if ($id > 0 || !empty($ref)) { $totalVolume = $tmparray['volume']; if ($totalWeight || $totalVolume) { print ''.$langs->trans("CalculatedWeight").''; - print ''; + print ''; print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); print ''; print ''.$langs->trans("CalculatedVolume").''; - print ''; + print ''; print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); print ''; } @@ -524,7 +524,7 @@ if ($id > 0 || !empty($ref)) { } print ''; print ''; - print ''; + print ''; if ($action != 'editincoterm') { print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); } else { diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index a14f5b75be9..75c5b02de10 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -295,7 +295,7 @@ if (empty($reshook)) { } if (!$error && empty($conf->global->EXPENSEREPORT_ALLOW_OVERLAPPING_PERIODS)) { - $overlappingExpenseReportID = $object->periode_existe($fuser, $object->date_debut, $object->date_fin, true); + $overlappingExpenseReportID = $object->periode_existe($fuser, $object->date_debut, $object->date_fin); if ($overlappingExpenseReportID > 0) { $error++; diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 80fcefc7b68..63cbeaad67b 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -985,6 +985,8 @@ class ExpenseReport extends CommonObject return -1; } } + + return 0; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -1328,8 +1330,6 @@ class ExpenseReport extends CommonObject public function set_save_from_refuse($fuser) { // phpcs:enable - global $conf, $langs; - // Sélection de la date de début de la NDF $sql = 'SELECT date_debut'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element; @@ -1357,6 +1357,8 @@ class ExpenseReport extends CommonObject } else { dol_syslog(get_class($this)."::set_save_from_refuse expensereport already with save status", LOG_WARNING); } + + return 0; } /** @@ -1465,6 +1467,8 @@ class ExpenseReport extends CommonObject } else { dol_syslog(get_class($this)."::setDeny expensereport already with refuse status", LOG_WARNING); } + + return 0; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -1531,6 +1535,8 @@ class ExpenseReport extends CommonObject } else { dol_syslog(get_class($this)."::set_unpaid expensereport already with unpaid status", LOG_WARNING); } + + return 0; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -1734,9 +1740,9 @@ class ExpenseReport extends CommonObject /** * Update total of an expense report when you add a line. * - * @param string $ligne_total_ht Amount without taxes + * @param string $ligne_total_ht Amount without taxes * @param string $ligne_total_tva Amount of all taxes - * @return void + * @return int */ public function update_totaux_add($ligne_total_ht, $ligne_total_tva) { @@ -1885,7 +1891,7 @@ class ExpenseReport extends CommonObject * * @param int $type Type of line * @param string $seller Seller, but actually he is unknown - * @return true or false + * @return boolean true or false */ public function checkRules($type = 0, $seller = '') { diff --git a/htdocs/expensereport/payment/card.php b/htdocs/expensereport/payment/card.php index db6c21e202f..bdc7b51312a 100644 --- a/htdocs/expensereport/payment/card.php +++ b/htdocs/expensereport/payment/card.php @@ -209,7 +209,7 @@ if ($resql) { print ''.price($objp->total_ttc - $objp->amount).''; // Status - print ''.$expensereport->getLibStatut(4, $objp->amount).''; + print ''.$expensereport->getLibStatut(4).''; print "\n"; diff --git a/htdocs/expensereport/payment/info.php b/htdocs/expensereport/payment/info.php index b5d87b81a51..c1e00ffa0fb 100644 --- a/htdocs/expensereport/payment/info.php +++ b/htdocs/expensereport/payment/info.php @@ -52,7 +52,7 @@ $confirm = GETPOST('confirm', 'alpha'); llxHeader('', $langs->trans("Payment")); $object = new PaymentExpenseReport($db); -$object->fetch($id, $ref); +$object->fetch($id); $object->info($object->id); $head = payment_expensereport_prepare_head($object); diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index 4591ccd0bf3..f35ae3a3121 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -1187,7 +1187,7 @@ if ($step == 5 && $datatoexport) { $htmltabloflibs .= ''.$langs->trans("LibraryVersion").''; $htmltabloflibs .= ''."\n"; - $liste = $objmodelexport->liste_modeles($db); + $liste = $objmodelexport->listOfAvailableExportFormat($db); $listeall = $liste; foreach ($listeall as $key => $val) { if (preg_match('/__\(Disabled\)__/', $listeall[$key])) { diff --git a/htdocs/exports/index.php b/htdocs/exports/index.php index 41d6cd18ed0..6039a9c447a 100644 --- a/htdocs/exports/index.php +++ b/htdocs/exports/index.php @@ -72,7 +72,7 @@ print ''; include_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php'; $model = new ModeleExports($db); -$liste = $model->liste_modeles($db); // This is not a static method for exports because method load non static properties +$liste = $model->listOfAvailableExportFormat($db); // This is not a static method for exports because method load non static properties foreach ($liste as $key => $val) { if (preg_match('/__\(Disabled\)__/', $liste[$key])) { diff --git a/htdocs/fichinter/card-rec.php b/htdocs/fichinter/card-rec.php index f2bd0bac8a3..22f77546090 100644 --- a/htdocs/fichinter/card-rec.php +++ b/htdocs/fichinter/card-rec.php @@ -234,7 +234,7 @@ if ($action == 'add') { } elseif ($action == 'delete' && $user->rights->ficheinter->supprimer) { // delete modele $object->fetch($id); - $object->delete(); + $object->delete($user); $id = 0; header('Location: '.$_SERVER["PHP_SELF"]); exit; diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 25fc0996ca0..01533698b1c 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -38,7 +38,7 @@ class Fichinter extends CommonObject { public $fields = array( 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), - 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'$conf->societe->enabled', 'visible'=>-1, 'notnull'=>1, 'position'=>15), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'isModEnabled("societe")', 'visible'=>-1, 'notnull'=>1, 'position'=>15), 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Fk projet', 'enabled'=>'isModEnabled("project")', 'visible'=>-1, 'position'=>20), 'fk_contrat' =>array('type'=>'integer', 'label'=>'Fk contrat', 'enabled'=>'$conf->contrat->enabled', 'visible'=>-1, 'position'=>25), 'ref' =>array('type'=>'varchar(30)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>30), @@ -501,6 +501,8 @@ class Fichinter extends CommonObject $this->db->free($resql); return 1; } + + return 0; } else { $this->error = $this->db->lasterror(); return -1; @@ -515,8 +517,6 @@ class Fichinter extends CommonObject */ public function setDraft($user) { - global $langs, $conf; - $error = 0; // Protection @@ -664,6 +664,8 @@ class Fichinter extends CommonObject return -1; } } + + return 0; } /** @@ -747,25 +749,25 @@ class Fichinter extends CommonObject { // phpcs:enable // Init/load array of translation of status - if (empty($this->statuts) || empty($this->statuts_short) || empty($this->statuts_logo)) { + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; $langs->load("fichinter"); - $this->statuts[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); - $this->statuts[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated'); - $this->statuts[self::STATUS_BILLED] = $langs->transnoentitiesnoconv('StatusInterInvoiced'); - $this->statuts[self::STATUS_CLOSED] = $langs->transnoentitiesnoconv('Done'); - $this->statuts_short[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); - $this->statuts_short[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated'); - $this->statuts_short[self::STATUS_BILLED] = $langs->transnoentitiesnoconv('StatusInterInvoiced'); - $this->statuts_short[self::STATUS_CLOSED] = $langs->transnoentitiesnoconv('Done'); - $this->statuts_logo[self::STATUS_DRAFT] = 'status0'; - $this->statuts_logo[self::STATUS_VALIDATED] = 'status1'; - $this->statuts_logo[self::STATUS_BILLED] = 'status6'; - $this->statuts_logo[self::STATUS_CLOSED] = 'status6'; + $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); + $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated'); + $this->labelStatus[self::STATUS_BILLED] = $langs->transnoentitiesnoconv('StatusInterInvoiced'); + $this->labelStatus[self::STATUS_CLOSED] = $langs->transnoentitiesnoconv('Done'); + $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); + $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated'); + $this->labelStatusShort[self::STATUS_BILLED] = $langs->transnoentitiesnoconv('StatusInterInvoiced'); + $this->labelStatusShort[self::STATUS_CLOSED] = $langs->transnoentitiesnoconv('Done'); } - return dolGetStatus($this->statuts[$status], $this->statuts_short[$status], '', $this->statuts_logo[$status], $mode); + $statuscode = 'status'.$status; + if ($status == self::STATUS_BILLED || $status == self::STATUS_CLOSED) { + $statuscode = 'status6'; + } + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statuscode, $mode); } /** @@ -904,8 +906,6 @@ class Fichinter extends CommonObject */ public function info($id) { - global $conf; - $sql = "SELECT f.rowid,"; $sql .= " f.datec,"; $sql .= " f.tms as date_modification,"; @@ -955,7 +955,7 @@ class Fichinter extends CommonObject * @param int $notrigger Disable trigger * @return int <0 if KO, >0 if OK */ - public function delete($user, $notrigger = 0) + public function delete(User $user, $notrigger = 0) { global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -1074,13 +1074,11 @@ class Fichinter extends CommonObject * * @param User $user Object user who define * @param integer $date_delivery date of delivery - * @return int <0 if ko, >0 if ok + * @return int <0 if KO, >0 if OK */ public function set_date_delivery($user, $date_delivery) { // phpcs:enable - global $conf; - if ($user->rights->ficheinter->creer) { $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter "; $sql .= " SET datei = '".$this->db->idate($date_delivery)."'"; @@ -1096,6 +1094,8 @@ class Fichinter extends CommonObject return -1; } } + + return 0; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -1109,8 +1109,6 @@ class Fichinter extends CommonObject public function set_description($user, $description) { // phpcs:enable - global $conf; - if ($user->rights->ficheinter->creer) { $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter "; $sql .= " SET description = '".$this->db->escape($description)."',"; @@ -1126,6 +1124,8 @@ class Fichinter extends CommonObject return -1; } } + + return 0; } @@ -1135,13 +1135,11 @@ class Fichinter extends CommonObject * * @param User $user Object user who modify * @param int $contractid Description - * @return int <0 if ko, >0 if ok + * @return int <0 if KO, >0 if OK */ public function set_contrat($user, $contractid) { // phpcs:enable - global $conf; - if ($user->rights->ficheinter->creer) { $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter "; $sql .= " SET fk_contrat = ".((int) $contractid); @@ -1155,6 +1153,7 @@ class Fichinter extends CommonObject return -1; } } + return -2; } @@ -1261,7 +1260,7 @@ class Fichinter extends CommonObject { dol_syslog(get_class($this)."::addline $fichinterid, $desc, $date_intervention, $duration"); - if ($this->statut == 0) { + if ($this->statut == self::STATUS_DRAFT) { $this->db->begin(); // Insertion ligne @@ -1288,6 +1287,8 @@ class Fichinter extends CommonObject return -1; } } + + return 0; } @@ -1300,7 +1301,7 @@ class Fichinter extends CommonObject */ public function initAsSpecimen() { - global $user, $langs, $conf; + global $langs; $now = dol_now(); @@ -1453,6 +1454,38 @@ class Fichinter extends CommonObject return -1; } } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + global $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + //$return .= ''; // Can be image + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + if (property_exists($this, 'socid')) { + $return .= '
'.$this->socid.''; + } + if (property_exists($this, 'duration')) { + $return .= '
'.$langs->trans("Duration").' : '.convertSecondToTime($this->duration, 'allhourmin').''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } /** diff --git a/htdocs/fichinter/class/fichinterrec.class.php b/htdocs/fichinter/class/fichinterrec.class.php index fa3b700b1fd..44dd63abcd2 100644 --- a/htdocs/fichinter/class/fichinterrec.class.php +++ b/htdocs/fichinter/class/fichinterrec.class.php @@ -150,7 +150,7 @@ class FichinterRec extends Fichinter $fichintsrc = new Fichinter($this->db); $result = $fichintsrc->fetch($this->id_origin); - $result = $fichintsrc->fetch_lines(1); // to get all lines + $result = $fichintsrc->fetch_lines(); // to get all lines if ($result > 0) { @@ -411,16 +411,13 @@ class FichinterRec extends Fichinter /** * Delete template fichinter rec * - * @param int $rowid Id of fichinter rec to delete. If empty, we delete current instance of fichinter rec - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @param int $idwarehouse Id warehouse to use for stock change. + * @param User $user Object user who delete + * @param int $notrigger Disable trigger * @return int <0 if KO, >0 if OK */ - public function delete($rowid = 0, $notrigger = 0, $idwarehouse = -1) + public function delete(User $user, $notrigger = 0) { - if (empty($rowid)) { - $rowid = $this->id; - } + $rowid = $this->id; dol_syslog(get_class($this)."::delete rowid=".$rowid, LOG_DEBUG); @@ -664,18 +661,15 @@ class FichinterRec extends Fichinter * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @param string $option ''=Create a specimen fichinter with lines, 'nolines'=No lines * @return void */ - public function initAsSpecimen($option = '') + public function initAsSpecimen() { - global $user, $langs, $conf; + //$now = dol_now(); + //$arraynow = dol_getdate($now); + //$nownotime = dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']); - $now = dol_now(); - $arraynow = dol_getdate($now); - $nownotime = dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']); - - parent::initAsSpecimen($option); + parent::initAsSpecimen(); $this->usenewprice = 1; } diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index d43b4166f1d..705dac46e50 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -57,6 +57,7 @@ $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'interventionlist'; +$mode = GETPOST('mode', 'alpha'); $search_ref = GETPOST('search_ref') ?GETPOST('search_ref', 'alpha') : GETPOST('search_inter', 'alpha'); $search_ref_client = GETPOST('search_ref_client', 'alpha'); @@ -460,7 +461,10 @@ $url = DOL_URL_ROOT.'/fichinter/card.php?action=create'; if (!empty($socid)) { $url .= '&socid='.$socid; } -$newcardbutton = dolGetButtonTitle($langs->trans('NewIntervention'), '', 'fa fa-plus-circle', $url, '', $user->rights->ficheinter->creer); +$newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('NewIntervention'), '', 'fa fa-plus-circle', $url, '', $user->rights->ficheinter->creer); print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -569,13 +573,13 @@ if (!empty($arrayfields['f.note_private']['checked'])) { } // Status if (!empty($arrayfields['f.fk_statut']['checked'])) { - print ''; + print ''; $tmp = $objectstatic->LibStatut(0); // To load $this->statuts_short $liststatus = $objectstatic->statuts_short; if (empty($conf->global->FICHINTER_CLASSIFY_BILLED)) { unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1 } - print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 1, 0, 0, '', 'onrightofpage'); + print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 1, 0, 0, '', 'search_status width100 onrightofpage'); print ''; } // Fields of detail line @@ -695,200 +699,219 @@ while ($i < $imaxinloop) { $companystatic->email = $obj->email; $companystatic->status = $obj->thirdpartystatus; - print ''; - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; - } - print ''; + //mode kanban + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + print '
'; } - print ''; - } - if (!empty($arrayfields['f.ref']['checked'])) { - print ""; - print ''; - // Picto + Ref - print ''; - // Warning - $warnornote = ''; - //if ($obj->fk_statut == 1 && $db->jdate($obj->dfv) < ($now - $conf->fichinter->warning_delay)) $warnornote.=img_warning($langs->trans("Late")); - if (!empty($obj->note_private)) { - $warnornote .= ($warnornote ? ' ' : ''); - $warnornote .= ''; - $warnornote .= ''.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').''; - $warnornote .= ''; + // Output Kanban + $objectstatic->duration = $obj->duree; + $objectstatic->socid = $companystatic->getNomUrl(1, '', 44); + + + print $objectstatic->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print ''; + print ''; } - if ($warnornote) { - print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; } + if (!empty($arrayfields['f.ref']['checked'])) { + print "
'; - print $objectstatic->getNomUrl(1); - print '
'; - print $warnornote; + } else { + print '
'; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } print '"; - // Other picto tool - print ''; - $filename = dol_sanitizeFileName($obj->ref); - $filedir = $conf->ficheinter->dir_output.'/'.dol_sanitizeFileName($obj->ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; - print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); - print '
'; + print ''; + // Picto + Ref + print ''; + // Warning + $warnornote = ''; + //if ($obj->fk_statut == 1 && $db->jdate($obj->dfv) < ($now - $conf->fichinter->warning_delay)) $warnornote.=img_warning($langs->trans("Late")); + if (!empty($obj->note_private)) { + $warnornote .= ($warnornote ? ' ' : ''); + $warnornote .= ''; + $warnornote .= ''.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').''; + $warnornote .= ''; + } + if ($warnornote) { + print ''; + } - print "\n"; - if (!$i) { - $totalarray['nbfield']++; + // Other picto tool + print '
'; + print $objectstatic->getNomUrl(1); + print ''; + print $warnornote; + print ''; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->ficheinter->dir_output.'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; + print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + print '
'; + + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } } - } - if (!empty($arrayfields['f.ref_client']['checked'])) { - // Customer ref - print ''; - print dol_escape_htmltag($obj->ref_client); - print ''; - if (!$i) { - $totalarray['nbfield']++; + if (!empty($arrayfields['f.ref_client']['checked'])) { + // Customer ref + print ''; + print dol_escape_htmltag($obj->ref_client); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - if (!empty($arrayfields['s.nom']['checked'])) { - print ''; - print $companystatic->getNomUrl(1, '', 44); - print ''; - if (!$i) { - $totalarray['nbfield']++; + if (!empty($arrayfields['s.nom']['checked'])) { + print ''; + print $companystatic->getNomUrl(1, '', 44); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - if (!empty($arrayfields['pr.ref']['checked'])) { - print ''; - $projetstatic->id = $obj->projet_id; - $projetstatic->ref = $obj->projet_ref; - $projetstatic->title = $obj->projet_title; - if ($projetstatic->id > 0) { - print $projetstatic->getNomUrl(1, ''); + if (!empty($arrayfields['pr.ref']['checked'])) { + print ''; + $projetstatic->id = $obj->projet_id; + $projetstatic->ref = $obj->projet_ref; + $projetstatic->title = $obj->projet_title; + if ($projetstatic->id > 0) { + print $projetstatic->getNomUrl(1, ''); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - print ''; - if (!$i) { - $totalarray['nbfield']++; + if (!empty($arrayfields['c.ref']['checked'])) { + print ''; + $contratstatic->id = $obj->contrat_id; + $contratstatic->ref = $obj->contrat_ref; + $contratstatic->ref_customer = $obj->contrat_ref_customer; + $contratstatic->ref_supplier = $obj->contrat_ref_supplier; + if ($contratstatic->id > 0) { + print $contratstatic->getNomUrl(1, ''); + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } } - } - if (!empty($arrayfields['c.ref']['checked'])) { - print ''; - $contratstatic->id = $obj->contrat_id; - $contratstatic->ref = $obj->contrat_ref; - $contratstatic->ref_customer = $obj->contrat_ref_customer; - $contratstatic->ref_supplier = $obj->contrat_ref_supplier; - if ($contratstatic->id > 0) { - print $contratstatic->getNomUrl(1, ''); + if (!empty($arrayfields['f.description']['checked'])) { + print ''.dol_trunc(dolGetFirstLineOfText(dol_string_nohtmltag($obj->description, 1)), 48).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['f.datec']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date modification + if (!empty($arrayfields['f.tms']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Note public + if (!empty($arrayfields['f.note_public']['checked'])) { + print ''; + print dol_string_nohtmltag($obj->note_public); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Note private + if (!empty($arrayfields['f.note_private']['checked'])) { + print ''; + print dol_string_nohtmltag($obj->note_private); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Status + if (!empty($arrayfields['f.fk_statut']['checked'])) { + print ''.$objectstatic->getLibStatut(5).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Fields of detail of line + if (!empty($arrayfields['fd.description']['checked'])) { + print ''.dol_trunc(dolGetFirstLineOfText(dol_string_nohtmltag($obj->descriptiondetail, 1)), 48).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['fd.date']['checked'])) { + print ''.dol_print_date($db->jdate($obj->dp), 'dayhour')."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['fd.duree']['checked'])) { + print ''.convertSecondToTime($obj->duree, 'allhourmin').''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['type'][$totalarray['nbfield']] = 'duration'; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'fd.duree'; + } + $totalarray['val']['fd.duree'] += $obj->duree; + } + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } print ''; } if (!$i) { $totalarray['nbfield']++; } - } - if (!empty($arrayfields['f.description']['checked'])) { - print ''.dol_trunc(dolGetFirstLineOfText(dol_string_nohtmltag($obj->description, 1)), 48).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['f.datec']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['f.tms']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Note public - if (!empty($arrayfields['f.note_public']['checked'])) { - print ''; - print dol_string_nohtmltag($obj->note_public); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Note private - if (!empty($arrayfields['f.note_private']['checked'])) { - print ''; - print dol_string_nohtmltag($obj->note_private); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Status - if (!empty($arrayfields['f.fk_statut']['checked'])) { - print ''.$objectstatic->getLibStatut(5).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Fields of detail of line - if (!empty($arrayfields['fd.description']['checked'])) { - print ''.dol_trunc(dolGetFirstLineOfText(dol_string_nohtmltag($obj->descriptiondetail, 1)), 48).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['fd.date']['checked'])) { - print ''.dol_print_date($db->jdate($obj->dp), 'dayhour')."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['fd.duree']['checked'])) { - print ''.convertSecondToTime($obj->duree, 'allhourmin').''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['type'][$totalarray['nbfield']] = 'duration'; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'fd.duree'; - } - $totalarray['val']['fd.duree'] += $obj->duree; - } - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } + print ''."\n"; - print ''."\n"; - - $total += $obj->duree; + $total += $obj->duree; + } $i++; } diff --git a/htdocs/fourn/ajax/getSupplierPrices.php b/htdocs/fourn/ajax/getSupplierPrices.php index 29cf421059e..66001ccc5a6 100644 --- a/htdocs/fourn/ajax/getSupplierPrices.php +++ b/htdocs/fourn/ajax/getSupplierPrices.php @@ -88,7 +88,7 @@ if ($idprod > 0) { $label .= ' ('.$productSupplier->fourn_ref.')'; } - $prices[] = array("id" => $productSupplier->product_fourn_price_id, "price" => price2num($price, 0, '', 0), "label" => $label, "title" => $title); // For price field, we must use price2num(), for label or title, price() + $prices[] = array("id" => $productSupplier->product_fourn_price_id, "price" => price2num($price, '', 0), "label" => $label, "title" => $title); // For price field, we must use price2num(), for label or title, price() } } diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 90a760e14a1..19335656f51 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -98,7 +98,8 @@ if (empty($reshook)) { $action = ""; } - if ($action == 'setsupplieraccountancycode') { + // Set supplier accounting account + if ($action == 'setsupplieraccountancycode' && $user->hasRight('societe', 'creer')) { $result = $object->fetch($id); $object->code_compta_fournisseur = GETPOST("supplieraccountancycode"); $result = $object->update($object->id, $user, 1, 0, 1); @@ -106,8 +107,17 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); } } + // Set vat number accounting account + if ($action == 'settva_intra' && $user->hasRight('societe', 'creer')) { + $result = $object->fetch($id); + $object->tva_intra = GETPOST("tva_intra"); + $result = $object->update($object->id, $user, 1, 0, 0); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } // Set payment terms of the settlement - if ($action == 'setconditions' && $user->rights->societe->creer) { + if ($action == 'setconditions' && $user->hasRight('societe', 'creer')) { $object->fetch($id); $result = $object->setPaymentTerms(GETPOST('cond_reglement_supplier_id', 'int')); if ($result < 0) { @@ -115,7 +125,7 @@ if (empty($reshook)) { } } // Payment mode - if ($action == 'setmode' && $user->rights->societe->creer) { + if ($action == 'setmode' && $user->hasRight('societe', 'creer')) { $object->fetch($id); $result = $object->setPaymentMethods(GETPOST('mode_reglement_supplier_id', 'int')); if ($result < 0) { @@ -124,7 +134,7 @@ if (empty($reshook)) { } // Bank account - if ($action == 'setbankaccount' && $user->rights->societe->creer) { + if ($action == 'setbankaccount' && $user->hasRight('societe', 'creer')) { $object->fetch($id); $result = $object->setBankAccount(GETPOST('fk_account', 'int')); if ($result < 0) { @@ -133,7 +143,7 @@ if (empty($reshook)) { } // update supplier order min amount - if ($action == 'setsupplier_order_min_amount') { + if ($action == 'setsupplier_order_min_amount' && $user->hasRight('societe', 'creer')) { $object->fetch($id); $object->supplier_order_min_amount = price2num(GETPOST('supplier_order_min_amount', 'alpha')); $result = $object->update($object->id, $user); @@ -142,7 +152,7 @@ if (empty($reshook)) { } } - if ($action == 'update_extras') { + if ($action == 'update_extras' && $user->hasRight('societe', 'creer')) { $object->fetch($id); $object->oldcopy = dol_clone($object); @@ -261,8 +271,12 @@ if ($object->id > 0) { } // TVA Intra - print ''.$langs->trans('VATIntra').''; - print showValueWithClipboardCPButton(dol_escape_htmltag($object->tva_intra)); + print ''; + //print $langs->trans('VATIntra').''; + $vattoshow = ($object->tva_intra ? showValueWithClipboardCPButton(dol_escape_htmltag($object->tva_intra)) : ''); + print $form->editfieldkey("VATIntra", 'tva_intra', $object->tva_intra, $object, $user->hasRight('societe', 'creer')); + print ''; + print $form->editfieldval("VATIntra", 'tva_intra', $vattoshow, $object, $user->hasRight('societe', 'creer'), 'string', $object->tva_intra, null, null, '', 1, '', 'id', 'auto', array('valuealreadyhtmlescaped'=>1)); print ''; // Default terms of the settlement diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 00ed65e7616..a08f2046790 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -254,7 +254,7 @@ class CommandeFournisseur extends CommonOrder 'multicurrency_total_tva' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyAmountVAT', 'enabled'=>'isModEnabled("multicurrency")', 'visible'=>-1, 'position'=>235), 'multicurrency_total_ttc' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyAmountTTC', 'enabled'=>'isModEnabled("multicurrency")', 'visible'=>-1, 'position'=>240), 'date_creation' =>array('type'=>'datetime', 'label'=>'Date creation', 'enabled'=>1, 'visible'=>-1, 'position'=>500), - 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'$conf->societe->enabled', 'visible'=>1, 'notnull'=>1, 'position'=>46), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'isModEnabled("societe")', 'visible'=>1, 'notnull'=>1, 'position'=>46), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>1000, 'index'=>1), 'tms'=>array('type'=>'datetime', 'label'=>"DateModificationShort", 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>501), 'last_main_doc' =>array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>1, 'visible'=>0, 'position'=>700), @@ -3544,6 +3544,38 @@ class CommandeFournisseur extends CommonOrder return -1; } } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + global $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + //$return .= ''; // Can be image + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + if (property_exists($this, 'socid') || property_exists($this, 'total_tva')) { + $return .='
'.$this->socid.''; + } + if (property_exists($this, 'billed')) { + $return .= '
'.$langs->trans("Billed").' : '.yn($this->billed).''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } @@ -3901,8 +3933,8 @@ class CommandeFournisseurLigne extends CommonOrderLine $sql .= ", vat_src_code = '".(empty($this->vat_src_code) ? '' : $this->vat_src_code)."'"; $sql .= ", tva_tx='".price2num($this->tva_tx)."'"; - $sql .= ", localtax1_tx='".price2num($this->total_localtax1)."'"; - $sql .= ", localtax2_tx='".price2num($this->total_localtax2)."'"; + $sql .= ", localtax1_tx='".price2num($this->localtax1_tx)."'"; + $sql .= ", localtax2_tx='".price2num($this->localtax2_tx)."'"; $sql .= ", localtax1_type='".$this->db->escape($this->localtax1_type)."'"; $sql .= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'"; $sql .= ", qty='".price2num($this->qty)."'"; diff --git a/htdocs/fourn/class/fournisseur.facture-rec.class.php b/htdocs/fourn/class/fournisseur.facture-rec.class.php index 1570f161582..8964213f83d 100644 --- a/htdocs/fourn/class/fournisseur.facture-rec.class.php +++ b/htdocs/fourn/class/fournisseur.facture-rec.class.php @@ -181,7 +181,7 @@ class FactureFournisseurRec extends CommonInvoice 'titre' =>array('type'=>'varchar(100)', 'label'=>'Titre', 'enabled'=>1, 'showoncombobox' => 1, 'visible'=>-1, 'position'=>15), 'ref_supplier' =>array('type'=>'varchar(180)', 'label'=>'RefSupplier', 'enabled'=>1, 'showoncombobox' => 1, 'visible'=>-1, 'position'=>20), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>25, 'index'=>1), - 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'$conf->societe->enabled', 'visible'=>-1, 'notnull'=>1, 'position'=>30), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'isModEnabled("societe")', 'visible'=>-1, 'notnull'=>1, 'position'=>30), 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>35), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>40), 'suspended' =>array('type'=>'integer', 'label'=>'Suspended', 'enabled'=>1, 'visible'=>-1, 'position'=>225), @@ -1331,7 +1331,7 @@ class FactureFournisseurRec extends CommonInvoice // We refresh the object in order to have all necessary data (like date_lim_reglement) $new_fac_fourn->fetch($new_fac_fourn->id); $result = $new_fac_fourn->generateDocument($facturerec->model_pdf, $langs); - if ($result <= 0) { + if ($result < 0) { $this->errors = $new_fac_fourn->errors; $this->error = $new_fac_fourn->error; $error++; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index de012c86a58..9ca933b7c43 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -275,7 +275,7 @@ class FactureFournisseur extends CommonInvoice 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>25, 'index'=>1), 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'RefExt', 'enabled'=>1, 'visible'=>0, 'position'=>30), 'type' =>array('type'=>'smallint(6)', 'label'=>'Type', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>35), - 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'$conf->societe->enabled', 'visible'=>-1, 'notnull'=>1, 'position'=>40), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'isModEnabled("societe")', 'visible'=>-1, 'notnull'=>1, 'position'=>40), 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>45), 'datef' =>array('type'=>'date', 'label'=>'Date', 'enabled'=>1, 'visible'=>-1, 'position'=>50), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>55), @@ -852,15 +852,18 @@ class FactureFournisseur extends CommonInvoice } /** - * Load object in memory from database + * Load object in memory from database * - * @param int $id Id supplier invoice - * @param string $ref Ref supplier invoice - * @return int <0 if KO, >0 if OK, 0 if not found + * @param int $id Id supplier invoice + * @param string $ref Ref supplier invoice + * @param string $ref_ext External reference of invoice + * @return int <0 if KO, >0 if OK, 0 if not found */ - public function fetch($id = '', $ref = '') + public function fetch($id = '', $ref = '', $ref_ext = '') { - global $langs; + if (empty($id) && empty($ref) && empty($ref_ext)) { + return -1; + } $sql = "SELECT"; $sql .= " t.rowid,"; @@ -911,10 +914,15 @@ class FactureFournisseur extends CommonInvoice $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON t.fk_mode_reglement = p.id"; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON t.fk_incoterms = i.rowid'; if ($id) { - $sql .= " WHERE t.rowid=".((int) $id); - } - if ($ref) { - $sql .= " WHERE t.ref='".$this->db->escape($ref)."' AND t.entity IN (".getEntity('supplier_invoice').")"; + $sql .= " WHERE t.rowid = ".((int) $id); + } else { + $sql .= ' WHERE t.entity IN ('.getEntity('supplier_invoice').')'; // Don't use entity if you use rowid + if ($ref) { + $sql .= " AND t.ref = '".$this->db->escape($ref)."'"; + } + if ($ref_ext) { + $sql .= " AND t.ref_ext = '".$this->db->escape($ref_ext)."'"; + } } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); @@ -1383,7 +1391,7 @@ class FactureFournisseur extends CommonInvoice $result = $this->update_price(1); if ($result > 0) { // Create link between discount and invoice line - $result = $remise->link_to_invoice($lineid, 0, 'supplier'); + $result = $remise->link_to_invoice($lineid, 0); if ($result < 0) { $this->error = $remise->error; $this->db->rollback(); @@ -3225,6 +3233,43 @@ class FactureFournisseur extends CommonInvoice return $isUsed; } + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + global $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + if (property_exists($this, 'socid')) { + $return .= ' | '.$this->socid.''; + } + if (property_exists($this, 'date_echeance') && property_exists($this, 'date')) { + if (!empty($this->date_echeance)) { + $return .= '
'.dol_print_date($this->date_echeance).''; + } else { + $return .= '
'.dol_print_date($this->date).''; + } + } + if (property_exists($this, 'total_ht')) { + $return .= '
'.$langs->trans("AmountHT").' : '.price($this->total_ht).''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index b627832ca3c..644469a257d 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -76,7 +76,6 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'purchaseordercard'; // To manage different context of search - $backtopage = GETPOST('backtopage', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); @@ -1696,16 +1695,16 @@ if ($action == 'create') { print img_picto('', 'company').$form->select_company((empty($socid) ? '' : $socid), 'socid', '(s.fournisseur=1 AND s.status=1)', 'SelectThirdParty', 1, 0, null, 0, 'minwidth175 maxwidth500 widthcentpercentminusxx'); // reload page to retrieve customer informations if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) { - print ''; + '; } print ' '; } @@ -2404,7 +2403,7 @@ if ($action == 'create') { // Show object lines if (!empty($object->lines)) { - $ret = $object->printObjectLines($action, $object->thirdparty, $mysoc, $lineid, 1); + $object->printObjectLines($action, $object->thirdparty, $mysoc, $lineid, 1); } $num = count($object->lines); diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 9e3a9ba7808..504336f0a6e 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -68,7 +68,7 @@ $hookmanager->initHooks(array('ordersupplierdispatch')); // Recuperation de l'id de projet $projectid = 0; -if ($_GET["projectid"]) { +if (GETPOSTISSET("projectid")) { $projectid = GETPOST("projectid", 'int'); } @@ -782,7 +782,8 @@ if ($id > 0 || !empty($ref)) { if (!$objp->fk_product > 0) { $nbfreeproduct++; } else { - $remaintodispatch = price2num($objp->qty - ((float) $products_dispatched[$objp->rowid]), 5); // Calculation of dispatched + $alreadydispatched = isset($products_dispatched[$objp->rowid])?$products_dispatched[$objp->rowid]:0; + $remaintodispatch = price2num($objp->qty - ((float) $alreadydispatched), 5); // Calculation of dispatched if ($remaintodispatch < 0 && empty($conf->global->SUPPLIER_ORDER_ALLOW_NEGATIVE_QTY_FOR_SUPPLIER_ORDER_RETURN)) { $remaintodispatch = 0; } @@ -799,7 +800,7 @@ if ($id > 0 || !empty($ref)) { print ''."\n"; // hidden fields for js function print ''; - print ''; + print ''; print ''; if (empty($conf->cache['product'][$objp->fk_product])) { @@ -860,7 +861,7 @@ if ($id > 0 || !empty($ref)) { print ''.$objp->qty.''; // Already dispatched - print ''.$products_dispatched[$objp->rowid].''; + print ''.$alreadydispatched.''; if (isModEnabled('productbatch') && $objp->tobatch > 0) { $type = 'batch'; diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 3d458247bcf..394660f3866 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -56,6 +56,7 @@ $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'supplierorderlist'; +$mode = GETPOST('mode', 'alpha'); // Search Criteria $search_date_order_startday = GETPOST('search_date_order_startday', 'int'); @@ -576,6 +577,9 @@ if (empty($reshook)) { // Make a redirect to avoid to bill twice if we make a refresh or back $param = ''; + if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); + } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -998,6 +1002,9 @@ if ($resql) { llxHeader('', $title, $help_url); $param = ''; + if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); + } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -1184,7 +1191,10 @@ if ($resql) { $url .= '&socid='.((int) $socid); $url .= '&backtopage='.urlencode(DOL_URL_ROOT.'/fourn/commande/list.php?socid='.((int) $socid)); } - $newcardbutton = dolGetButtonTitle($langs->trans('NewSupplierOrderShort'), '', 'fa fa-plus-circle', $url, '', $permissiontoadd); + $newcardbutton = ''; + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewSupplierOrderShort'), '', 'fa fa-plus-circle', $url, '', $permissiontoadd); // Lines of title fields print ''; @@ -1198,17 +1208,18 @@ if ($resql) { print ''; print ''; print ''; + print ''; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'supplier_order', 0, $newcardbutton, '', $limit, 0, 0, 1); $topicmail = "SendOrderRef"; $modelmail = "order_supplier_send"; - $objecttmp = new CommandeFournisseur($db); + $objecttmp = new CommandeFournisseur($db); // in case $object is not the good object $trackid = 'sord'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($massaction == 'prevalidate') { - print $form->formconfirm($_SERVER["PHP_SELF"].$fieldstosearchall, $langs->trans("ConfirmMassValidation"), $langs->trans("ConfirmMassValidationQuestion"), "validate", null, '', 0, 200, 500, 1); + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassValidation"), $langs->trans("ConfirmMassValidationQuestion"), "validate", null, '', 0, 200, 500, 1); } if ($massaction == 'createbills') { @@ -1469,8 +1480,8 @@ if ($resql) { } // Status billed if (!empty($arrayfields['cf.billed']['checked'])) { - print ''; - print $form->selectyesno('search_billed', $search_billed, 1, false, 1, 1, 'maxwidth100 onrightofpage'); + print ''; + print $form->selectyesno('search_billed', $search_billed, 1, false, 1, 1, 'search_status width100 onrightofpage'); print ''; } // Date valid @@ -1660,344 +1671,365 @@ if ($resql) { $objectstatic->note_private = $obj->note_private; $objectstatic->statut = $obj->fk_statut; - print ''; - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; - } - print ''; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + print '
'; } - print ''; - } - // Ref - if (!empty($arrayfields['cf.ref']['checked'])) { - print ''; - // Picto + Ref - print $objectstatic->getNomUrl(1, '', 0, -1, 1); - // Other picto tool - $filename = dol_sanitizeFileName($obj->ref); - $filedir = $conf->fournisseur->commande->dir_output.'/'.dol_sanitizeFileName($obj->ref); - print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); - - print ''."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Ref Supplier - if (!empty($arrayfields['cf.ref_supplier']['checked'])) { - print ''.dol_escape_htmltag($obj->ref_supplier).''."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Project - if (!empty($arrayfields['cf.fk_projet']['checked'])) { - $projectstatic->id = $obj->project_id; - $projectstatic->ref = $obj->project_ref; - $projectstatic->title = $obj->project_title; - print ''; - if ($obj->project_id > 0) { - print $projectstatic->getNomUrl(1); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Author - $userstatic->id = $obj->fk_user_author; - $userstatic->lastname = $obj->lastname; - $userstatic->firstname = $obj->firstname; - $userstatic->login = $obj->login; - $userstatic->photo = $obj->photo; - $userstatic->email = $obj->user_email; - $userstatic->statut = $obj->user_status; - if (!empty($arrayfields['u.login']['checked'])) { - print ''; - if ($userstatic->id) { - print $userstatic->getNomUrl(1); - } - print ""; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Thirdparty - if (!empty($arrayfields['cf.fk_soc']['checked'])) { - print ''; $thirdpartytmp->id = $obj->socid; $thirdpartytmp->name = $obj->name; $thirdpartytmp->email = $obj->email; $thirdpartytmp->name_alias = $obj->alias; $thirdpartytmp->client = $obj->client; $thirdpartytmp->fournisseur = $obj->fournisseur; - print $thirdpartytmp->getNomUrl(1, 'supplier', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); - print ''."\n"; - if (!$i) { - $totalarray['nbfield']++; + $objectstatic->socid = $thirdpartytmp->getNomUrl('supplier', 0, 0, -1); + // Output Kanban + print $objectstatic->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print '
'; + print ''; } - } - //alias - if (!empty($arrayfields['s.name_alias']['checked'])) { - print ''; - print $obj->alias; - print ''."\n"; - if (!$i) { - $totalarray['nbfield']++; + } else { + print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; } - } - // Town - if (!empty($arrayfields['s.town']['checked'])) { - print ''; - print $obj->town; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Zip - if (!empty($arrayfields['s.zip']['checked'])) { - print ''; - print $obj->zip; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // State - if (!empty($arrayfields['state.nom']['checked'])) { - print "".$obj->state_name."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Country - if (!empty($arrayfields['country.code_iso']['checked'])) { - print ''; - $tmparray = getCountry($obj->fk_pays, 'all'); - print $tmparray['label']; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Type ent - if (!empty($arrayfields['typent.code']['checked'])) { - print ''; - if (empty($typenArray)) { - $typenArray = $formcompany->typent_array(1); - } - print $typenArray[$obj->typent_code]; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } + // Ref + if (!empty($arrayfields['cf.ref']['checked'])) { + print ''; - // Order date - if (!empty($arrayfields['cf.date_commande']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_commande), 'day'); - if ($objectstatic->statut != $objectstatic::STATUS_ORDERSENT && $objectstatic->statut != $objectstatic::STATUS_RECEIVED_PARTIALLY) { - if ($objectstatic->hasDelay()) { - print ' '.img_picto($langs->trans("Late").' : '.$objectstatic->showDelay(), "warning"); + // Picto + Ref + print $objectstatic->getNomUrl(1, '', 0, -1, 1); + // Other picto tool + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->fournisseur->commande->dir_output.'/'.dol_sanitizeFileName($obj->ref); + print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + + print ''."\n"; + if (!$i) { + $totalarray['nbfield']++; } } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Plannned date of delivery - if (!empty($arrayfields['cf.date_livraison']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_livraison), 'day'); - if ($objectstatic->statut == $objectstatic::STATUS_ORDERSENT || $objectstatic->statut == $objectstatic::STATUS_RECEIVED_PARTIALLY) { - if ($objectstatic->hasDelay()) { - print ' '.img_picto($langs->trans("Late").' : '.$objectstatic->showDelay(), "warning"); + // Ref Supplier + if (!empty($arrayfields['cf.ref_supplier']['checked'])) { + print ''.dol_escape_htmltag($obj->ref_supplier).''."\n"; + if (!$i) { + $totalarray['nbfield']++; } } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount HT - if (!empty($arrayfields['cf.total_ht']['checked'])) { - print ''.price($obj->total_ht)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_ht'; - } - $totalarray['val']['cf.total_ht'] += $obj->total_ht; - } - // Amount VAT - if (!empty($arrayfields['cf.total_tva']['checked'])) { - print ''.price($obj->total_tva)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_tva'; - } - $totalarray['val']['cf.total_tva'] += $obj->total_tva; - } - // Amount TTC - if (!empty($arrayfields['cf.total_ttc']['checked'])) { - print ''.price($obj->total_ttc)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_ttc'; - } - $totalarray['val']['cf.total_ttc'] += $obj->total_ttc; - } - - // Currency - if (!empty($arrayfields['cf.multicurrency_code']['checked'])) { - print ''.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Currency rate - if (!empty($arrayfields['cf.multicurrency_tx']['checked'])) { - print ''; - $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount HT - if (!empty($arrayfields['cf.multicurrency_total_ht']['checked'])) { - print ''.price($obj->multicurrency_total_ht)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount VAT - if (!empty($arrayfields['cf.multicurrency_total_tva']['checked'])) { - print ''.price($obj->multicurrency_total_tva)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount TTC - if (!empty($arrayfields['cf.multicurrency_total_ttc']['checked'])) { - print ''.price($obj->multicurrency_total_ttc)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['cf.date_creation']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['cf.tms']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Status - if (!empty($arrayfields['cf.fk_statut']['checked'])) { - print ''.$objectstatic->LibStatut($obj->fk_statut, 5, $obj->billed).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Billed - if (!empty($arrayfields['cf.billed']['checked'])) { - print ''.yn($obj->billed).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // valid date - if (!empty($arrayfields['cf.date_valid']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_valid), 'day'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // approve date - if (!empty($arrayfields['cf.date_approve']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_approve), 'day'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Note public - if (!empty($arrayfields['cf.note_public']['checked'])) { - print ''; - print dol_string_nohtmltag($obj->note_public); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Note private - if (!empty($arrayfields['cf.note_private']['checked'])) { - print ''; - print dol_string_nohtmltag($obj->note_private); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; + // Project + if (!empty($arrayfields['cf.fk_projet']['checked'])) { + $projectstatic->id = $obj->project_id; + $projectstatic->ref = $obj->project_ref; + $projectstatic->title = $obj->project_title; + print ''; + if ($obj->project_id > 0) { + print $projectstatic->getNomUrl(1); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Author + $userstatic->id = $obj->fk_user_author; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; + $userstatic->login = $obj->login; + $userstatic->photo = $obj->photo; + $userstatic->email = $obj->user_email; + $userstatic->statut = $obj->user_status; + if (!empty($arrayfields['u.login']['checked'])) { + print ''; + if ($userstatic->id) { + print $userstatic->getNomUrl(1); + } + print ""; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Thirdparty + if (!empty($arrayfields['cf.fk_soc']['checked'])) { + print ''; + $thirdpartytmp->id = $obj->socid; + $thirdpartytmp->name = $obj->name; + $thirdpartytmp->email = $obj->email; + $thirdpartytmp->name_alias = $obj->alias; + $thirdpartytmp->client = $obj->client; + $thirdpartytmp->fournisseur = $obj->fournisseur; + print $thirdpartytmp->getNomUrl(1, 'supplier', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); + print ''."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + //alias + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + print $obj->alias; + print ''."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Town + if (!empty($arrayfields['s.town']['checked'])) { + print ''; + print $obj->town; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Zip + if (!empty($arrayfields['s.zip']['checked'])) { + print ''; + print $obj->zip; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // State + if (!empty($arrayfields['state.nom']['checked'])) { + print "".$obj->state_name."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) { + print ''; + $tmparray = getCountry($obj->fk_pays, 'all'); + print $tmparray['label']; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Type ent + if (!empty($arrayfields['typent.code']['checked'])) { + print ''; + if (empty($typenArray)) { + $typenArray = $formcompany->typent_array(1); + } + print $typenArray[$obj->typent_code]; + print ''; + if (!$i) { + $totalarray['nbfield']++; } - print ''; } - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } - print "\n"; + // Order date + if (!empty($arrayfields['cf.date_commande']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_commande), 'day'); + if ($objectstatic->statut != $objectstatic::STATUS_ORDERSENT && $objectstatic->statut != $objectstatic::STATUS_RECEIVED_PARTIALLY) { + if ($objectstatic->hasDelay()) { + print ' '.img_picto($langs->trans("Late").' : '.$objectstatic->showDelay(), "warning"); + } + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Plannned date of delivery + if (!empty($arrayfields['cf.date_livraison']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_livraison), 'day'); + if ($objectstatic->statut == $objectstatic::STATUS_ORDERSENT || $objectstatic->statut == $objectstatic::STATUS_RECEIVED_PARTIALLY) { + if ($objectstatic->hasDelay()) { + print ' '.img_picto($langs->trans("Late").' : '.$objectstatic->showDelay(), "warning"); + } + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount HT + if (!empty($arrayfields['cf.total_ht']['checked'])) { + print ''.price($obj->total_ht)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_ht'; + } + $totalarray['val']['cf.total_ht'] += $obj->total_ht; + } + // Amount VAT + if (!empty($arrayfields['cf.total_tva']['checked'])) { + print ''.price($obj->total_tva)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_tva'; + } + $totalarray['val']['cf.total_tva'] += $obj->total_tva; + } + // Amount TTC + if (!empty($arrayfields['cf.total_ttc']['checked'])) { + print ''.price($obj->total_ttc)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_ttc'; + } + $totalarray['val']['cf.total_ttc'] += $obj->total_ttc; + } - $total += $obj->total_ht; - $subtotal += $obj->total_ht; + // Currency + if (!empty($arrayfields['cf.multicurrency_code']['checked'])) { + print ''.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Currency rate + if (!empty($arrayfields['cf.multicurrency_tx']['checked'])) { + print ''; + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount HT + if (!empty($arrayfields['cf.multicurrency_total_ht']['checked'])) { + print ''.price($obj->multicurrency_total_ht)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount VAT + if (!empty($arrayfields['cf.multicurrency_total_tva']['checked'])) { + print ''.price($obj->multicurrency_total_tva)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount TTC + if (!empty($arrayfields['cf.multicurrency_total_ttc']['checked'])) { + print ''.price($obj->multicurrency_total_ttc)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['cf.date_creation']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date modification + if (!empty($arrayfields['cf.tms']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Status + if (!empty($arrayfields['cf.fk_statut']['checked'])) { + print ''.$objectstatic->LibStatut($obj->fk_statut, 5, $obj->billed).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Billed + if (!empty($arrayfields['cf.billed']['checked'])) { + print ''.yn($obj->billed).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // valid date + if (!empty($arrayfields['cf.date_valid']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_valid), 'day'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // approve date + if (!empty($arrayfields['cf.date_approve']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_approve), 'day'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Note public + if (!empty($arrayfields['cf.note_public']['checked'])) { + print ''; + print dol_string_nohtmltag($obj->note_public); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Note private + if (!empty($arrayfields['cf.note_private']['checked'])) { + print ''; + print dol_string_nohtmltag($obj->note_private); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } + + print "\n"; + + $total += $obj->total_ht; + $subtotal += $obj->total_ht; + } $i++; } diff --git a/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php b/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php index 192a39c9b06..e2e9fb5f899 100644 --- a/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php +++ b/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php @@ -46,7 +46,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { ?> trans("SupplierOrder"); ?> - trans("ShowOrder"), "order").' '.$objectlink->ref; ?> + getNomUrl(1); ?> ref_supplier; ?> date, 'day'); ?> global->MAIN_DEPOSIT_MULTI_TVA) && $diff != 0) { $object->fetch_lines(); $subprice_diff = $object->lines[0]->subprice - $diff / (1 + $object->lines[0]->tva_tx / 100); - $object->updateline($object->lines[0]->id, $object->lines[0]->desc, $subprice_diff, $object->lines[0]->qty, $object->lines[0]->remise_percent, $object->lines[0]->date_start, $object->lines[0]->date_end, $object->lines[0]->tva_tx, 0, 0, 'HT', $object->lines[0]->info_bits, $object->lines[0]->product_type, 0, 0, 0, $object->lines[0]->pa_ht, $object->lines[0]->label, 0, array(), 100); + $object->updateline( + $object->lines[0]->id, + $object->lines[0]->desc, + $subprice_diff, + $object->lines[0]->tva_tx, + $object->lines[0]->localtax1_tx, + $object->lines[0]->localtax2_tx, + $object->lines[0]->qty, + $object->lines[0]->fk_product, + 'HT', + $object->lines[0]->info_bits, + $object->lines[0]->product_type, + $object->lines[0]->remise_percent, + 0, + $object->lines[0]->date_start, + $object->lines[0]->date_end, + 0, + 0, + 0, + '', + 100 + ); } } elseif ($result > 0) { $lines = $srcobject->lines; @@ -2080,14 +2101,15 @@ if ($action == 'create') { // reload page to retrieve supplier informations if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) { print ''; + '; } if ($fac_recid <= 0) { print ' '; @@ -2212,7 +2234,7 @@ if ($action == 'create') { jQuery(".checkforselect").prop("disabled", false); jQuery(".checkforselect").prop("checked", true); } - }; + } }); '; @@ -3630,7 +3652,7 @@ if ($action == 'create') { // Show object lines if (!empty($object->lines)) { - $ret = $object->printObjectLines($action, $societe, $mysoc, $lineid, 1); + $object->printObjectLines($action, $societe, $mysoc, $lineid, 1); } $num = count($object->lines); diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index be215e891eb..9b790050571 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -99,14 +99,8 @@ $search_country = GETPOST("search_country", 'int'); $search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); $search_user = GETPOST('search_user', 'int'); $search_sale = GETPOST('search_sale', 'int'); -$search_date_startday = GETPOST('search_date_startday', 'int'); -$search_date_startmonth = GETPOST('search_date_startmonth', 'int'); -$search_date_startyear = GETPOST('search_date_startyear', 'int'); -$search_date_endday = GETPOST('search_date_endday', 'int'); -$search_date_endmonth = GETPOST('search_date_endmonth', 'int'); -$search_date_endyear = GETPOST('search_date_endyear', 'int'); -$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver -$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear); +$search_date_start = GETPOSTDATE('search_date_start', '', 'tzserver'); +$search_date_end = GETPOSTDATE('search_date_end', '23:59:59', 'tzserver'); $search_datelimit_startday = GETPOST('search_datelimit_startday', 'int'); $search_datelimit_startmonth = GETPOST('search_datelimit_startmonth', 'int'); $search_datelimit_startyear = GETPOST('search_datelimit_startyear', 'int'); @@ -277,12 +271,6 @@ if (empty($reshook)) { $search_type = ''; $search_country = ''; $search_type_thirdparty = ''; - $search_date_startday = ''; - $search_date_startmonth = ''; - $search_date_startyear = ''; - $search_date_endday = ''; - $search_date_endmonth = ''; - $search_date_endyear = ''; $search_date_start = ''; $search_date_end = ''; $search_datelimit_startday = ''; @@ -766,6 +754,9 @@ if ($socid) { } $param = '&socid='.$socid; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -775,23 +766,11 @@ if ($limit > 0 && $limit != $conf->liste_limit) { if ($search_all) { $param .= '&search_all='.urlencode($search_all); } -if ($search_date_startday) { - $param .= '&search_date_startday='.urlencode($search_date_startday); +if ($search_date_start) { + $param .= buildParamDate('search_date_start', null, '', 'tzserver'); } -if ($search_date_startmonth) { - $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); -} -if ($search_date_startyear) { - $param .= '&search_date_startyear='.urlencode($search_date_startyear); -} -if ($search_date_endday) { - $param .= '&search_date_endday='.urlencode($search_date_endday); -} -if ($search_date_endmonth) { - $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); -} -if ($search_date_endyear) { - $param .= '&search_date_endyear='.urlencode($search_date_endyear); +if ($search_date_end) { + $param .= buildParamDate('search_date_end', null, '', 'tzserver'); } if ($search_datelimit_startday) { $param .= '&search_datelimit_startday='.urlencode($search_datelimit_startday); @@ -918,7 +897,10 @@ $url = DOL_URL_ROOT.'/fourn/facture/card.php?action=create'; if (!empty($socid)) { $url .= '&socid='.urlencode($socid); } -$newcardbutton = dolGetButtonTitle($langs->trans('NewBill'), '', 'fa fa-plus-circle', $url, '', ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer)); +$newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('NewBill'), '', 'fa fa-plus-circle', $url, '', ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer)); $i = 0; print ''."\n"; @@ -1226,9 +1208,9 @@ if (!empty($arrayfields['f.tms']['checked'])) { } // Status if (!empty($arrayfields['f.fk_statut']['checked'])) { - print ''; + print ''; $liststatus = array('0'=>$langs->trans("Draft"), '1'=>$langs->trans("Unpaid"), '2'=>$langs->trans("Paid")); - print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'onrightofpage', 1); + print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage', 1); print ''; } // Action column @@ -1430,409 +1412,423 @@ if ($num > 0) { $remaintopay = -$facturestatic->getSumFromThisCreditNotesNotUsed(); } } - - print ''; - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->facid, $arrayofselected)) { - $selected = 1; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + print '
'; + } + // Output Kanban + $facturestatic->socid = $thirdparty->getNomUrl(1, 'supplier', 3); + $facturestatic->total_ht = $obj->total_ht; + $facturestatic->date = $obj->datef; + print $facturestatic->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print '
'; + print ''; + } + } else { + print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->facid, $arrayofselected)) { + $selected = 1; + } + print ''; } - print ''; + print ''; } - print ''; - } - if (!empty($arrayfields['f.ref']['checked'])) { - print ''; + if (!empty($arrayfields['f.ref']['checked'])) { + print ''; - print ''; - // Picto + Ref - print '
'; - print $facturestatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); + print ''; + // Picto + Ref + print '
'; + print $facturestatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); - $filename = dol_sanitizeFileName($obj->ref); - $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($obj->facid, 2, 0, 0, $facturestatic, 'invoice_supplier').dol_sanitizeFileName($obj->ref); - $subdir = get_exdir($obj->facid, 2, 0, 0, $facturestatic, 'invoice_supplier').dol_sanitizeFileName($obj->ref); - print $formfile->getDocumentsLink('facture_fournisseur', $subdir, $filedir); - print '
'; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($obj->facid, 2, 0, 0, $facturestatic, 'invoice_supplier').dol_sanitizeFileName($obj->ref); + $subdir = get_exdir($obj->facid, 2, 0, 0, $facturestatic, 'invoice_supplier').dol_sanitizeFileName($obj->ref); + print $formfile->getDocumentsLink('facture_fournisseur', $subdir, $filedir); + print '
'; - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Supplier ref - if (!empty($arrayfields['f.ref_supplier']['checked'])) { - print ''; - print $obj->ref_supplier; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Type - if (!empty($arrayfields['f.type']['checked'])) { - print ''; - print $facturestatic->getLibType(); - print ""; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Label - if (!empty($arrayfields['f.label']['checked'])) { - print ''; - print $obj->label; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Date - if (!empty($arrayfields['f.datef']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->datef), 'day'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Date limit - if (!empty($arrayfields['f.date_lim_reglement']['checked'])) { - print ''.dol_print_date($datelimit, 'day'); - if ($facturestatic->hasDelay()) { - print img_warning($langs->trans('Alert').' - '.$langs->trans('Late')); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Project - if (!empty($arrayfields['p.ref']['checked'])) { - print ''; - if ($obj->project_id > 0) { - $projectstatic->id = $obj->project_id; - $projectstatic->ref = $obj->project_ref; - $projectstatic->title = $obj->project_label; - print $projectstatic->getNomUrl(1); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Third party - if (!empty($arrayfields['s.nom']['checked'])) { - print ''; - print $thirdparty->getNomUrl(1, 'supplier', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Alias - if (!empty($arrayfields['s.name_alias']['checked'])) { - print ''; - print $thirdparty->name_alias; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Town - if (!empty($arrayfields['s.town']['checked'])) { - print ''; - print $obj->town; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Zip - if (!empty($arrayfields['s.zip']['checked'])) { - print ''; - print dol_escape_htmltag($obj->zip); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // State - if (!empty($arrayfields['state.nom']['checked'])) { - print "".$obj->state_name."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Country - if (!empty($arrayfields['country.code_iso']['checked'])) { - print ''; - $tmparray = getCountry($obj->fk_pays, 'all'); - print $tmparray['label']; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Type ent - if (!empty($arrayfields['typent.code']['checked'])) { - print ''; - if (empty($typenArray)) { - $typenArray = $formcompany->typent_array(1); - } - print $typenArray[$obj->typent_code]; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Payment condition - if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { - $s = $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 1, '', -1, -1, 1); - print ''; - print dol_escape_htmltag($s); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Payment mode - if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { - $s = $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1, 0, '', 1); - print ''; - print dol_escape_htmltag($s); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Amount HT - if (!empty($arrayfields['f.total_ht']['checked'])) { - print ''.price($obj->total_ht)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ht'; - } - $totalarray['val']['f.total_ht'] += $obj->total_ht; - } - // Amount VAT - if (!empty($arrayfields['f.total_vat']['checked'])) { - print ''.price($obj->total_vat)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'f.total_vat'; - } - $totalarray['val']['f.total_vat'] += $obj->total_vat; - } - // Amount LocalTax1 - if (!empty($arrayfields['f.total_localtax1']['checked'])) { - print ''.price($obj->total_localtax1)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax1'; - } - $totalarray['val']['f.total_localtax1'] += $obj->total_localtax1; - } - // Amount LocalTax2 - if (!empty($arrayfields['f.total_localtax2']['checked'])) { - print ''.price($obj->total_localtax2)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax2'; - } - $totalarray['val']['f.total_localtax2'] += $obj->total_localtax2; - } - // Amount TTC - if (!empty($arrayfields['f.total_ttc']['checked'])) { - print ''.price($obj->total_ttc)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc'; - } - $totalarray['val']['f.total_ttc'] += $obj->total_ttc; - } - - $userstatic->id = $obj->fk_user_author; - $userstatic->login = $obj->login; - $userstatic->lastname = $obj->lastname; - $userstatic->firstname = $obj->firstname; - $userstatic->email = $obj->user_email; - $userstatic->statut = $obj->user_statut; - $userstatic->entity = $obj->entity; - $userstatic->photo = $obj->photo; - $userstatic->office_phone = $obj->office_phone; - $userstatic->office_fax = $obj->office_fax; - $userstatic->user_mobile = $obj->user_mobile; - $userstatic->job = $obj->job; - $userstatic->gender = $obj->gender; - - // Author - if (!empty($arrayfields['u.login']['checked'])) { - print ''; - if ($userstatic->id) { - print $userstatic->getLoginUrl(-1); - } else { - print ' '; - } - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - if (!empty($arrayfields['dynamount_payed']['checked'])) { - print ''.(!empty($totalpay) ?price($totalpay, 0, $langs) : '').''; // TODO Use a denormalized field - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'totalam'; - } - $totalarray['val']['totalam'] += $totalpay; - } - - if (!empty($arrayfields['rtp']['checked'])) { - print ''.(!empty($remaintopay) ?price($remaintopay, 0, $langs) : ' ').''; // TODO Use a denormalized field - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'rtp'; - } - $totalarray['val']['rtp'] += $remaintopay; - } - - // Currency - if (!empty($arrayfields['f.multicurrency_code']['checked'])) { - print ''.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Currency rate - if (!empty($arrayfields['f.multicurrency_tx']['checked'])) { - print ''; - $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount HT - if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) { - print ''.price($obj->multicurrency_total_ht)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount VAT - if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) { - print ''.price($obj->multicurrency_total_vat)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount TTC - if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) { - print ''.price($obj->multicurrency_total_ttc)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) { - print ''.(!empty($multicurrency_totalpay) ?price($multicurrency_totalpay, 0, $langs) : '').''; // TODO Use a denormalized field - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Pending amount - if (!empty($arrayfields['multicurrency_rtp']['checked'])) { - print ''; - print (!empty($multicurrency_remaintopay) ? price($multicurrency_remaintopay, 0, $langs) : ''); - print ''; // TODO Use a denormalized field - if (!$i) { - $totalarray['nbfield']++; - } - } - - - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - // Date creation - if (!empty($arrayfields['f.datec']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['f.tms']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Status - if (!empty($arrayfields['f.fk_statut']['checked'])) { - print ''; - print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $paiement, $obj->type); - print ""; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->facid, $arrayofselected)) { - $selected = 1; + print "\n"; + if (!$i) { + $totalarray['nbfield']++; } - print ''; } - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } - print "\n"; + // Supplier ref + if (!empty($arrayfields['f.ref_supplier']['checked'])) { + print ''; + print $obj->ref_supplier; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Type + if (!empty($arrayfields['f.type']['checked'])) { + print ''; + print $facturestatic->getLibType(); + print ""; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Label + if (!empty($arrayfields['f.label']['checked'])) { + print ''; + print $obj->label; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date + if (!empty($arrayfields['f.datef']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->datef), 'day'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date limit + if (!empty($arrayfields['f.date_lim_reglement']['checked'])) { + print ''.dol_print_date($datelimit, 'day'); + if ($facturestatic->hasDelay()) { + print img_warning($langs->trans('Alert').' - '.$langs->trans('Late')); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Project + if (!empty($arrayfields['p.ref']['checked'])) { + print ''; + if ($obj->project_id > 0) { + $projectstatic->id = $obj->project_id; + $projectstatic->ref = $obj->project_ref; + $projectstatic->title = $obj->project_label; + print $projectstatic->getNomUrl(1); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Third party + if (!empty($arrayfields['s.nom']['checked'])) { + print ''; + print $thirdparty->getNomUrl(1, 'supplier', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Alias + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + print $thirdparty->name_alias; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Town + if (!empty($arrayfields['s.town']['checked'])) { + print ''; + print $obj->town; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Zip + if (!empty($arrayfields['s.zip']['checked'])) { + print ''; + print dol_escape_htmltag($obj->zip); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // State + if (!empty($arrayfields['state.nom']['checked'])) { + print "".$obj->state_name."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) { + print ''; + $tmparray = getCountry($obj->fk_pays, 'all'); + print $tmparray['label']; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Type ent + if (!empty($arrayfields['typent.code']['checked'])) { + print ''; + if (empty($typenArray)) { + $typenArray = $formcompany->typent_array(1); + } + print $typenArray[$obj->typent_code]; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Payment condition + if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { + $s = $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 1, '', -1, -1, 1); + print ''; + print dol_escape_htmltag($s); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Payment mode + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { + $s = $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1, 0, '', 1); + print ''; + print dol_escape_htmltag($s); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Amount HT + if (!empty($arrayfields['f.total_ht']['checked'])) { + print ''.price($obj->total_ht)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ht'; + } + $totalarray['val']['f.total_ht'] += $obj->total_ht; + } + // Amount VAT + if (!empty($arrayfields['f.total_vat']['checked'])) { + print ''.price($obj->total_vat)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_vat'; + } + $totalarray['val']['f.total_vat'] += $obj->total_vat; + } + // Amount LocalTax1 + if (!empty($arrayfields['f.total_localtax1']['checked'])) { + print ''.price($obj->total_localtax1)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax1'; + } + $totalarray['val']['f.total_localtax1'] += $obj->total_localtax1; + } + // Amount LocalTax2 + if (!empty($arrayfields['f.total_localtax2']['checked'])) { + print ''.price($obj->total_localtax2)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax2'; + } + $totalarray['val']['f.total_localtax2'] += $obj->total_localtax2; + } + // Amount TTC + if (!empty($arrayfields['f.total_ttc']['checked'])) { + print ''.price($obj->total_ttc)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc'; + } + $totalarray['val']['f.total_ttc'] += $obj->total_ttc; + } + + $userstatic->id = $obj->fk_user_author; + $userstatic->login = $obj->login; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; + $userstatic->email = $obj->user_email; + $userstatic->statut = $obj->user_statut; + $userstatic->entity = $obj->entity; + $userstatic->photo = $obj->photo; + $userstatic->office_phone = $obj->office_phone; + $userstatic->office_fax = $obj->office_fax; + $userstatic->user_mobile = $obj->user_mobile; + $userstatic->job = $obj->job; + $userstatic->gender = $obj->gender; + + // Author + if (!empty($arrayfields['u.login']['checked'])) { + print ''; + if ($userstatic->id) { + print $userstatic->getLoginUrl(-1); + } else { + print ' '; + } + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + if (!empty($arrayfields['dynamount_payed']['checked'])) { + print ''.(!empty($totalpay) ?price($totalpay, 0, $langs) : '').''; // TODO Use a denormalized field + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'totalam'; + } + $totalarray['val']['totalam'] += $totalpay; + } + + if (!empty($arrayfields['rtp']['checked'])) { + print ''.(!empty($remaintopay) ?price($remaintopay, 0, $langs) : ' ').''; // TODO Use a denormalized field + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'rtp'; + } + $totalarray['val']['rtp'] += $remaintopay; + } + + // Currency + if (!empty($arrayfields['f.multicurrency_code']['checked'])) { + print ''.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Currency rate + if (!empty($arrayfields['f.multicurrency_tx']['checked'])) { + print ''; + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount HT + if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) { + print ''.price($obj->multicurrency_total_ht)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount VAT + if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) { + print ''.price($obj->multicurrency_total_vat)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount TTC + if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) { + print ''.price($obj->multicurrency_total_ttc)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) { + print ''.(!empty($multicurrency_totalpay) ?price($multicurrency_totalpay, 0, $langs) : '').''; // TODO Use a denormalized field + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Pending amount + if (!empty($arrayfields['multicurrency_rtp']['checked'])) { + print ''; + print (!empty($multicurrency_remaintopay) ? price($multicurrency_remaintopay, 0, $langs) : ''); + print ''; // TODO Use a denormalized field + if (!$i) { + $totalarray['nbfield']++; + } + } + + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Date creation + if (!empty($arrayfields['f.datec']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date modification + if (!empty($arrayfields['f.tms']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Status + if (!empty($arrayfields['f.fk_statut']['checked'])) { + print ''; + print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $paiement, $obj->type); + print ""; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->facid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } + + print "\n"; + } $i++; } diff --git a/htdocs/ftp/index.php b/htdocs/ftp/index.php index af48f0f8348..e6c1aac1372 100644 --- a/htdocs/ftp/index.php +++ b/htdocs/ftp/index.php @@ -154,6 +154,7 @@ if ($action == 'addfolder') { // Action ajout d'un rep if ($action == 'add' && $user->rights->ftp->setup) { + $ecmdir = new EcmDirectory($db); $ecmdir->ref = GETPOST("ref"); $ecmdir->label = GETPOST("label"); $ecmdir->description = GETPOST("desc"); @@ -282,7 +283,7 @@ if ($action == 'download') { $newsection = $section; - $result = dol_ftp_get($connect_id, $localfile, $file, $newsection); + $result = dol_ftp_get($conn_id, $localfile, $file, $newsection); if ($result) { @@ -306,9 +307,9 @@ if ($action == 'download') { header('Content-Type: '.$type); } if ($attachment) { - header('Content-Disposition: attachment; filename="'.$filename.'"'); + header('Content-Disposition: attachment; filename="'.$file.'"'); } else { - header('Content-Disposition: inline; filename="'.$filename.'"'); + header('Content-Disposition: inline; filename="'.$file.'"'); } // Ajout directives pour resoudre bug IE @@ -319,7 +320,7 @@ if ($action == 'download') { exit; } else { - setEventMessages($langs->transnoentitiesnoconv('FailedToGetFile', $remotefile), null, 'errors'); + setEventMessages($langs->transnoentitiesnoconv('FailedToGetFile', $file), null, 'errors'); } } else { dol_print_error('', $mesg); diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 0125becd21c..e8f56659de9 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1470,7 +1470,7 @@ class Holiday extends CommonObject $sql .= " value = '".$this->db->escape($value)."'"; $sql .= " WHERE name = '".$this->db->escape($name)."'"; - dol_syslog(get_class($this).'::updateConfCP name='.$name.'', LOG_DEBUG); + dol_syslog(get_class($this).'::updateConfCP name='.$name, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { return true; @@ -1580,7 +1580,7 @@ class Holiday extends CommonObject // We add a log for each user $this->addLogCP($user->id, $userCounter['rowid'], $langs->trans('HolidaysMonthlyUpdate'), $newSolde, $userCounter['type']); - $result = $this->updateSoldeCP($userCounter['rowid'], $newSolde, $userCounter['type'], $langs->trans('HolidaysMonthlyUpdate')); + $result = $this->updateSoldeCP($userCounter['rowid'], $newSolde, $userCounter['type']); if ($result < 0) { $error++; @@ -2419,4 +2419,41 @@ class Holiday extends CommonObject return -1; } } + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + global $langs, $selected; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + if (property_exists($this, 'fk_user') && !empty($this->id)) { + $return .= '| '.$this->fk_user.''; + $return .= ''; + } + if (property_exists($this, 'fk_type')) { + $return .= '
'.$langs->trans("Type").' : '; + $return .= ''.$langs->trans($this->getTypes(1, -1)[$this->fk_type]['code']).''; + } + if (property_exists($this, 'date_debut') && property_exists($this, 'date_fin')) { + $return .= '
'.dol_print_date($this->date_debut, 'day').''; + $return .= ' '.$langs->trans("To").' '; + $return .= ''.dol_print_date($this->date_fin, 'day').''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 564fb8a2a96..cef7375a4b6 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -52,6 +52,7 @@ $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'holidaylist'; // To manage different context of search +$mode = GETPOST('mode', 'alpha'); // for switch mode view result $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') @@ -394,6 +395,9 @@ if ($resql) { $arrayofselected = is_array($toselect) ? $toselect : array(); $param = ''; + if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); + } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -476,6 +480,8 @@ if ($resql) { print ''; print ''; print ''; + print ''; + if ($id > 0) { print ''; } @@ -519,7 +525,11 @@ if ($resql) { } else { $title = $langs->trans("ListeCP"); - $newcardbutton = dolGetButtonTitle($langs->trans('MenuAddCP'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/holiday/card.php?action=create', '', $user->rights->holiday->write); + + $newcardbutton = ''; + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('MenuAddCP'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/holiday/card.php?action=create', '', $user->rights->holiday->write); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_hrm', 0, $newcardbutton, '', $limit, 0, 0, 1); } @@ -787,7 +797,8 @@ if ($resql) { $holidaystatic->id = $obj->rowid; $holidaystatic->ref = ($obj->ref ? $obj->ref : $obj->rowid); $holidaystatic->statut = $obj->status; - $holidaystatic->date_debut = $db->jdate($obj->date_debut); + $holidaystatic->date_debut = $obj->date_debut; + $holidaystatic->date_fin = $obj->date_fin; // User $userstatic->id = $obj->fk_user; @@ -815,139 +826,163 @@ if ($resql) { $starthalfday = ($obj->halfday == -1 || $obj->halfday == 2) ? 'afternoon' : 'morning'; $endhalfday = ($obj->halfday == 1 || $obj->halfday == 2) ? 'morning' : 'afternoon'; - print ''; - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $nbopenedday = num_open_day($db->jdate($obj->date_debut, 1), $db->jdate($obj->date_fin, 1), 0, 1, $obj->halfday); // user jdate(..., 1) because num_open_day need UTC dates + $totalduration += $nbopenedday; + + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + print '
'; + } + + $holidaystatic->fk_type = $holidaystatic->getTypes(1, -1)[$obj->fk_type]['rowid']; + $holidaystatic->fk_user = $userstatic->getNomUrl(1); + // Output Kanban + if ($massactionbutton || $massaction) { $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { + if (in_array($object->id, $arrayofselected)) { $selected = 1; } - print ''; + print $holidaystatic->getKanbanView(''); } - print ''; - } - if (!empty($arrayfields['cp.ref']['checked'])) { - print ''; - print $holidaystatic->getNomUrl(1, 1); - print ''; - if (!$i) { - $totalarray['nbfield']++; + if ($i == (min($num, $limit) - 1)) { + print '
'; + print ''; } - } - if (!empty($arrayfields['cp.fk_user']['checked'])) { - print ''.$userstatic->getNomUrl(-1, 'leave').''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['cp.fk_validator']['checked'])) { - print ''.$approbatorstatic->getNomUrl(-1).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['cp.fk_type']['checked'])) { - $labeltypeleavetoshow = ($langs->trans($typeleaves[$obj->fk_type]['code']) != $typeleaves[$obj->fk_type]['code'] ? $langs->trans($typeleaves[$obj->fk_type]['code']) : $typeleaves[$obj->fk_type]['label']); - $labeltypeleavetoshow = empty($typeleaves[$obj->fk_type]['label']) ? $langs->trans("TypeWasDisabledOrRemoved", $obj->fk_type) : $labeltypeleavetoshow; - - print ''; - print $labeltypeleavetoshow; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['duration']['checked'])) { - print ''; - $nbopenedday = num_open_day($db->jdate($obj->date_debut, 1), $db->jdate($obj->date_fin, 1), 0, 1, $obj->halfday); // user jdate(..., 1) because num_open_day need UTC dates - $totalduration += $nbopenedday; - print $nbopenedday; - //print ' '.$langs->trans('DurationDays'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['cp.date_debut']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_debut), 'day'); - print ' ('.$langs->trans($listhalfday[$starthalfday]).')'; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['cp.date_fin']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_fin), 'day'); - print ' ('.$langs->trans($listhalfday[$endhalfday]).')'; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date validation - if (!empty($arrayfields['cp.date_valid']['checked'])) { // date_valid is both date_valid but also date_approval - print ''; - print dol_print_date($db->jdate($obj->date_valid), 'day'); - print ''; - if (!$i) $totalarray['nbfield']++; - } - // Date approval - if (!empty($arrayfields['cp.date_approval']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_approval), 'day'); - print ''; - if (!$i) $totalarray['nbfield']++; - } - - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - // Date creation - if (!empty($arrayfields['cp.date_create']['checked'])) { - print ''.dol_print_date($date, 'dayhour').''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['cp.tms']['checked'])) { - print ''.dol_print_date($date_modif, 'dayhour').''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['cp.statut']['checked'])) { - print ''.$holidaystatic->getLibStatut(5).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; + } else { + print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; } - print ''; + print ''; } - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } + if (!empty($arrayfields['cp.ref']['checked'])) { + print ''; + print $holidaystatic->getNomUrl(1, 1); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['cp.fk_user']['checked'])) { + print ''.$userstatic->getNomUrl(-1, 'leave').''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['cp.fk_validator']['checked'])) { + print ''.$approbatorstatic->getNomUrl(-1).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['cp.fk_type']['checked'])) { + $labeltypeleavetoshow = ($langs->trans($typeleaves[$obj->fk_type]['code']) != $typeleaves[$obj->fk_type]['code'] ? $langs->trans($typeleaves[$obj->fk_type]['code']) : $typeleaves[$obj->fk_type]['label']); + $labeltypeleavetoshow = empty($typeleaves[$obj->fk_type]['label']) ? $langs->trans("TypeWasDisabledOrRemoved", $obj->fk_type) : $labeltypeleavetoshow; - print ''."\n"; + print ''; + print $labeltypeleavetoshow; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['duration']['checked'])) { + print ''; + $nbopenedday = num_open_day($db->jdate($obj->date_debut, 1), $db->jdate($obj->date_fin, 1), 0, 1, $obj->halfday); // user jdate(..., 1) because num_open_day need UTC dates + $totalduration += $nbopenedday; + print $nbopenedday; + //print ' '.$langs->trans('DurationDays'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['cp.date_debut']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_debut), 'day'); + print ' ('.$langs->trans($listhalfday[$starthalfday]).')'; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['cp.date_fin']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_fin), 'day'); + print ' ('.$langs->trans($listhalfday[$endhalfday]).')'; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date validation + if (!empty($arrayfields['cp.date_valid']['checked'])) { // date_valid is both date_valid but also date_approval + print ''; + print dol_print_date($db->jdate($obj->date_valid), 'day'); + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Date approval + if (!empty($arrayfields['cp.date_approval']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_approval), 'day'); + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Date creation + if (!empty($arrayfields['cp.date_create']['checked'])) { + print ''.dol_print_date($date, 'dayhour').''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['cp.tms']['checked'])) { + print ''.dol_print_date($date_modif, 'dayhour').''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['cp.statut']['checked'])) { + print ''.$holidaystatic->getLibStatut(5).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } + + print ''."\n"; + } $i++; } diff --git a/htdocs/hrm/admin/admin_establishment.php b/htdocs/hrm/admin/admin_establishment.php index 99212988488..59192bc5ca5 100644 --- a/htdocs/hrm/admin/admin_establishment.php +++ b/htdocs/hrm/admin/admin_establishment.php @@ -145,13 +145,12 @@ if ($result) { $establishmentstatic->label = $obj->label; $establishmentstatic->status = $obj->status; - print ''; print ''.$establishmentstatic->getNomUrl(1).''; - print ''.$obj->label.''; - print ''.$obj->address.''; - print ''.$obj->zip.''; - print ''.$obj->town.''; + print ''.dol_escape_htmltag($obj->label).''; + print ''.dol_escape_htmltag($obj->address).''; + print ''.dol_escape_htmltag($obj->zip).''; + print ''.dol_escape_htmltag($obj->town).''; print ''; print $establishmentstatic->getLibStatut(5); print ''; @@ -160,7 +159,7 @@ if ($result) { $i++; } } else { - print ''.$langs->trans("None").''; + print ''.$langs->trans("None").''; } print ''; diff --git a/htdocs/hrm/class/evaluation.class.php b/htdocs/hrm/class/evaluation.class.php index 0125e7f882c..4a41f1c8e0e 100644 --- a/htdocs/hrm/class/evaluation.class.php +++ b/htdocs/hrm/class/evaluation.class.php @@ -853,7 +853,7 @@ class Evaluation extends CommonObject $this->labelStatus[self::STATUS_CLOSED] = $langs->transnoentitiesnoconv('Closed'); $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated'); - $this->labelStatus[self::STATUS_CLOSED] = $langs->transnoentitiesnoconv('Closed'); + $this->labelStatusShort[self::STATUS_CLOSED] = $langs->transnoentitiesnoconv('Closed'); } $statusType = 'status'.$status; @@ -923,8 +923,8 @@ class Evaluation extends CommonObject $result = $objectline->fetchAll('ASC', '', 0, 0, array('customsql'=>'fk_evaluation = '.$this->id)); if (is_numeric($result)) { - $this->error = $this->error; - $this->errors = $this->errors; + $this->error = $objectline->error; + $this->errors = $objectline->errors; return $result; } else { $this->lines = $result; diff --git a/htdocs/hrm/class/evaluationdet.class.php b/htdocs/hrm/class/evaluationdet.class.php index f9bbde51912..5489065e52d 100644 --- a/htdocs/hrm/class/evaluationdet.class.php +++ b/htdocs/hrm/class/evaluationdet.class.php @@ -561,7 +561,8 @@ class Evaluationline extends CommonObject $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'evaluationline/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (!$resql) { - $error++; $this->error = $this->db->lasterror(); + $error++; + $this->error = $this->db->lasterror(); } // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments @@ -891,8 +892,8 @@ class Evaluationline extends CommonObject $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_evaluationdet = '.$this->id)); if (is_numeric($result)) { - $this->error = $this->error; - $this->errors = $this->errors; + $this->error = $objectline->error; + $this->errors = $objectline->errors; return $result; } else { $this->lines = $result; diff --git a/htdocs/hrm/class/job.class.php b/htdocs/hrm/class/job.class.php index 117878c10c9..a013bb57a36 100644 --- a/htdocs/hrm/class/job.class.php +++ b/htdocs/hrm/class/job.class.php @@ -600,30 +600,27 @@ class Job extends CommonObject } /** - * Get last job for user + * Get the last occupied position for a user * - * @param int $fk_user id of user we need to get last job - * @return mixed|string|null + * @param int $fk_user Id of user we need to get last job + * @return Position|string Last occupied position */ public function getLastJobForUser($fk_user) { - global $db; - - $j = new Job($db); - $Tab = $j->getForUser($fk_user); + $Tab = $this->getForUser($fk_user); if (empty($Tab)) return ''; - $job = array_shift($Tab); + $lastpos = array_shift($Tab); - return $job; + return $lastpos; } /** - * Get jobs for user + * Get array of occupied positions for a user * - * @param int $userid id of user we need to get job list - * @return array of jobs + * @param int $userid Id of user we need to get job list + * @return Position[] Array of occupied positions */ public function getForUser($userid) { @@ -925,8 +922,8 @@ class Job extends CommonObject $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_job = '.$this->id)); if (is_numeric($result)) { - $this->error = $this->error; - $this->errors = $this->errors; + $this->error = $objectline->error; + $this->errors = $objectline->errors; return $result; } else { $this->lines = $result; @@ -1057,6 +1054,37 @@ class Job extends CommonObject return $error; } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + global $selected, $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + $return .= ''; + if (property_exists($this, 'deplacement')) { + $return .= '
'.$langs->trans("Type").''; + $return .= ' : '.$this->fields['deplacement']['arrayofkeyval'][$this->deplacement].''; + } + if (property_exists($this, 'description') && !(empty($this->description))) { + $return .= '
'.$langs->trans("Description").' : '; + $return .= '
'.(strlen($this->description) > 30 ? dol_substr($this->description, 0, 25).'...' : $this->description).''; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/hrm/class/position.class.php b/htdocs/hrm/class/position.class.php index 5d0c04a4f47..98b5fd89be9 100644 --- a/htdocs/hrm/class/position.class.php +++ b/htdocs/hrm/class/position.class.php @@ -971,8 +971,8 @@ class Position extends CommonObject $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql' => 'fk_position = ' . $this->id)); if (is_numeric($result)) { - $this->error = $this->error; - $this->errors = $this->errors; + $this->error = $objectline->error; + $this->errors = $objectline->errors; return $result; } else { $this->lines = $result; @@ -1036,6 +1036,8 @@ class Position extends CommonObject } /** + * getForUser + * * @param int $userid id of user we need to get position list * @return array|int of positions of user with for each of them the job fetched into that array */ @@ -1049,7 +1051,7 @@ class Position extends CommonObject } /** - * Create a document onto disk according to template module. + * Create a document onto disk according to template module. * * @param string $modele Force template to use ('' to not force) * @param Translate $outputlangs objet lang a utiliser pour traduction diff --git a/htdocs/hrm/class/skill.class.php b/htdocs/hrm/class/skill.class.php index 592fd77ac45..0832ded3725 100644 --- a/htdocs/hrm/class/skill.class.php +++ b/htdocs/hrm/class/skill.class.php @@ -965,8 +965,8 @@ class Skill extends CommonObject $result = $objectline->fetchAll('ASC', 'rankorder', 0, 0, array('customsql'=>'fk_skill = '.$this->id)); if (is_numeric($result)) { - $this->error = $this->error; - $this->errors = $this->errors; + $this->error = $objectline->error; + $this->errors = $objectline->errors; return $result; } else { $this->lines = $result; diff --git a/htdocs/hrm/class/skillrank.class.php b/htdocs/hrm/class/skillrank.class.php index 6db80642bab..2d75425823e 100644 --- a/htdocs/hrm/class/skillrank.class.php +++ b/htdocs/hrm/class/skillrank.class.php @@ -919,8 +919,8 @@ class SkillRank extends CommonObject $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_skillrank = '.((int) $this->id))); if (is_numeric($result)) { - $this->error = $this->error; - $this->errors = $this->errors; + $this->error = $objectline->error; + $this->errors = $objectline->errors; return $result; } else { $this->lines = $result; diff --git a/htdocs/hrm/compare.php b/htdocs/hrm/compare.php index 686d5820695..6365dd51d25 100644 --- a/htdocs/hrm/compare.php +++ b/htdocs/hrm/compare.php @@ -28,9 +28,6 @@ * 2- the central part displays the skills. display of the maximum score for this group and the number of occurrences. * * 3- the right part displays the members of group 2 or the job to be compared - * - * - * */ @@ -48,6 +45,7 @@ require_once DOL_DOCUMENT_ROOT . '/hrm/lib/hrm.lib.php'; // Load translation files required by the page $langs->load('hrm'); +$job = new Job($db); // Permissions $permissiontoread = $user->rights->hrm->evaluation->read || $user->rights->hrm->compare_advance->read; @@ -61,8 +59,8 @@ if (!$permissiontoread || ($action === 'create' && !$permissiontoadd)) accessfor * View */ -$css = array(); -$css[] = '/hrm/css/style.css'; +$css = array('/hrm/css/style.css'); + llxHeader('', $langs->trans('SkillComparison'), '', '', 0, 0, '', $css); $head = array(); @@ -74,8 +72,6 @@ $head[$h][2] = 'compare'; print dol_get_fiche_head($head, 'compare', '', 1); -//$PDOdb = new TPDOdb; -$form = new Form($db); ?> '; print '
'; @@ -994,7 +994,7 @@ if ($action == 'create' && $user->rights->projet->creer) { console.log("Hide task fields "+jQuery("#usage_task").prop("checked")); jQuery(".classusetask").hide(); } - }; + } });'; print ''; print '
'; @@ -1020,7 +1020,7 @@ if ($action == 'create' && $user->rights->projet->creer) { console.log("Hide bill time fields "+jQuery("#usage_bill_time").prop("checked")); jQuery(".classusebilltime").hide(); } - }; + } });'; print ''; print '
'; @@ -1046,7 +1046,7 @@ if ($action == 'create' && $user->rights->projet->creer) { console.log("Hide organize event fields "+jQuery("#usage_organize_event").prop("checked")); jQuery(".classuseorganizeevent").hide(); } - }; + } });'; print ''; } diff --git a/htdocs/projet/class/api_projects.class.php b/htdocs/projet/class/api_projects.class.php index 6a18057afd5..8cbb3949cd5 100644 --- a/htdocs/projet/class/api_projects.class.php +++ b/htdocs/projet/class/api_projects.class.php @@ -29,7 +29,6 @@ */ class Projects extends DolibarrApi { - /** * @var array $FIELDS Mandatory fields, checked when create and update object */ @@ -267,10 +266,9 @@ class Projects extends DolibarrApi * * @param int $id Id of project * @param int $userid Id of user (0 = connected user) + * @return array * * @url GET {id}/roles - * - * @return int */ public function getRoles($id, $userid = 0) { @@ -301,6 +299,7 @@ class Projects extends DolibarrApi foreach ($this->project->roles as $line) { array_push($result, $this->_cleanObjectDatas($line)); } + return $result; } diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index c1c24d4f8da..79ea13dcd40 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1480,7 +1480,7 @@ class Project extends CommonObject * @param int $list 0=Return array, 1=Return string list * @param int $socid 0=No filter on third party, id of third party * @param string $filter additionnal filter on project (statut, ref, ...) - * @return array or string Array of projects id, or string with projects id separated with "," if list is 1 + * @return array|string Array of projects id, or string with projects id separated with "," if list is 1 */ public function getProjectsAuthorizedForUser($user, $mode = 0, $list = 0, $socid = 0, $filter = '') { @@ -2289,8 +2289,8 @@ class Project extends CommonObject * Adds it to non existing supplied categories. * Existing categories are left untouch. * - * @param int[]|int $categories Category or categories IDs - * @return void + * @param int[]|int $categories Category or categories IDs + * @return int <0 if KO, >0 if OK */ public function setCategories($categories) { diff --git a/htdocs/projet/class/projectstats.class.php b/htdocs/projet/class/projectstats.class.php index 65d673a9ad2..e2b6c5129ff 100644 --- a/htdocs/projet/class/projectstats.class.php +++ b/htdocs/projet/class/projectstats.class.php @@ -298,7 +298,7 @@ class ProjectStats extends Stats * @param int $startyear End year * @param int $cachedelay Delay we accept for cache file (0=No read, no save of cache, -1=No read but save) * @param int $wonlostfilter Add a filter on status won/lost - * @return array Array of values + * @return array|int Array of values or <0 if error */ public function getWeightedAmountByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $wonlostfilter = 1) { @@ -411,10 +411,10 @@ class ProjectStats extends Stats /** * Return amount of elements by month for several years * - * @param int $endyear End year - * @param int $startyear Start year - * @param int $cachedelay accept for cache file (0=No read, no save of cache, -1=No read but save) - * @return array of values + * @param int $endyear End year + * @param int $startyear Start year + * @param int $cachedelay accept for cache file (0=No read, no save of cache, -1=No read but save) + * @return array|int Array of values or <0 if error */ public function getTransformRateByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0) { @@ -549,7 +549,7 @@ class ProjectStats extends Stats /** * Return average of entity by month * @param int $year year number - * @return int value + * @return array */ protected function getAverageByMonth($year) { diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 91333c153f8..6c2e8ad29a4 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -812,7 +812,7 @@ class Task extends CommonObjectLine * @param array $search_array_options Array of search * @param int $loadextras Fetch all Extrafields on each task * @param int $loadRoleMode 1= will test Roles on task; 0 used in delete project action - * @return array Array of tasks + * @return array|string Array of tasks */ public function getTasksArray($usert = null, $userp = null, $projectid = 0, $socid = 0, $mode = 0, $filteronproj = '', $filteronprojstatus = '-1', $morewherefilter = '', $filteronprojuser = 0, $filterontaskuser = 0, $extrafields = array(), $includebilltime = 0, $search_array_options = array(), $loadextras = 0, $loadRoleMode = 1) { @@ -1025,7 +1025,8 @@ class Task extends CommonObjectLine if (!empty($extrafields->attributes['projet']['label'])) { foreach ($extrafields->attributes['projet']['label'] as $key => $val) { if ($extrafields->attributes['projet']['type'][$key] != 'separate') { - $tasks[$i]->{'options_'.$key} = $obj->{'options_'.$key}; + $tmpvar = 'options_'.$key; + $tasks[$i]->{'options_'.$key} = $obj->$tmpvar; } } } @@ -1033,7 +1034,8 @@ class Task extends CommonObjectLine if (!empty($extrafields->attributes['projet_task']['label'])) { foreach ($extrafields->attributes['projet_task']['label'] as $key => $val) { if ($extrafields->attributes['projet_task']['type'][$key] != 'separate') { - $tasks[$i]->{'options_'.$key} = $obj->{'options_'.$key}; + $tmpvar = 'options_'.$key; + $tasks[$i]->{'options_'.$key} = $obj->$tmpvar; } } } @@ -1061,7 +1063,7 @@ class Task extends CommonObjectLine * @param int $projectid Project id list separated with , to filter on project * @param int $taskid Task id to filter on a task * @param integer $filteronprojstatus Filter on project status if userp is set. Not used if userp not defined. - * @return array Array (projectid => 'list of roles for project' or taskid => 'list of roles for task') + * @return array|int Array (projectid => 'list of roles for project' or taskid => 'list of roles for task') */ public function getUserRolesForProjectsOrTasks($userp, $usert, $projectid = '', $taskid = 0, $filteronprojstatus = -1) { @@ -1396,12 +1398,10 @@ class Task extends CommonObjectLine * * @param User|int $userobj Filter on user. null or 0=No filter * @param string $morewherefilter Add more filter into where SQL request (must start with ' AND ...') - * @return array Array of info for task array('min_date', 'max_date', 'total_duration', 'total_amount', 'nblines', 'nblinesnull') + * @return array|int Array of info for task array('min_date', 'max_date', 'total_duration', 'total_amount', 'nblines', 'nblinesnull') */ public function getSummaryOfTimeSpent($userobj = null, $morewherefilter = '') { - global $langs; - if (is_object($userobj)) { $userid = $userobj->id; } else { @@ -1565,14 +1565,12 @@ class Task extends CommonObjectLine /** * Load all records of time spent * - * @param User $userobj User object - * @param string $morewherefilter Add more filter into where SQL request (must start with ' AND ...') - * @return int <0 if KO, array of time spent if OK + * @param User $userobj User object + * @param string $morewherefilter Add more filter into where SQL request (must start with ' AND ...') + * @return array|int <0 if KO, array of time spent if OK */ public function fetchAllTimeSpent(User $userobj, $morewherefilter = '') { - global $langs; - $arrayres = array(); $sql = "SELECT"; @@ -2327,4 +2325,39 @@ class Task extends CommonObjectLine return ($datetouse > 0 && ($datetouse < ($now - $conf->project->task->warning_delay))); } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + global $langs, $conf; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + //$return .= ''; // Can be image + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + if (property_exists($this, 'fk_project') ) { + $return .= '
'.$this->fk_project.''; + } + if (property_exists($this, 'budget_amount')) { + $return .= '
'.$langs->trans("Budget").' : '.price($this->budget_amount, 0, $langs, 1, 0, 0, $conf->currency).''; + } + if (property_exists($this, 'fk_statut')) { + $return .= '
'.$this->fk_statut.''; + } + if (property_exists($this, 'duration_effective')) { + $return .= '
'.getTaskProgressView($this, false, false).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/projet/class/taskstats.class.php b/htdocs/projet/class/taskstats.class.php index ce7c6c4f4c5..6ff56fd8132 100644 --- a/htdocs/projet/class/taskstats.class.php +++ b/htdocs/projet/class/taskstats.class.php @@ -212,7 +212,7 @@ class TaskStats extends Stats /** * Return average of entity by month * @param int $year year number - * @return int value + * @return array array of values */ protected function getAverageByMonth($year) { diff --git a/htdocs/projet/jsgantt_language.js.php b/htdocs/projet/jsgantt_language.js.php index 35ab1132ae7..93b9ee5505f 100644 --- a/htdocs/projet/jsgantt_language.js.php +++ b/htdocs/projet/jsgantt_language.js.php @@ -67,7 +67,7 @@ var vLangs={'getDefaultLang(1); ?>': 'sunday':'transnoentities('Sunday'); ?>','monday':'transnoentities('Monday'); ?>','tuesday':'transnoentities('Tuesday'); ?>','wednesday':'transnoentities('Wednesday'); ?>','thursday':'transnoentities('Thursday'); ?>','friday':'transnoentities('Friday'); ?>','saturday':'transnoentities('Saturday'); ?>', 'sun':'transnoentities('SundayMin'); ?>','mon':'transnoentities('MondayMin'); ?>','tue':'transnoentities('TuesdayMin'); ?>','wed':'transnoentities('WednesdayMin'); ?>','thu':'transnoentities('ThursdayMin'); ?>','fri':'transnoentities('FridayMin'); ?>','sat':'transnoentities('SaturdayMin'); ?>' } -}; +} var vLang='getDefaultLang(1); ?>'; $langs->trans("ThirdParty"), 'checked'=>1 $arrayfields['s.name_alias'] = array('label'=>"AliasNameShort", 'checked'=>0, 'position'=>22); $arrayfields['commercial'] = array('label'=>$langs->trans("SaleRepresentativesOfThirdParty"), 'checked'=>0, 'position'=>23); $arrayfields['c.assigned'] = array('label'=>$langs->trans("AssignedTo"), 'checked'=>-1, 'position'=>120); -$arrayfields['opp_weighted_amount'] = array('label'=>$langs->trans('OpportunityWeightedAmountShort'), 'checked'=>0, 'position'=> 116, 'enabled'=>(empty($conf->global->PROJECT_USE_OPPORTUNITIES) ? 0 : 1), 'position'=>106); +$arrayfields['opp_weighted_amount'] = array('label'=>$langs->trans('OpportunityWeightedAmountShort'), 'checked'=>0, 'enabled'=>(empty($conf->global->PROJECT_USE_OPPORTUNITIES) ? 0 : 1), 'position'=>106); $arrayfields['u.login'] = array('label'=>"Author", 'checked'=>1, 'position'=>165); // Force some fields according to search_usage filter... if (GETPOST('search_usage_opportunity')) { @@ -1187,13 +1187,13 @@ if (!empty($arrayfields['p.import_key']['checked'])) { print ''; } if (!empty($arrayfields['p.fk_statut']['checked'])) { - print ''; + print ''; $arrayofstatus = array(); foreach ($object->statuts_short as $key => $val) { $arrayofstatus[$key] = $langs->trans($val); } $arrayofstatus['99'] = $langs->trans("NotClosed").' ('.$langs->trans('Draft').' + '.$langs->trans('Opened').')'; - print $form->selectarray('search_status', $arrayofstatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth125 onrightofpage', 1); + print $form->selectarray('search_status', $arrayofstatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage', 1); print ''; } // Action column diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index c966a34ea0b..877cd910311 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -183,6 +183,14 @@ $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; * Actions */ +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; + $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} + $parameters = array('id'=>$id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { @@ -413,6 +421,7 @@ $help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; llxHeader("", $title, $help_url); +$arrayofselected = is_array($toselect) ? $toselect : array(); if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); @@ -544,6 +553,18 @@ if ($id > 0 || !empty($ref)) { // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + $arrayofmassactions = array(); + if ($user->rights->projet->creer) { + $arrayofmassactions['preclonetasks'] = img_picto('', 'rightarrow', 'class="pictofixedwidth"').$langs->trans("Clone"); + } + if ($permissiontodelete) { + $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); + } + if (in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); + } + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); + // Project card $linkback = ''.$langs->trans("BackToList").''; @@ -849,7 +870,11 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third $linktotasks .= dolGetButtonTitle($langs->trans('ViewGantt'), '', 'fa fa-stream imgforviewmode', DOL_URL_ROOT.'/projet/ganttview.php?id='.$object->id.'&withproject=1', '', 1, array('morecss'=>'reposition marginleftonly')); //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'generic', 0, '', '', 0, 1); - print load_fiche_titre($title, $linktotasks.'   '.$linktocreatetask, 'projecttask'); + print load_fiche_titre($title, $linktotasks.'   '.$linktocreatetask, 'projecttask', '', '', '', $massactionbutton); + + $objecttmp = new Task($db); + $trackid = 'task'.$taskstatic->id; + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; // Get list of tasks in tasksarray and taskarrayfiltered // We need all tasks (even not limited to a user because a task to user can have a parent that is not affected to him). @@ -884,6 +909,11 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third print '
'; } + // Show the massaction checkboxes only when this page is not opend from the Extended POS + if ($massactionbutton && $contextpage != 'poslist') { + $selectedfields = $form->showCheckAddButtons('checkforselect', 1); + } + print '
'; print ''; @@ -994,6 +1024,8 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + print ''; + // Action column print ''; print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; @@ -1069,7 +1102,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third if (count($tasksarray) > 0) { // Show all lines in taskarray (recursive function to go down on tree) $j = 0; $level = 0; - $nboftaskshown = projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole, $object->id, 1, $object->id, $filterprogresscalc, ($object->usage_bill_time ? 1 : 0), $arrayfields); + $nboftaskshown = projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole, $object->id, 1, $object->id, $filterprogresscalc, ($object->usage_bill_time ? 1 : 0), $arrayfields, $arrayofselected); } else { $colspan = 10; if ($object->usage_bill_time) { diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 72c5eb25874..bc4c8770f0f 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -580,6 +580,9 @@ llxHeader('', $title, $help_url); $arrayofselected = is_array($toselect) ? $toselect : array(); $param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -697,7 +700,11 @@ if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'pr } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); -$newcardbutton = dolGetButtonTitle($langs->trans('NewTask'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/tasks.php?action=create', '', $user->rights->projet->creer); +$newcardbutton = ''; + +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('NewTask'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/tasks.php?action=create', '', $user->rights->projet->creer); print ''."\n"; if ($optioncss != '') { @@ -712,6 +719,8 @@ if (!empty($type)) { print ''; } print ''; +print ''; + // Show description of content $texthelp = ''; @@ -1121,6 +1130,8 @@ while ($i < $imaxinloop) { print '
'; } // Output Kanban + $object->fk_statut = $projectstatic->getLibStatut(1); + $object->fk_project = $projectstatic->getNomUrl(1, 'task'); print $object->getKanbanView(''); if ($i == ($imaxinloop - 1)) { print '
'; diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 8b19c8c0519..fccf9d2ffe1 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -467,7 +467,7 @@ if ($id > 0 || !empty($ref)) { // Task parent print ''; // Date start diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 94ed0edaffd..3c8597cd862 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -88,6 +88,10 @@ $search_company = GETPOST('$search_company', 'alpha'); $search_company_alias = GETPOST('$search_company_alias', 'alpha'); $search_project_ref = GETPOST('$search_project_ref', 'alpha'); $search_project_label = GETPOST('$search_project_label', 'alpha'); +$search_timespent_starthour = GETPOSTINT("search_timespent_duration_starthour"); +$search_timespent_startmin = GETPOSTINT("search_timespent_duration_startmin"); +$search_timespent_endhour = GETPOSTINT("search_timespent_duration_endhour"); +$search_timespent_endmin = GETPOSTINT("search_timespent_duration_endmin"); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -196,6 +200,10 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_product_ref = ''; $toselect = array(); $search_array_options = array(); + $search_timespent_starthour = ''; + $search_timespent_startmin = ''; + $search_timespent_endhour = ''; + $search_timespent_endmin = ''; $action = ''; } @@ -1337,6 +1345,18 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if ($search_date_endyear) { $param .= '&search_date_endyear='.urlencode($search_date_endyear); } + if ($search_timespent_starthour) { + $param .= '&search_timespent_duration_starthour='.urlencode($search_timespent_starthour); + } + if ($search_timespent_startmin) { + $param .= '&search_timespent_duration_startmin='.urlencode($search_timespent_startmin); + } + if ($search_timespent_endhour) { + $param .= '&search_timespent_duration_endhour='.urlencode($search_timespent_endhour); + } + if ($search_timespent_endmin) { + $param .= '&search_timespent_duration_endmin='.urlencode($search_timespent_endmin); + } /* // Add $param from extra fields @@ -1609,6 +1629,20 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $sql .= " AND t.task_date <= '".$db->idate($search_date_end)."'"; } + if (!empty($arrayfields['t.task_duration']['checked'])) { + if ($search_timespent_starthour || $search_timespent_startmin) { + $timespent_duration_start = $search_timespent_starthour * 60 * 60; // We store duration in seconds + $timespent_duration_start += ($search_timespent_startmin ? $search_timespent_startmin : 0) * 60; // We store duration in seconds + $sql .= " AND t.task_duration >= " . $timespent_duration_start; + } + + if ($search_timespent_endhour || $search_timespent_endmin) { + $timespent_duration_end = $search_timespent_endhour * 60 * 60; // We store duration in seconds + $timespent_duration_end += ($search_timespent_endmin ? $search_timespent_endmin : 0) * 60; // We store duration in seconds + $sql .= " AND t.task_duration <= " . $timespent_duration_end; + } + } + $sql .= dolSqlDateFilter('t.task_datehour', $search_day, $search_month, $search_year); // Add where from hooks @@ -1877,7 +1911,26 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser } // Duration if (!empty($arrayfields['t.task_duration']['checked'])) { - print ''; + // Duration - Time spent + print ''; } // Product if (!empty($arrayfields['t.fk_product']['checked'])) { diff --git a/htdocs/public/error-401.php b/htdocs/public/error-401.php index 3d453cd30e5..a160535ff10 100644 --- a/htdocs/public/error-401.php +++ b/htdocs/public/error-401.php @@ -20,6 +20,11 @@
Sorry. You are not allowed to access this resource. +
+
+ + No esta autorizado para acceder a este recurso. +
diff --git a/htdocs/public/error-404.php b/htdocs/public/error-404.php index c964e49cd85..84832100026 100644 --- a/htdocs/public/error-404.php +++ b/htdocs/public/error-404.php @@ -20,6 +20,10 @@
You requested a website or a page that does not exists. +
+
+ la pagina o el recurso solicitado no existe. +
diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index c0758c4a64d..943280d6e2d 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -46,9 +46,6 @@ if (!defined('NOLOGIN')) { if (!defined('NOCSRFCHECK')) { define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. } -if (!defined('NOIPCHECK')) { - define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -} if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } @@ -561,7 +558,7 @@ if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEW if (jQuery("#morphy").val() == \'mor\') { jQuery("#trcompany").show(); } - }; + } initmorphy(); jQuery("#morphy").change(function() { initmorphy(); diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php index de6b27cba90..c47bbd7f734 100644 --- a/htdocs/public/onlinesign/newonlinesign.php +++ b/htdocs/public/onlinesign/newonlinesign.php @@ -549,6 +549,8 @@ if ($action == "dosign" && empty($cancel)) { $("#signbutton").attr("disabled",false); if(!$._data($("#signbutton")[0], "events")){ $("#signbutton").on("click",function(){ + console.log("We click on button sign"); + $("#signbutton").val(\''.dol_escape_js($langs->transnoentities('PleaseBePatient')).'\'); var signature = $("#signature").jSignature("getData", "image"); $.ajax({ type: "POST", diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 79104817e77..4f2b91a51e7 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -281,15 +281,9 @@ if ((empty($paymentmethod) || $paymentmethod == 'stripe') && isModEnabled('strip } // Initialize $validpaymentmethod +// The list can be complete by the hook 'doValidatePayment' executed inside getValidOnlinePaymentMethods() $validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod); -// This hook is used to push to $validpaymentmethod by external payment modules (ie Payzen, ...) -$parameters = [ - 'paymentmethod' => $paymentmethod, - 'validpaymentmethod' => &$validpaymentmethod -]; -$reshook = $hookmanager->executeHooks('doValidatePayment', $parameters, $object, $action); - // Check security token $tmpsource = $source; if ($tmpsource == 'membersubscription') { @@ -1039,6 +1033,7 @@ if ($source == 'order') { $amount = price2num($amount); } + $tag = ''; if (GETPOST('fulltag', 'alpha')) { $fulltag = GETPOST('fulltag', 'alpha'); } else { @@ -2395,7 +2390,7 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme color: '#fa755a', iconColor: '#fa755a' } - }; + } var cardElement = elements.create('card', {style: style}); @@ -2435,7 +2430,7 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme ?> var cardButton = document.getElementById('buttontopay'); var clientSecret = cardButton.dataset.secret; - var options = { clientSecret: clientSecret,}; + var options = { clientSecret: clientSecret }; // Create an instance of Elements var elements = stripe.elements(options); @@ -2465,7 +2460,7 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme color: '#fa755a', iconColor: '#fa755a' } - }; + } setDefaultLang($mysoc->default_lang); $companylangs->loadLangs(array('main', 'members', 'bills', 'paypal', 'paybox')); - $from = $conf->global->MAILING_EMAIL_FROM; + $from = !empty($conf->global->MAILING_EMAIL_FROM) ? $conf->global->MAILING_EMAIL_FROM : getDolGlobalString("MAIN_MAIL_EMAIL_FROM"); $sendto = $sendemail; $urlback = $_SERVER["REQUEST_URI"]; diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 6d50d1c8c76..4a13de1ef7f 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -54,13 +54,14 @@ if (is_numeric($entity)) { require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; -require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; - if (isModEnabled('paypal')) { require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php'; } +// Hook to be used by external payment modules (ie Payzen, ...) +include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; +$hookmanager = new HookManager($db); +$hookmanager->initHooks(array('newpayment')); $langs->loadLangs(array("main", "other", "dict", "bills", "companies", "paybox", "paypal")); @@ -337,6 +338,16 @@ if (isModEnabled('stripe')) { } } +// Check status of the object to verify if it is paid by external payment modules +$action = ''; +$parameters = [ + 'paymentmethod' => $paymentmethod, +]; +$reshook = $hookmanager->executeHooks('isPaymentOK', $parameters, $object, $action); +if ($reshook >= 0) { + $ispaymentok = $hookmanager->resArray['ispaymentok']; +} + // If data not provided from back url, search them into the session env if (empty($ipaddress)) { @@ -1142,6 +1153,8 @@ if ($ispaymentok) { // (we need first that the donation module is able to generate a pdf document for the cerfa with pre filled content) } elseif (array_key_exists('ATT', $tmptag) && $tmptag['ATT'] > 0) { // Record payment for registration to an event for an attendee + require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; + require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $object = new Facture($db); $result = $object->fetch($ref); @@ -1314,7 +1327,9 @@ if ($ispaymentok) { if ($attendeetovalidate->email_company && $attendeetovalidate->email_company != $thirdparty->email) { $cc = ($cc ? ', ' : '').$attendeetovalidate->email_company; } - $from = $conf->global->MAILING_EMAIL_FROM; + + $from = !empty($conf->global->MAILING_EMAIL_FROM) ? $conf->global->MAILING_EMAIL_FROM : getDolGlobalString("MAIN_MAIL_EMAIL_FROM"); + $urlback = $_SERVER["REQUEST_URI"]; $ishtml = dol_textishtml($texttosend); // May contain urls @@ -1355,6 +1370,8 @@ if ($ispaymentok) { } } elseif (array_key_exists('BOO', $tmptag) && $tmptag['BOO'] > 0) { // Record payment for booth or conference + require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; + require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $object = new Facture($db); $result = $object->fetch($ref); @@ -1461,6 +1478,8 @@ if ($ispaymentok) { if (!$error) { // Putting the booth to "suggested" state + require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; + require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; $booth = new ConferenceOrBooth($db); $resultbooth = $booth->fetch((int) $tmptag['BOO']); if ($resultbooth < 0) { @@ -1611,7 +1630,7 @@ if ($ispaymentok) { $companylangs->loadLangs(array('main', 'members', 'bills', 'paypal', 'paybox')); $sendto = $sendemail; - $from = $conf->global->MAILING_EMAIL_FROM; + $from = !empty($conf->global->MAILING_EMAIL_FROM) ? $conf->global->MAILING_EMAIL_FROM : getDolGlobalString("MAIN_MAIL_EMAIL_FROM"); // Define $urlwithroot $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file @@ -1739,7 +1758,7 @@ if ($ispaymentok) { $companylangs->loadLangs(array('main', 'members', 'bills', 'paypal', 'paybox')); $sendto = $sendemail; - $from = $conf->global->MAILING_EMAIL_FROM; + $from = !empty($conf->global->MAILING_EMAIL_FROM) ? $conf->global->MAILING_EMAIL_FROM : getDolGlobalString("MAIN_MAIL_EMAIL_FROM"); // Define $urlwithroot $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file diff --git a/htdocs/public/recruitment/index.php b/htdocs/public/recruitment/index.php index 23a180b9a7b..4f82139656c 100644 --- a/htdocs/public/recruitment/index.php +++ b/htdocs/public/recruitment/index.php @@ -252,7 +252,7 @@ if (is_array($results)) { } } print ''; - print $tmpuser->getFullName(-1); + print $tmpuser->getFullName($langs); print '   '.dol_print_email($emailforcontact, 0, 0, 1, 0, 0, 'envelope'); print ''; print '
'; diff --git a/htdocs/public/recruitment/view.php b/htdocs/public/recruitment/view.php index 57cb82d9b08..3626693ce89 100644 --- a/htdocs/public/recruitment/view.php +++ b/htdocs/public/recruitment/view.php @@ -159,6 +159,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; * View */ +$now = dol_now(); + $head = ''; if (!empty($conf->global->MAIN_RECRUITMENT_CSS_URL)) { $head = ''."\n"; @@ -201,7 +203,7 @@ $paramlogo = 'ONLINE_RECRUITMENT_LOGO_'.$suffix; if (!empty($conf->global->$paramlogo)) { $logosmall = $conf->global->$paramlogo; } elseif (!empty($conf->global->ONLINE_RECRUITMENT_LOGO)) { - $logosmall = $conf->global->ONLINE_RECRUITMENT_LOGO_; + $logosmall = $conf->global->ONLINE_RECRUITMENT_LOGO; } //print ''."\n"; // Define urllogo @@ -221,7 +223,7 @@ if ($urllogo) { if (!empty($mysoc->url)) { print ''; } - print ''; + print ''; if (!empty($mysoc->url)) { print ''; } @@ -234,7 +236,7 @@ if ($urllogo) { if (!empty($conf->global->RECRUITMENT_IMAGE_PUBLIC_INTERFACE)) { print '
'; - print ''; + print ''; print '
'; } diff --git a/htdocs/public/users/view.php b/htdocs/public/users/view.php new file mode 100644 index 00000000000..d63a2a66eee --- /dev/null +++ b/htdocs/public/users/view.php @@ -0,0 +1,464 @@ + + * + * 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/public/users/view.php + * \ingroup user + * \brief Public file to user profile + */ + +if (!defined('NOLOGIN')) { + define("NOLOGIN", 1); // This means this output page does not require to be logged. +} +if (!defined('NOCSRFCHECK')) { + define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. +} +if (!defined('NOIPCHECK')) { + define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +} +if (!defined('NOBROWSERNOTIF')) { + define('NOBROWSERNOTIF', '1'); +} + +// Load Dolibarr environment +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/vcard.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array("companies", "other", "recruitment")); + +// Get parameters +$action = GETPOST('action', 'aZ09'); +$mode = GETPOST('mode', 'aZ09'); +$cancel = GETPOST('cancel', 'alpha'); +$backtopage = ''; + +$id = GETPOST('id', 'int'); +$securekey = GETPOST('securekey', 'alpha'); +$suffix = GETPOST('suffix'); + +$object = new User($db); +$object->fetch($id, '', '', 1); + +// Define $urlwithroot +//$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); +//$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file +$urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost. + +// Security check +global $dolibarr_main_instance_unique_id; +$encodedsecurekey = dol_hash($dolibarr_main_instance_unique_id.'uservirtualcard'.$object->id.'-'.$object->login, 'md5'); +if ($encodedsecurekey != $securekey) { + httponly_accessforbidden('Bad value for securitykey or public profile not enabled'); +} + +if (!getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) { + httponly_accessforbidden('Bad value for securitykey or public profile not enabled'); +} + + +/* + * Actions + */ + +if ($cancel) { + if (!empty($backtopage)) { + header("Location: ".$backtopage); + exit; + } + $action = 'view'; +} + + +/* + * View + */ + +$form = new Form($db); +$v = new vCard(); + +$company = $mysoc; + +$modulepart = 'userphotopublic'; +$dir = $conf->user->dir_output; + +// Show logo (search order: logo defined by ONLINE_SIGN_LOGO_suffix, then ONLINE_SIGN_LOGO_, then small company logo, large company logo, theme logo, common logo) +// Define logo and logosmall +$logo = ''; +$logosmall = ''; +if (!empty($object->photo)) { + if (dolIsAllowedForPreview($object->photo)) { + $logosmall = get_exdir(0, 0, 0, 0, $object, 'user').'photos/'.getImageFileNameForSize($object->photo, '_small'); + $logo = get_exdir(0, 0, 0, 0, $object, 'user').'photos/'.$object->photo; + //$originalfile = get_exdir(0, 0, 0, 0, $object, 'user').'photos/'.$object->photo; + } +} +//print ''."\n"; +// Define urllogo +$urllogo = ''; +$urllogofull = ''; +if (!empty($logosmall) && is_readable($dir.'/'.$logosmall)) { + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.($conf->entity > 1 ? '&entity='.$conf->entity : '').'&securekey='.urlencode($securekey).'&file='.urlencode($logosmall); + $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart='.$modulepart.($conf->entity > 1 ? '&entity='.$conf->entity : '').'&securekey='.urlencode($securekey).'&file='.urlencode($logosmall); +} elseif (!empty($logo) && is_readable($dir.'/'.$logo)) { + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.($conf->entity > 1 ? '&entity='.$conf->entity : '').'&securekey='.urlencode($securekey).'&file='.urlencode($logo); + $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart='.$modulepart.($conf->entity > 1 ? '&entity='.$conf->entity : '').'&securekey='.urlencode($securekey).'&file='.urlencode($logo); +} + +// Clean data we don't want on public page +if (getDolUserInt('USER_PUBLIC_HIDE_PHOTO', 0, $object)) { + $logo = ''; + $logosmall = ''; + $urllogo = ''; + $urllogofull = ''; +} +if (getDolUserInt('USER_PUBLIC_HIDE_JOBPOSITION', 0, $object)) { + $object->job = ''; +} +if (getDolUserInt('USER_PUBLIC_HIDE_EMAIL', 0, $object)) { + $object->email = ''; +} +if (getDolUserInt('USER_PUBLIC_HIDE_EMAIL', 0, $object)) { + $object->job = ''; +} +if (getDolUserInt('USER_PUBLIC_HIDE_OFFICE_PHONE', 0, $object)) { + $object->office_phone = ''; +} +if (getDolUserInt('USER_PUBLIC_HIDE_OFFICE_FAX', 0, $object)) { + $object->office_fax = ''; +} +if (getDolUserInt('USER_PUBLIC_HIDE_USER_MOBILE', 0, $object)) { + $object->user_mobile = ''; +} +if (getDolUserInt('USER_PUBLIC_HIDE_BIRTH', 0, $object)) { + $object->birth = ''; +} +if (getDolUserInt('USER_PUBLIC_HIDE_SOCIALNETWORKS', 0, $object)) { + $object->socialnetworks = ''; +} +if (getDolUserInt('USER_PUBLIC_HIDE_ADDRESS', 0, $object)) { + $object->address = ''; + $object->town = ''; + $object->zip = ''; + $object->state = ''; + $object->country = ''; +} +if (getDolUserInt('USER_PUBLIC_HIDE_COMPANY', 0, $object)) { + $company = null; +} + + +// Output vcard +if ($mode == 'vcard') { + // We create VCard + $output = $v->buildVCardString($object, $company, $langs, $urllogofull); + + $filename = trim(urldecode($v->getFileName())); // "Nom prenom.vcf" + $filenameurlencoded = dol_sanitizeFileName(urlencode($filename)); + //$filename = dol_sanitizeFileName($filename); + + top_httphead('text/vcard; name="'.$filename.'"'); + + header("Content-Disposition: attachment; filename=\"".$filename."\""); + header("Content-Length: ".dol_strlen($output)); + header("Connection: close"); + + print $output; + + $db->close(); + + exit; +} + +$head = ''; +if (!empty($conf->global->MAIN_USER_PROFILE_CSS_URL)) { + $head = ''."\n"; +} + +$conf->dol_hide_topmenu = 1; +$conf->dol_hide_leftmenu = 1; + +if (!getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) { + $langs->load("errors"); + print '
'.$langs->trans('ErrorPublicInterfaceNotEnabled').'
'; + $db->close(); + exit(); +} + +$arrayofjs = array(); +$arrayofcss = array(); + +$replacemainarea = (empty($conf->dol_hide_leftmenu) ? '
' : '').'
'; +llxHeader($head, $langs->trans("UserProfile").' '.$object->getFullName($langs), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea, 1, 1); + +print ''."\n"; +print '
'."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''; +print "\n"; +print ''."\n"; + +// Output html code for logo +print '
'; +print '
'; + +// Name +print '
'.$object->getFullName($langs).'
'; +// User position +if ($object->job && !getDolUserInt('USER_PUBLIC_HIDE_JOBPOSITION', 0, $object)) { + print '
'; + print dol_escape_htmltag($object->job); + print '
'; +} + + +print '
'; +/*if (empty($conf->global->MAIN_HIDE_POWERED_BY)) { + print ''; +}*/ +print '
'; + + +if (!empty($conf->global->USER_IMAGE_PUBLIC_INTERFACE)) { + print '
'; + print ''; + print '
'; +} + +$urlforqrcode = $object->getOnlineVirtualCardUrl('vcard'); + +$socialnetworksdict = getArrayOfSocialNetworks(); + + + +// Show barcode +$showbarcode = GETPOST('nobarcode') ? 0 : 1; +if ($showbarcode) { + $qrcodecontent = $output = $v->buildVCardString($object, $company, $langs); + + print '
'; + print '
'; + print ''; + print '
'; + print '
'; +} + + +// Me +// Show photo +if ($urllogo) { + print ''; +} + + +$usersection = ''; + +// User email +if ($object->email && !getDolUserInt('USER_PUBLIC_HIDE_EMAIL', 0, $object)) { + $usersection .= '
'; + $usersection .= dol_print_email($object->email, 0, 0, 1, 0, 1, 1); + $usersection .= '
'; +} + +// User url +if ($object->url && !getDolUserInt('USER_PUBLIC_HIDE_URL', 0, $object)) { + $usersection .= '
'; + $usersection .= img_picto('', 'globe', 'class="pictofixedwidth"'); + $usersection .= dol_print_url($object->url, '_blank', 0, 0, ''); + $usersection .= '
'; +} + +// User phone +if ($object->office_phone && !getDolUserInt('USER_PUBLIC_HIDE_OFFICE_PHONE', 0, $object)) { + $usersection .= '
'; + $usersection .= img_picto('', 'phone', 'class="pictofixedwidth"'); + $usersection .= dol_print_phone($object->office_phone, $object->country_code, 0, $mysoc->id, 'tel', ' ', 0, ''); + $usersection .= '
'; +} +if ($object->office_fax && !getDolUserInt('USER_PUBLIC_HIDE_OFFICE_FAX', 0, $object)) { + $usersection .= '
'; + $usersection .= img_picto('', 'phoning_fax', 'class="pictofixedwidth"'); + $usersection .= dol_print_phone($object->office_fax, $object->country_code, 0, $mysoc->id, 'fax', ' ', 0, ''); + $usersection .= '
'; +} +if ($object->user_mobile && !getDolUserInt('USER_PUBLIC_HIDE_USER_MOBILE', 0, $object)) { + $usersection .= '
'; + $usersection .= img_picto('', 'phone', 'class="pictofixedwidth"'); + $usersection .= dol_print_phone($object->user_mobile, $object->country_code, 0, $mysoc->id, 'tel', ' ', 0, ''); + $usersection .= '
'; +} + +// Social networks +if (!empty($object->socialnetworks) && is_array($object->socialnetworks) && count($object->socialnetworks) > 0) { + if (!getDolUserInt('USER_PUBLIC_HIDE_SOCIALNETWORKS', 0, $object)) { + foreach ($object->socialnetworks as $key => $value) { + if ($value) { + $usersection .= '
'.dol_print_socialnetworks($value, 0, $mysoc->id, $key, $socialnetworksdict).'
'; + } + } + } +} + +if ($usersection) { + print '
 '; $searchpicto = $form->showFilterButtons(); @@ -1062,6 +1094,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; + print '
'.$langs->trans("ChildOfProjectTask").''; - print $formother->selectProjectTasks($object->fk_task_parent, $projectstatic->id, 'task_parent', ($user->admin ? 0 : 1), 0, 0, 0, $object->id); + $formother->selectProjectTasks($object->fk_task_parent, $projectstatic->id, 'task_parent', ($user->admin ? 0 : 1), 0, 0, 0, $object->id); print '
'; + + $durationtouse_start = 0; + if ($search_timespent_starthour || $search_timespent_startmin) { + $durationtouse_start = ($search_timespent_starthour * 3600 + $search_timespent_startmin * 60); + } + print '
'.$langs->trans('from').' '; + $form->select_duration('search_timespent_duration_start', $durationtouse_start, 0, 'text'); + print '
'; + + $durationtouse_end = 0; + if ($search_timespent_endhour || $search_timespent_endmin) { + $durationtouse_end = ($search_timespent_endhour * 3600 + $search_timespent_endmin * 60); + } + print '
'.$langs->trans('at').' '; + $form->select_duration('search_timespent_duration_end', $durationtouse_end, 0, 'text'); + print '
'; + + print '
'."\n"; + + // Output payment summary form + print ''."\n"; + + print '
'; + + print '
'; + + print $usersection; + + print '
'."\n"; + print "\n"; + + print '
'."\n"; +} + + +if (!getDolUserInt('USER_PUBLIC_HIDE_COMPANY', 0, $object)) { + $companysection = ''; + + if ($mysoc->email) { + $companysection .= '
'; + $companysection .= img_picto('', 'email', 'class="pictofixedwidth"'); + $companysection .= dol_print_email($mysoc->email, 0, 0, 1); + $companysection .= '
'; + } + + if ($mysoc->url) { + $companysection .= '
'; + $companysection .= img_picto('', 'globe', 'class="pictofixedwidth"'); + $companysection .= dol_print_url($mysoc->url, '_blank', 0, 0, ''); + $companysection .= '
'; + } + + if ($mysoc->phone) { + $companysection .= '
'; + $companysection .= img_picto('', 'phone', 'class="pictofixedwidth"'); + $companysection .= dol_print_phone($mysoc->phone, $mysoc->country_code, 0, $mysoc->id, 'tel', ' ', 0, ''); + $companysection .= '
'; + } + if ($mysoc->fax) { + $companysection .= '
'; + $companysection .= img_picto('', 'phoning_fax', 'class="pictofixedwidth"'); + $companysection .= dol_print_phone($mysoc->fax, $mysoc->country_code, 0, $mysoc->id, 'fax', ' ', 0, ''); + $companysection .= '
'; + } + + // Social networks + if (!empty($mysoc->socialnetworks) && is_array($mysoc->socialnetworks) && count($mysoc->socialnetworks) > 0) { + foreach ($mysoc->socialnetworks as $key => $value) { + if ($value) { + $companysection .= '
'.dol_print_socialnetworks($value, 0, $mysoc->id, $key, $socialnetworksdict).'
'; + } + } + } + + // Show logo (search order: logo defined by ONLINE_SIGN_LOGO_suffix, then ONLINE_SIGN_LOGO_, then small company logo, large company logo, theme logo, common logo) + // Define logo and logosmall + $logosmall = $mysoc->logo_squarred_small ? $mysoc->logo_squarred_small : $mysoc->logo_small; + $logo = $mysoc->logo_squarred ? $mysoc->logo_squarred : $mysoc->logo; + $paramlogo = 'ONLINE_USER_LOGO_'.$suffix; + if (!empty($conf->global->$paramlogo)) { + $logosmall = $conf->global->$paramlogo; + } elseif (!empty($conf->global->ONLINE_USER_LOGO)) { + $logosmall = $conf->global->ONLINE_USER_LOGO; + } + //print ''."\n"; + // Define urllogo + $urllogo = ''; + $urllogofull = ''; + if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) { + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany'.($conf->entity > 1 ? '&entity='.$conf->entity : '').'&file='.urlencode('logos/thumbs/'.$logosmall); + $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany'.($conf->entity > 1 ? '&entity='.$conf->entity : '').'&file='.urlencode('logos/thumbs/'.$logosmall); + } elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) { + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany'.($conf->entity > 1 ? '&entity='.$conf->entity : '').'&file='.urlencode('logos/'.$logo); + $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany'.($conf->entity > 1 ? '&entity='.$conf->entity : '').'&file='.urlencode('logos/'.$logo); + } + // Output html code for logo + if ($urllogo) { + print '
'; + if (!empty($mysoc->url)) { + print ''; + } + print ''; + if (!empty($mysoc->url)) { + print ''; + } + print '
'; + } + print ''."\n"; + + // Output payment summary form + print ''."\n"; + + print '
'; + + print '
'; + + // Add company info + if ($mysoc->name) { + print '
'; + print $mysoc->name; + print '
'; + print '
'; + } + + print $companysection; + + print '
'."\n"; + print "\n"; + + print '
'."\n"; +} + + +// Description +$text = getDolUserString('USER_PUBLIC_MORE', '', $object); +print $text; + + +print ''."\n"; +print '
'."\n"; +print '
'; + + +//htmlPrintOnlinePaymentFooter($mysoc, $langs); + +print ''; + +llxFooter('', 'public'); + +$db->close(); diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 96b275bfb26..e9a89691c88 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -140,27 +140,6 @@ class Reception extends CommonObject public function __construct($db) { $this->db = $db; - - // List of long language codes for status - $this->statuts = array(); - $this->statuts[-1] = 'StatusReceptionCanceled'; - $this->statuts[0] = 'StatusReceptionDraft'; - // product to receive if stock increase is on close or already received if stock increase is on validation - $this->statuts[1] = 'StatusReceptionValidated'; - if (getDolGlobalInt("STOCK_CALCULATE_ON_RECEPTION")) { - $this->statuts[1] = 'StatusReceptionValidatedReceived'; - } - if (getDolGlobalInt("STOCK_CALCULATE_ON_RECEPTION_CLOSE")) { - $this->statuts[1] = 'StatusReceptionValidatedToReceive'; - } - $this->statuts[2] = 'StatusReceptionProcessed'; - - // List of short language codes for status - $this->statuts_short = array(); - $this->statuts_short[-1] = 'StatusReceptionCanceledShort'; - $this->statuts_short[0] = 'StatusReceptionDraftShort'; - $this->statuts_short[1] = 'StatusReceptionValidatedShort'; - $this->statuts_short[2] = 'StatusReceptionProcessedShort'; } /** @@ -1317,8 +1296,27 @@ class Reception extends CommonObject // phpcs:enable global $langs; - $labelStatus = $langs->transnoentitiesnoconv($this->statuts[$status]); - $labelStatusShort = $langs->transnoentitiesnoconv($this->statuts_short[$status]); + // List of long language codes for status + $this->labelStatus[-1] = 'StatusReceptionCanceled'; + $this->labelStatus[0] = 'StatusReceptionDraft'; + // product to receive if stock increase is on close or already received if stock increase is on validation + $this->labelStatus[1] = 'StatusReceptionValidated'; + if (getDolGlobalInt("STOCK_CALCULATE_ON_RECEPTION")) { + $this->labelStatus[1] = 'StatusReceptionValidatedReceived'; + } + if (getDolGlobalInt("STOCK_CALCULATE_ON_RECEPTION_CLOSE")) { + $this->labelStatus[1] = 'StatusReceptionValidatedToReceive'; + } + $this->labelStatus[2] = 'StatusReceptionProcessed'; + + // List of short language codes for status + $this->labelStatusShort[-1] = 'StatusReceptionCanceledShort'; + $this->labelStatusShort[0] = 'StatusReceptionDraftShort'; + $this->labelStatusShort[1] = 'StatusReceptionValidatedShort'; + $this->labelStatusShort[2] = 'StatusReceptionProcessedShort'; + + $labelStatus = $langs->transnoentitiesnoconv($this->labelStatus[$status]); + $labelStatusShort = $langs->transnoentitiesnoconv($this->labelStatusShort[$status]); $statusType = 'status'.$status; if ($status == self::STATUS_VALIDATED) { @@ -1348,25 +1346,6 @@ class Reception extends CommonObject dol_syslog(get_class($this)."::initAsSpecimen"); - // Load array of products prodids - $num_prods = 0; - $prodids = array(); - $sql = "SELECT rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."product"; - $sql .= " WHERE entity IN (".getEntity('product').")"; - $sql .= $this->db->plimit(100); - - $resql = $this->db->query($sql); - if ($resql) { - $num_prods = $this->db->num_rows($resql); - $i = 0; - while ($i < $num_prods) { - $i++; - $row = $this->db->fetch_row($resql); - $prodids[$i] = $row[0]; - } - } - $order = new CommandeFournisseur($this->db); $order->initAsSpecimen(); diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index d6e39e64eeb..42deedd5419 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -959,8 +959,8 @@ if (!empty($arrayfields['e.tms']['checked'])) { } // Status if (!empty($arrayfields['e.fk_statut']['checked'])) { - print ''; - print $form->selectarray('search_status', array('0'=>$langs->trans('StatusReceptionDraftShort'), '1'=>$langs->trans('StatusReceptionValidatedShort'), '2'=>$langs->trans('StatusReceptionProcessedShort')), $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status onrightofpage'); + print ''; + print $form->selectarray('search_status', array('0'=>$langs->trans('StatusReceptionDraftShort'), '1'=>$langs->trans('StatusReceptionValidatedShort'), '2'=>$langs->trans('StatusReceptionProcessedShort')), $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage'); print ''; } // Status billed diff --git a/htdocs/reception/tpl/linkedobjectblock.tpl.php b/htdocs/reception/tpl/linkedobjectblock.tpl.php index 009534b91b5..341e30e3784 100644 --- a/htdocs/reception/tpl/linkedobjectblock.tpl.php +++ b/htdocs/reception/tpl/linkedobjectblock.tpl.php @@ -50,12 +50,12 @@ foreach ($linkedObjectBlock as $key => $objectlink) { } ?> - trans("Reception"); ?> + trans("Reception"); ?> global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { print ' - getNomUrl(1); ?> + getNomUrl(1); ?> ref_supplier); ?> date_delivery, 'day'); ?> entity); + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { + $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); } if (!($res > 0)) { diff --git a/htdocs/recruitment/admin/setup_candidatures.php b/htdocs/recruitment/admin/setup_candidatures.php index c5f067d4d94..1da5d698645 100644 --- a/htdocs/recruitment/admin/setup_candidatures.php +++ b/htdocs/recruitment/admin/setup_candidatures.php @@ -90,11 +90,11 @@ $setupnotempty = 0; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstcand = GETPOST('maskconstcand', 'alpha'); - $maskcand = GETPOST('maskcand', 'alpha'); + $maskconst = GETPOST('maskconstcand', 'aZ09'); + $maskvalue = GETPOST('maskcand', 'alpha'); - if ($maskconstcand) { - $res = dolibarr_set_const($db, $maskconstcand, $maskcand, 'chaine', 0, '', $conf->entity); + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { + $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); } if (!($res > 0)) { diff --git a/htdocs/recruitment/class/recruitmentcandidature.class.php b/htdocs/recruitment/class/recruitmentcandidature.class.php index 2ece5dbe217..1690f13da56 100644 --- a/htdocs/recruitment/class/recruitmentcandidature.class.php +++ b/htdocs/recruitment/class/recruitmentcandidature.class.php @@ -894,8 +894,8 @@ class RecruitmentCandidature extends CommonObject $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_recruitmentcandidature = '.((int) $this->id))); if (is_numeric($result)) { - $this->error = $this->error; - $this->errors = $this->errors; + $this->error = $objectline->error; + $this->errors = $objectline->errors; return $result; } else { $this->lines = $result; diff --git a/htdocs/recruitment/class/recruitmentjobposition.class.php b/htdocs/recruitment/class/recruitmentjobposition.class.php index 7a9d077f910..fb34e33376e 100644 --- a/htdocs/recruitment/class/recruitmentjobposition.class.php +++ b/htdocs/recruitment/class/recruitmentjobposition.class.php @@ -124,7 +124,7 @@ class RecruitmentJobPosition extends CommonObject 'email_recruiter' => array('type'=>'varchar(255)', 'label'=>'EmailRecruiter', 'enabled'=>'1', 'position'=>54, 'notnull'=>0, 'visible'=>-1, 'help'=>'ToUseAGenericEmail', 'picto'=>'email'), 'fk_user_supervisor' => array('type'=>'integer:User:user/class/user.class.php:t.statut = 1', 'label'=>'FutureManager', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1, 'foreignkey'=>'user.rowid', 'css'=>'maxwidth500', 'csslist'=>'tdoverflowmax150', 'picto'=>'user'), 'fk_establishment' => array('type'=>'integer:Establishment:hrm/class/establishment.class.php', 'label'=>'Establishment', 'enabled'=>'$conf->hrm->enabled', 'position'=>56, 'notnull'=>0, 'visible'=>-1, 'foreignkey'=>'establishment.rowid',), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'WorkPlace', 'enabled'=>'$conf->societe->enabled', 'position'=>57, 'notnull'=>-1, 'visible'=>-1, 'css'=>'maxwidth500', 'index'=>1, 'help'=>"IfJobIsLocatedAtAPartner", 'picto'=>'company'), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'WorkPlace', 'enabled'=>'isModEnabled("societe")', 'position'=>57, 'notnull'=>-1, 'visible'=>-1, 'css'=>'maxwidth500', 'index'=>1, 'help'=>"IfJobIsLocatedAtAPartner", 'picto'=>'company'), 'date_planned' => array('type'=>'date', 'label'=>'DateExpected', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>1,), 'remuneration_suggested' => array('type'=>'varchar(255)', 'label'=>'Remuneration', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>1,), 'description' => array('type'=>'html', 'label'=>'Description', 'enabled'=>'1', 'position'=>65, 'notnull'=>0, 'visible'=>3,), diff --git a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php index cfbf91463e8..147e8ec3519 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php @@ -264,7 +264,7 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename $newfile = basename($srctemplatepath); - $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile); $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); $newfiletmp = $objectref.'_'.$newfiletmp; diff --git a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php index 1a58085d8c9..61c2eb3ff20 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php @@ -798,7 +798,7 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio /** * Show top header of page. * - * @param Tcpdf $pdf Object PDF + * @param TCPDF $pdf Object PDF * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output diff --git a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_advanced.php b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_advanced.php index 6ed0a027310..415ac3357eb 100644 --- a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_advanced.php +++ b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_advanced.php @@ -69,7 +69,7 @@ class mod_recruitmentcandidature_advanced extends ModeleNumRefRecruitmentCandida $texte .= ''; $texte .= ''; $texte .= ''; - $texte .= ''; + $texte .= '
'; $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("RecruitmentCandidature"), $langs->transnoentities("RecruitmentCandidature")); $tooltip .= $langs->trans("GenericMaskCodes2"); diff --git a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_advanced.php b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_advanced.php index a49a4714b24..be565486c3a 100644 --- a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_advanced.php +++ b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_advanced.php @@ -69,7 +69,7 @@ class mod_recruitmentjobposition_advanced extends ModeleNumRefRecruitmentJobPosi $texte .= ''; $texte .= ''; $texte .= ''; - $texte .= '
'; + $texte .= '
'; $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("RecruitmentJobPosition"), $langs->transnoentities("RecruitmentJobPosition")); $tooltip .= $langs->trans("GenericMaskCodes2"); diff --git a/htdocs/recruitment/recruitmentcandidature_agenda.php b/htdocs/recruitment/recruitmentcandidature_agenda.php index 7f82f0c067f..8a6c11caf1f 100644 --- a/htdocs/recruitment/recruitmentcandidature_agenda.php +++ b/htdocs/recruitment/recruitmentcandidature_agenda.php @@ -143,6 +143,7 @@ if ($object->id > 0) { $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; + $morehtmlref.= $object->getFullName('', 1); /* // Ref customer $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); diff --git a/htdocs/recruitment/recruitmentcandidature_card.php b/htdocs/recruitment/recruitmentcandidature_card.php index 2452c9e530b..7cf9fb47b56 100644 --- a/htdocs/recruitment/recruitmentcandidature_card.php +++ b/htdocs/recruitment/recruitmentcandidature_card.php @@ -426,6 +426,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; + $morehtmlref.= $object->getFullName('', 1); /* // Ref customer $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); diff --git a/htdocs/recruitment/recruitmentcandidature_document.php b/htdocs/recruitment/recruitmentcandidature_document.php index 3f08c770111..ed0cb115ea7 100644 --- a/htdocs/recruitment/recruitmentcandidature_document.php +++ b/htdocs/recruitment/recruitmentcandidature_document.php @@ -121,6 +121,7 @@ if ($object->id) { $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; + $morehtmlref.= $object->getFullName('', 1); /* // Ref customer $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); diff --git a/htdocs/recruitment/recruitmentcandidature_note.php b/htdocs/recruitment/recruitmentcandidature_note.php index 1649ab5ee5e..f04a22aaf1b 100644 --- a/htdocs/recruitment/recruitmentcandidature_note.php +++ b/htdocs/recruitment/recruitmentcandidature_note.php @@ -96,6 +96,7 @@ if ($id > 0 || !empty($ref)) { $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; + $morehtmlref.= $object->getFullName('', 1); /* // Ref customer $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); diff --git a/htdocs/recruitment/recruitmentjobposition_card.php b/htdocs/recruitment/recruitmentjobposition_card.php index d1ca4ef2db1..b33ce55808e 100644 --- a/htdocs/recruitment/recruitmentjobposition_card.php +++ b/htdocs/recruitment/recruitmentjobposition_card.php @@ -108,7 +108,7 @@ if (empty($reshook)) { if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { $backtopage = $backurlforlist; } else { - $backtopage = dol_buildpath('/recruitment/recruitmentjobposition_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); + $backtopage = dol_buildpath('/recruitment/recruitmentjobposition_card.php', 1).'?id='.((!empty($id) && $id > 0) ? $id : '__ID__'); } } } @@ -130,7 +130,7 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; if ($action == 'set_thirdparty' && $permissiontoadd) { - $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'RECRUITMENTJOBPOSITION_MODIFY'); + $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, $triggermodname); } if ($action == 'classin' && $permissiontoadd) { $object->setProject(GETPOST('projectid', 'int')); @@ -257,8 +257,6 @@ if (($id || $ref) && $action == 'edit') { // Part to show record if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { - $res = $object->fetch_optionals(); - $head = recruitmentjobpositionPrepareHead($object); print dol_get_fiche_head($head, 'card', $langs->trans("RecruitmentJobPosition"), -1, $object->picto); @@ -395,31 +393,27 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (empty($reshook)) { // Send if (empty($user->socid)) { - print ''.$langs->trans('SendMail').''."\n"; + print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init&token='.newToken().'#formmailbeforetitle'); } // Back to draft if ($object->status == $object::STATUS_VALIDATED) { if ($permissiontoadd) { - print ''.$langs->trans("SetToDraft").''; + print dolGetButtonAction('', $langs->trans('SetToDraft'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes&token='.newToken(), '', $permissiontoadd); } } // Modify - if ($permissiontoadd) { - print ''.$langs->trans("Modify").''."\n"; - } else { - print ''.$langs->trans('Modify').''."\n"; - } + print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd); // Validate if ($object->status == $object::STATUS_DRAFT) { if ($permissiontoadd) { if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) { - print ''.$langs->trans("Validate").''; + print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes&token='.newToken(), '', $permissiontoadd); } else { $langs->load("errors"); - print ''.$langs->trans("Validate").''; + print dolGetButtonAction($langs->trans("ErrorAddAtLeastOneLineFirst"), $langs->trans("Validate"), 'default', '#', '', 0); } } } @@ -442,9 +436,10 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea /* if ($permissiontoadd) { if ($object->status == $object::STATUS_ENABLED) { - print ''.$langs->trans("Disable").''."\n"; + print dolGetButtonAction('', $langs->trans('Disable'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=disable&token='.newToken(), '', $permissiontoadd); } else { - print ''.$langs->trans("Enable").''."\n"; + print dolGetButtonAction('', $langs->trans('Enable'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=enable&token='.newToken(), '', $permissiontoadd); + } } }*/ if ($permissiontoadd) { @@ -454,7 +449,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Delete - print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete); + $params = array(); + print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete, $params); } print '
'."\n"; } diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index 5c588b59c6b..3ee118d06c7 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -225,7 +225,7 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) { // Type print '
'; print ''; // Description diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 974407ff42d..975d4d16200 100644 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -381,6 +381,10 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->salaries- $object->paye = 0; $object->id = $object->ref = null; + if (GETPOST('amount', 'alphanohtml')) { + $object->amount = price2num(GETPOST('amount', 'alphanohtml'), 'MT', 2); + } + if (GETPOST('clone_label', 'alphanohtml')) { $object->label = GETPOST('clone_label', 'alphanohtml'); } else { @@ -658,18 +662,25 @@ if ($action == 'create' && $permissiontoadd) { print ''; print "Transaction status registered, you can close this"; diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 73971ca5480..bef2e6e7800 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -49,7 +49,7 @@ if (!defined('ISLOADEDBYSTEELSHEET')) { --colortextbacktab: #; --colorboxiconbg: #eee; --refidnocolor:#444; - --tableforfieldcolor:#666; + --tableforfieldcolor:#888; --amountremaintopaycolor:#880000; --amountpaymentcomplete:#008800; --amountremaintopaybackcolor:none; @@ -171,6 +171,11 @@ table.liste th.wrapcolumntitle.liste_titre_sel:not(.maxwidthsearch), table.liste max-width: 100px; text-overflow: ellipsis; } +th.wrapcolumntitle dl dt a span.fas.fa-list { + padding-bottom: 1px; + vertical-align: bottom; +} + /*.liste_titre input[name=month_date_when], .liste_titre input[name=monthvalid], .liste_titre input[name=search_ordermonth], .liste_titre input[name=search_deliverymonth], .liste_titre input[name=search_smonth], .liste_titre input[name=search_month], .liste_titre input[name=search_emonth], .liste_titre input[name=smonth], .liste_titre input[name=month], .liste_titre select[name=month], .liste_titre select[name=year], @@ -629,7 +634,7 @@ table.tableforfield .buttonDelete:not(.bordertransp):not(.buttonpayment) { -webkit-box-shadow: 0px 0px 5px 1px rgba(0, 0, 60, 0.2), 0px 0px 0px rgba(60,60,60,0.1); box-shadow: 0px 0px 5px 1px rgba(0, 0, 60, 0.2), 0px 0px 0px rgba(60,60,60,0.1); } -.button:hover, .buttonDelete:hover { +.button:hover:not(.nohover), .buttonDelete:hover:not(.nohover) { /* warning: having a larger shadow has side effect when button is completely on left of a table */ -webkit-box-shadow: 0px 0px 1px 1px rgba(0, 0, 0, 0.2), 0px 0px 0px rgba(60,60,60,0.1); box-shadow: 0px 0px 1px 1px rgba(0, 0, 0, 0.2), 0px 0px 0px rgba(60,60,60,0.1); @@ -905,7 +910,9 @@ textarea.centpercent { .nomarginright { margin-: unset; } - +.nowidthimp { + width: unset !important; +} .cursordefault { cursor: default; } @@ -1425,6 +1432,9 @@ select.flat.selectlimit { .tablelistofcalendars { margin-top: 25px !important; } +.navselectiondate { + width: 250px; +} /* Styles for amount on card */ table.paymenttable td.amountpaymentcomplete, table.paymenttable td.amountremaintopay, table.paymenttable td.amountremaintopayback { @@ -1556,6 +1566,9 @@ table[summary="list_of_modules"] .fa-cog { .linkedcol-element { min-width: 100px; } +.linkedcol-amount { + white-space: nowrap; +} .img-skinthumb { width: 160px; @@ -1594,6 +1607,7 @@ table[summary="list_of_modules"] .fa-cog { .minwidth100 { min-width: 100px; } .minwidth150 { min-width: 150px; } .minwidth200 { min-width: 200px; } + .minwidth250 { min-width: 250px; } .minwidth300 { min-width: 300px; } .minwidth400 { min-width: 400px; } .minwidth500 { min-width: 500px; } @@ -1616,6 +1630,7 @@ table[summary="list_of_modules"] .fa-cog { .width125 { width: 125px; } .width150 { width: 150px; } .width200 { width: 200px; } +.width250 { width: 250px; } .width300 { width: 300px; } .width400 { width: 400px; } .width500 { width: 500px; } @@ -1707,6 +1722,7 @@ select.widthcentpercentminusxx, span.widthcentpercentminusxx:not(.select2-select display: inline-block; } + /* Force values for small screen 767 */ @media only screen and (max-width: 767px) { @@ -1996,11 +2012,12 @@ td.showDragHandle { z-index: 1005; } -global->THEME_DARKMODEENABLED)) { ?> -.side-nav-vert { - border-bottom: 1px solid #888; + +@media screen and (prefers-color-scheme: dark) { + .side-nav-vert { + border-bottom: 1px solid #888; + } } - .side-nav { /*display: block; @@ -3099,6 +3116,17 @@ img.userphotosmall { /* size for user photo in lists */ vertical-align: middle; background-color: #FFF; } +img.userphotopublicvcard { + width: 60px; + height: 60px; + border-radius: 50%; + background-size: contain; + border: 1px solid; + border-color: rgba(128, 128, 128, 0.5); + position: relative; + top: 25px; + left: -110px; +} img.userphoto[alt="Gravatar avatar"], img.photouserphoto.dropdown-user-image[alt="Gravatar avatar"] { background: #fff; } @@ -5406,6 +5434,10 @@ td.cal_other_month { opacity: 0.8; } +td.event-past span { + opacity: 0.5; +} + /* ============================================================================== */ @@ -6506,6 +6538,10 @@ ul.select2-results__options li { font-size: 0.95em; } +.parentonrightofpage { + direction: rtl; +} + @media only screen and (min-width: 767px) { /* CSS to have the dropdown boxes larger that the input search area */ @@ -6702,7 +6738,7 @@ dl.dropdown { z-index: 1; } .dropdown dd ul.selectedfieldsleft { - right: auto; + : auto; } .dropdown dd ul li { white-space: nowrap; @@ -7502,6 +7538,14 @@ div.clipboardCPValue.hidewithsize { { .imgopensurveywizard, .imgautosize { width:95%; height: auto; } + .fiche > .listactionsfilter .table-fiche-title .col-title .titre { + display: none; + } + + .navselectiondate { + width: 220px; + } + #tooltip { position: absolute; width: px; @@ -7799,6 +7843,12 @@ div.clipboardCPValue.hidewithsize { .lilevel1 span.paddingright { padding-right: 4px; } + + img.userphotopublicvcard { + left: unset; + top: unset; + margin-top: 30px; + } } @media only screen and (max-width: 320px) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index fcf9f7ffd1f..2b74cf538b4 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -91,7 +91,7 @@ if (GETPOST('theme', 'aZ09')) { if (GETPOST('lang', 'aZ09')) { $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL } -if (GETPOSTISSET('THEME_DARKMODEENABLED', 'int')) { +if (GETPOSTISSET('THEME_DARKMODEENABLED')) { $conf->global->THEME_DARKMODEENABLED = GETPOST('THEME_DARKMODEENABLED', 'int'); // If darkmode was forced on URL } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 613b2fbf312..afc43936695 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -93,7 +93,7 @@ if (GETPOST('lang', 'aZ09')) { $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL } -if (GETPOSTISSET('THEME_DARKMODEENABLED', 'int')) { +if (GETPOSTISSET('THEME_DARKMODEENABLED')) { $conf->global->THEME_DARKMODEENABLED = GETPOST('THEME_DARKMODEENABLED', 'int'); // If darkmode was forced on URL } @@ -485,6 +485,11 @@ th.wrapcolumntitle.liste_titre_sel:not(.maxwidthsearch), td.wrapcolumntitle.list max-width: 120px; text-overflow: ellipsis; } +th.wrapcolumntitle dl dt a span.fas.fa-list { + padding-bottom: 1px; + vertical-align: bottom; +} + .liste_titre input[name=month_date_when], .liste_titre input[name=monthvalid], .liste_titre input[name=search_ordermonth], .liste_titre input[name=search_deliverymonth], .liste_titre input[name=search_smonth], .liste_titre input[name=search_month], .liste_titre input[name=search_emonth], .liste_titre input[name=smonth], .liste_titre input[name=month], .liste_titre input[name=month_lim], .liste_titre input[name=month_start], .liste_titre input[name=month_end], .liste_titre input[name=month_create], @@ -874,7 +879,7 @@ table.tableforfield .buttonDelete:not(.bordertransp):not(.buttonpayment) { -webkit-box-shadow: 0px 0px 6px 1px rgba(0, 0, 60, 0.2), 0px 0px 0px rgba(60,60,60,0.1); box-shadow: 0px 0px 6px 1px rgba(0, 0, 60, 0.2), 0px 0px 0px rgba(60,60,60,0.1); } -.button:hover, .buttonDelete:hover { +.button:hover:not(.nohover), .buttonDelete:hover:not(.nohover) { -webkit-box-shadow: 0px 0px 6px 1px rgba(0, 0, 0, 0.2), 0px 0px 0px rgba(60,60,60,0.1); box-shadow: 0px 0px 6px 1px rgba(0, 0, 0, 0.2), 0px 0px 0px rgba(60,60,60,0.1); } @@ -1142,6 +1147,9 @@ textarea.centpercent { .nomarginright { margin-: unset; } +.nowidthimp { + width: unset !important; +} .cursordefault { cursor: default; @@ -1771,7 +1779,9 @@ table[summary="list_of_modules"] .fa-cog { .linkedcol-element { min-width: 100px; } - +.linkedcol-amount { + white-space: nowrap; +} .linkedcol-date { text-align: center; } @@ -1814,6 +1824,7 @@ tr.nobottom td { .minwidth100 { min-width: 100px; } .minwidth150 { min-width: 150px; } .minwidth200 { min-width: 200px; } + .minwidth250 { min-width: 250px; } .minwidth300 { min-width: 300px; } .minwidth400 { min-width: 400px; } .minwidth500 { min-width: 500px; } @@ -1837,6 +1848,7 @@ tr.nobottom td { .width125 { width: 125px; } .width150 { width: 150px; } .width200 { width: 200px; } +.width250 { width: 250px; } .width300 { width: 300px; } .width400 { width: 400px; } .width500 { width: 500px; } @@ -3222,6 +3234,17 @@ img.userphotosmall { /* size for user photo in lists */ img.userphoto[alt="Gravatar avatar"], img.photouserphoto.dropdown-user-image[alt="Gravatar avatar"] { background: #fff; } +img.userphotopublicvcard { + width: 60px; + height: 60px; + border-radius: 50%; + background-size: contain; + border: 1px solid; + border-color: rgba(128, 128, 128, 0.5); + position: relative; + top: 25px; + left: -110px; +} form[name="addtime"] img.userphoto { border: 1px solid #444; } @@ -6434,6 +6457,10 @@ ul.select2-results__options li { } } +.parentonrightofpage { + direction: rtl; +} + /* ============================================================================== */ /* For categories */ @@ -6602,7 +6629,7 @@ dl.dropdown { z-index: 1; } .dropdown dd ul.selectedfieldsleft { - right: auto; + : auto; } .dropdown dd ul li { white-space: nowrap; @@ -7625,6 +7652,12 @@ div.clipboardCPValue.hidewithsize { .lilevel1 span.paddingright { padding-right: 3px; } + + img.userphotopublicvcard { + left: unset; + top: unset; + margin-top: 30px; + } } diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index 6ad204965bc..29a013f1eb9 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -111,7 +111,7 @@ class ActionsTicket * @param int $id ID of ticket * @param string $ref Reference of ticket * @param string $track_id Track ID of ticket (for public area) - * @return void + * @return int <0 if KO, >0 if OK */ public function fetch($id = 0, $ref = '', $track_id = '') { diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index dcd4c3c9911..e27a7a5e0c7 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -270,7 +270,7 @@ class Ticket extends CommonObject // BEGIN MODULEBUILDER PROPERTIES public $fields = array( - 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'position'=>1, 'visible'=>-2, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id"), + 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-2, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id"), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>5, 'notnull'=>1, 'index'=>1), 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'css'=>'', 'showoncombobox'=>1), 'track_id' => array('type'=>'varchar(255)', 'label'=>'TicketTrackId', 'visible'=>-2, 'enabled'=>1, 'position'=>11, 'notnull'=>-1, 'searchall'=>1, 'help'=>"Help text"), @@ -280,7 +280,7 @@ class Ticket extends CommonObject 'type_code' => array('type'=>'varchar(32)', 'label'=>'Type', 'visible'=>1, 'enabled'=>1, 'position'=>20, 'notnull'=>-1, 'help'=>"", 'csslist'=>'maxwidth125 tdoverflowmax50'), 'category_code' => array('type'=>'varchar(32)', 'label'=>'TicketCategory', 'visible'=>-1, 'enabled'=>1, 'position'=>21, 'notnull'=>-1, 'help'=>"", 'css'=>'maxwidth100 tdoverflowmax200'), 'severity_code' => array('type'=>'varchar(32)', 'label'=>'Severity', 'visible'=>1, 'enabled'=>1, 'position'=>22, 'notnull'=>-1, 'help'=>"", 'css'=>'maxwidth100'), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>'$conf->societe->enabled', 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"OrganizationEventLinkToThirdParty", 'css'=>'tdoverflowmax150 maxwidth150onsmartphone'), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>'isModEnabled("societe")', 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"OrganizationEventLinkToThirdParty", 'css'=>'tdoverflowmax150 maxwidth150onsmartphone'), 'notify_tiers_at_create' => array('type'=>'integer', 'label'=>'NotifyThirdparty', 'visible'=>-1, 'enabled'=>0, 'position'=>51, 'notnull'=>1, 'index'=>1), 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php', 'label'=>'Project', 'visible'=>-1, 'enabled'=>'$conf->project->enabled', 'position'=>52, 'notnull'=>-1, 'index'=>1, 'help'=>"LinkToProject"), //'timing' => array('type'=>'varchar(20)', 'label'=>'Timing', 'visible'=>-1, 'enabled'=>1, 'position'=>42, 'notnull'=>-1, 'help'=>""), // what is this ? @@ -1789,11 +1789,11 @@ class Ticket extends CommonObject /** * Search and fetch thirparties by email * - * @param string $email Email - * @param int $type Type of thirdparties (0=any, 1=customer, 2=prospect, 3=supplier) - * @param array $filters Array of couple field name/value to filter the companies with the same name - * @param string $clause Clause for filters - * @return array Array of thirdparties object + * @param string $email Email + * @param int $type Type of thirdparties (0=any, 1=customer, 2=prospect, 3=supplier) + * @param array $filters Array of couple field name/value to filter the companies with the same name + * @param string $clause Clause for filters + * @return array|int Array of thirdparties object */ public function searchSocidByEmail($email, $type = '0', $filters = array(), $clause = 'AND') { @@ -1854,10 +1854,10 @@ class Ticket extends CommonObject /** * Search and fetch contacts by email * - * @param string $email Email - * @param array $socid Limit to a thirdparty - * @param string $case Respect case - * @return array Array of contacts object + * @param string $email Email + * @param array $socid Limit to a thirdparty + * @param string $case Respect case + * @return array|int Array of contacts object */ public function searchContactByEmail($email, $socid = '', $case = '') { @@ -1900,8 +1900,8 @@ class Ticket extends CommonObject /** * Define parent commany of current ticket * - * @param int $id Id of thirdparty to set or '' to remove - * @return int <0 if KO, >0 if OK + * @param int $id Id of thirdparty to set or '' to remove + * @return int <0 if KO, >0 if OK */ public function setCustomer($id) { @@ -2075,7 +2075,7 @@ class Ticket extends CommonObject * @param string $source Source of contact: external or thirdparty (llx_socpeople) or internal (llx_user) * @param int $list 0:Return array contains all properties, 1:Return array contains just id * @param string $code Filter on this code of contact type ('SHIPPING', 'BILLING', ...) - * @return array Array of contacts + * @return array|int Array of contacts */ public function listeContact($status = -1, $source = 'external', $list = 0, $code = '') { @@ -2328,8 +2328,8 @@ class Ticket extends CommonObject * Adds it to non existing supplied categories. * Existing categories are left untouch. * - * @param int[]|int $categories Category or categories IDs - * @return void + * @param int[]|int $categories Category or categories IDs + * @return int <0 if KO, >0 if OK */ public function setCategories($categories) { @@ -2364,12 +2364,12 @@ class Ticket extends CommonObject } } - return; + return 1; } /** * Add new message on a ticket (private/public area). - * Can also send it be email if GETPOST('send_email', 'int') is set. For such email, header and footer is added. + * Can also send it by email if GETPOST('send_email', 'int') is set. For such email, header and footer is added. * * @param User $user User for action * @param string $action Action string @@ -2438,8 +2438,13 @@ class Ticket extends CommonObject * Send emails to assigned users (public area notification) */ if (!empty($conf->global->TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_ENABLED)) { + // Retrieve internal contact datas + $internal_contacts = $object->getInfosTicketInternalContact(); + $assigned_user_dont_have_email = ''; + $sendto = array(); + if ($this->fk_user_assign > 0) { $assigned_user = new User($this->db); $assigned_user->fetch($this->fk_user_assign); @@ -2449,6 +2454,21 @@ class Ticket extends CommonObject $assigned_user_dont_have_email = $assigned_user->getFullName($langs); } } + + // Build array to display recipient list + foreach ($internal_contacts as $key => $info_sendto) { + // Avoid duplicate notifications + if ($info_sendto['id'] == $user->id) { + continue; + } + + if ($info_sendto['email'] != '') { + if (!empty($info_sendto['email'])) { + $sendto[] = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'])." <".$info_sendto['email'].">"; + } + } + } + if (empty($sendto)) { if (!empty($conf->global->TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_DEFAULT_EMAIL)) { $sendto[] = $conf->global->TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_DEFAULT_EMAIL; @@ -2545,7 +2565,7 @@ class Ticket extends CommonObject if ($info_sendto['email'] != '') { if (!empty($info_sendto['email'])) { - $sendto[] = trim($info_sendto['firstname']." ".$info_sendto['lastname'])." <".$info_sendto['email'].">"; + $sendto[] = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'])." <".$info_sendto['email'].">"; } // Contact type diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 4c4dce5a428..79db9e0e73e 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -836,15 +836,15 @@ foreach ($object->fields as $key => $val) { print ''; } elseif ($key == 'type_code') { print ''; } elseif ($key == 'category_code') { print ''; } elseif ($key == 'severity_code') { print ''; } elseif ($key == 'fk_user_assign' || $key == 'fk_user_create') { print ' - - + rights->user->user->lire || $user->admin) { $linkback = ''.$langs->trans("BackToList").''; } -$morehtmlref = ''; +$morehtmlref = ''; $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"'); $morehtmlref .= ''; +$urltovirtualcard = '/user/virtualcard.php?id='.((int) $object->id); +$morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->trans("PublicVirtualCardUrl").' - '.$object->getFullName($langs), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', 'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard, '', 'nohover'); + dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin, 'rowid', 'ref', $morehtmlref); diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index fb795ecc6e4..7040add3950 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -350,10 +350,13 @@ if ($action != 'edit' && $action != 'create') { // If not bank account yet, $ac $linkback = ''.$langs->trans("BackToList").''; } - $morehtmlref = ''; + $morehtmlref = ''; $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"'); $morehtmlref .= ''; + $urltovirtualcard = '/user/virtualcard.php?id='.((int) $object->id); + $morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->trans("PublicVirtualCardUrl").' - '.$object->getFullName($langs), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', 'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard, '', 'nohover'); + dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin, 'rowid', 'ref', $morehtmlref); print '
'; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index f26d61da521..602bc25eb3a 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -71,6 +71,10 @@ $group = GETPOST("group", "int", 3); $cancel = GETPOST('cancel', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'useracard'; // To manage different context of search +if (empty($id)) { + $id = $user->id; +} + $dateemployment = dol_mktime(0, 0, 0, GETPOST('dateemploymentmonth', 'int'), GETPOST('dateemploymentday', 'int'), GETPOST('dateemploymentyear', 'int')); $dateemploymentend = dol_mktime(0, 0, 0, GETPOST('dateemploymentendmonth', 'int'), GETPOST('dateemploymentendday', 'int'), GETPOST('dateemploymentendyear', 'int')); $datestartvalidity = dol_mktime(0, 0, 0, GETPOST('datestartvaliditymonth', 'int'), GETPOST('datestartvalidityday', 'int'), GETPOST('datestartvalidityyear', 'int')); @@ -375,6 +379,7 @@ if (empty($reshook)) { $editgroup->oldcopy = clone $editgroup; $object->fetch($id); + if ($action == 'addgroup') { $result = $object->SetInGroup($group, $editgroup->entity); } @@ -516,7 +521,14 @@ if (empty($reshook)) { } if (!$error) { - $ret = $object->update($user); + $passwordismodified = 0; + if (!empty($object->pass)) { + if ($object->pass != $object->pass_indatabase && !dol_verifyHash($object->pass, $object->pass_indatabase_crypted)) { + $passwordismodified = 1; + } + } + + $ret = $object->update($user); // This may include call to setPassword if password has changed if ($ret < 0) { $error++; if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { @@ -610,6 +622,13 @@ if (empty($reshook)) { $langs->load("errors"); setEventMessages($langs->transnoentitiesnoconv("WarningYourLoginWasModifiedPleaseLogin"), null, 'warnings'); } + if ($passwordismodified && $object->login == $user->login) { // Current user has changed its password + $error++; + $langs->load("errors"); + setEventMessages($langs->transnoentitiesnoconv("WarningYourPasswordWasModifiedPleaseLogin"), null, 'warnings'); + header("Location: ".DOL_URL_ROOT.'/user/card.php?id='.$object->id); + exit; + } } else { $db->rollback(); } @@ -1432,10 +1451,13 @@ if ($action == 'create' || $action == 'adduserldap') { if ($action != 'edit') { print dol_get_fiche_head($head, 'user', $title, -1, 'user'); - $morehtmlref = ''; - $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"'); + $morehtmlref = ''; + $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard").' ('.$langs->trans("AddToContacts").')', 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"'); $morehtmlref .= ''; + $urltovirtualcard = '/user/virtualcard.php?id='.((int) $object->id); + $morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->trans("PublicVirtualCardUrl").' - '.$object->getFullName($langs), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', 'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard, '', 'nohover'); + dol_banner_tab($object, 'id', $linkback, $user->hasRight("user", "user", "read") || $user->admin, 'rowid', 'ref', $morehtmlref); print '
'; @@ -1506,7 +1528,7 @@ if ($action == 'create' || $action == 'adduserldap') { $huser = new User($db); if ($object->fk_user > 0) { $huser->fetch($object->fk_user); - print $huser->getNomUrl(1); + print $huser->getNomUrl(-1); } else { print ''.$langs->trans("None").''; } @@ -1524,7 +1546,7 @@ if ($action == 'create' || $action == 'adduserldap') { if (!empty($object->fk_user_expense_validator)) { $evuser = new User($db); $evuser->fetch($object->fk_user_expense_validator); - print $evuser->getNomUrl(1); + print $evuser->getNomUrl(-1); } print ''; print "
\n"; @@ -1540,7 +1562,7 @@ if ($action == 'create' || $action == 'adduserldap') { if (!empty($object->fk_user_holiday_validator)) { $hvuser = new User($db); $hvuser->fetch($object->fk_user_holiday_validator); - print $hvuser->getNomUrl(1); + print $hvuser->getNomUrl(-1); } print ''; print "\n"; @@ -2255,7 +2277,7 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; $huser = new User($db); $huser->fetch($object->fk_user); - print $huser->getNomUrl(1); + print $huser->getNomUrl(-1); } print ''; print "\n"; @@ -2273,7 +2295,7 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; $evuser = new User($db); $evuser->fetch($object->fk_user_expense_validator); - print $evuser->getNomUrl(1); + print $evuser->getNomUrl(-1); } print ''; print "\n"; @@ -2292,7 +2314,7 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; $hvuser = new User($db); $hvuser->fetch($object->fk_user_holiday_validator); - print $hvuser->getNomUrl(1); + print $hvuser->getNomUrl(-1); } print ''; print "\n"; @@ -2461,6 +2483,7 @@ if ($action == 'create' || $action == 'adduserldap') { // Country print ''; +} $db->free($resql); +print '
'.$langs->trans("ResourceType").''; - $ret = $formresource->select_types_resource($object->fk_code_type_resource, 'fk_code_type_resource', '', 2); + $formresource->select_types_resource($object->fk_code_type_resource, 'fk_code_type_resource', '', 2); print '
'; - $formTicket->selectTypesTickets(dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, (!empty($val['css']) ? $val['css'] : 'maxwidth150'), 1); + $formTicket->selectTypesTickets(dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]), 'search_'.$key, '', 2, 1, 1, 0, (!empty($val['css']) ? $val['css'] : 'maxwidth150'), 1); print ''; - $formTicket->selectGroupTickets(dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, (!empty($val['css']) ? $val['css'] : 'maxwidth150')); + $formTicket->selectGroupTickets(dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]), 'search_'.$key, '', 2, 1, 1, 0, (!empty($val['css']) ? $val['css'] : 'maxwidth150')); print ''; - $formTicket->selectSeveritiesTickets(dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, (!empty($val['css']) ? $val['css'] : 'maxwidth150')); + $formTicket->selectSeveritiesTickets(dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]), 'search_'.$key, '', 2, 1, 1, 0, (!empty($val['css']) ? $val['css'] : 'maxwidth150')); print ''; diff --git a/htdocs/ticket/tpl/linkedobjectblock.tpl.php b/htdocs/ticket/tpl/linkedobjectblock.tpl.php index 6a49597f1f4..4ba36894379 100644 --- a/htdocs/ticket/tpl/linkedobjectblock.tpl.php +++ b/htdocs/ticket/tpl/linkedobjectblock.tpl.php @@ -46,12 +46,12 @@ foreach ($linkedObjectBlock as $key => $objectlink) { } ?>
trans("Ticket"); ?> + trans("Ticket"); ?> global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { print ' getNomUrl(1); ?>getNomUrl(1); ?> ref_client; ?> datec, 'day'); ?>
'.$form->editfieldkey('Country', 'selectcounty_id', '', $object, 0).''; + print img_picto('', 'country', 'class="pictofixedwidth"'); if ($caneditfield) { print $form->select_country((GETPOST('country_id') != '' ?GETPOST('country_id') : $object->country_id), 'country_id'); if ($user->admin) { diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 52a9f941cfe..22556d3e1c2 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -276,6 +276,7 @@ class User extends CommonObject public $datelastlogin; public $datepreviouslogin; + public $flagdelsessionsbefore; public $iplastlogin; public $ippreviouslogin; public $datestartvalidity; @@ -436,11 +437,12 @@ class User extends CommonObject $sql .= " u.admin, u.login, u.note_private, u.note_public,"; $sql .= " u.pass, u.pass_crypted, u.pass_temp, u.api_key,"; $sql .= " u.fk_soc, u.fk_socpeople, u.fk_member, u.fk_user, u.ldap_sid, u.fk_user_expense_validator, u.fk_user_holiday_validator,"; - $sql .= " u.statut, u.lang, u.entity,"; + $sql .= " u.statut as status, u.lang, u.entity,"; $sql .= " u.datec as datec,"; $sql .= " u.tms as datem,"; $sql .= " u.datelastlogin as datel,"; $sql .= " u.datepreviouslogin as datep,"; + $sql .= " u.flagdelsessionsbefore,"; $sql .= " u.iplastlogin,"; $sql .= " u.ippreviouslogin,"; $sql .= " u.datelastpassvalidation,"; @@ -553,7 +555,10 @@ class User extends CommonObject $this->note_public = $obj->note_public; $this->note_private = $obj->note_private; $this->note = $obj->note_private; // deprecated - $this->statut = $obj->statut; + + $this->statut = $obj->status; // deprecated + $this->status = $obj->status; + $this->photo = $obj->photo; $this->openid = $obj->openid; $this->lang = $obj->lang; @@ -572,6 +577,7 @@ class User extends CommonObject $this->datem = $this->db->jdate($obj->datem); $this->datelastlogin = $this->db->jdate($obj->datel); $this->datepreviouslogin = $this->db->jdate($obj->datep); + $this->flagdelsessionsbefore = $this->db->jdate($obj->flagdelsessionsbefore, 'gmt'); $this->iplastlogin = $obj->iplastlogin; $this->ippreviouslogin = $obj->ippreviouslogin; $this->datestartvalidity = $this->db->jdate($obj->datestartvalidity); @@ -717,7 +723,6 @@ class User extends CommonObject 'shipping' => 'expedition', 'task' => 'task@projet', 'fichinter' => 'ficheinter', - 'propale' => 'propal', 'inventory' => 'stock', 'invoice' => 'facture', 'invoice_supplier' => 'fournisseur', @@ -1350,7 +1355,11 @@ class User extends CommonObject $error = 0; // Check parameters - if ($this->statut == $status) { + if (isset($this->statut)) { + if ($this->statut == $status) { + return 0; + } + } elseif (isset($this->status) && $this->status == $status) { return 0; } @@ -1390,8 +1399,8 @@ class User extends CommonObject * Adds it to non existing supplied categories. * Existing categories are left untouch. * - * @param int[]|int $categories Category or categories IDs - * @return void + * @param int[]|int $categories Category or categories IDs + * @return int <0 if KO, >0 if OK */ public function setCategories($categories) { @@ -1770,9 +1779,9 @@ class User extends CommonObject } } - if ($result > 0 && $member->fk_soc) { // If member is linked to a thirdparty + if ($result > 0 && $member->socid) { // If member is linked to a thirdparty $sql = "UPDATE ".$this->db->prefix()."user"; - $sql .= " SET fk_soc=".((int) $member->fk_soc); + $sql .= " SET fk_soc=".((int) $member->socid); $sql .= " WHERE rowid=".((int) $this->id); dol_syslog(get_class($this)."::create_from_member", LOG_DEBUG); @@ -2025,9 +2034,9 @@ class User extends CommonObject // Update password if (!empty($this->pass)) { - if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted) { + if ($this->pass != $this->pass_indatabase && !dol_verifyHash($this->pass, $this->pass_indatabase_crypted)) { // If a new value for password is set and different than the one crypted into database - $result = $this->setPassword($user, $this->pass, 0, $notrigger, $nosyncmemberpass); + $result = $this->setPassword($user, $this->pass, 0, $notrigger, $nosyncmemberpass, 0, 1); if ($result < 0) { return -5; } @@ -2237,9 +2246,10 @@ class User extends CommonObject * @param int $notrigger 1=Does not launch triggers * @param int $nosyncmember Do not synchronize linked member * @param int $passwordalreadycrypted 0=Value is cleartext password, 1=Value is crypted value. + * @param int $flagdelsessionsbefore 1=Save also the current date to ask to invalidate all other session before this date. * @return string If OK return clear password, 0 if no change (warning, you may retreive 1 instead of 0 even if password was same), < 0 if error */ - public function setPassword($user, $password = '', $changelater = 0, $notrigger = 0, $nosyncmember = 0, $passwordalreadycrypted = 0) + public function setPassword($user, $password = '', $changelater = 0, $notrigger = 0, $nosyncmember = 0, $passwordalreadycrypted = 0, $flagdelsessionsbefore = 1) { global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; @@ -2291,6 +2301,9 @@ class User extends CommonObject $sql = "UPDATE ".$this->db->prefix()."user"; $sql .= " SET pass_crypted = '".$this->db->escape($password_crypted)."',"; $sql .= " pass_temp = null"; + if (!empty($flagdelsessionsbefore)) { + $sql .= ", flagdelsessionsbefore = '".$this->db->idate(dol_now() - 5, 'gmt')."'"; + } if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) { $sql .= ", pass = null"; } else { @@ -2641,7 +2654,11 @@ class User extends CommonObject $sql = "DELETE FROM ".$this->db->prefix()."usergroup_user"; $sql .= " WHERE fk_user = ".((int) $this->id); $sql .= " AND fk_usergroup = ".((int) $group); - $sql .= " AND entity = ".((int) $entity); + if (empty($entity)) { + $sql .= " AND entity IN (0, 1)"; // group may be in entity 0 (so $entity=0) and link with user into entity 1. + } else { + $sql .= " AND entity = ".((int) $entity); + } $result = $this->db->query($sql); if ($result) { @@ -3253,7 +3270,8 @@ class User extends CommonObject $this->iplastlogin = '127.0.0.1'; $this->datepreviouslogin = $now; $this->ippreviouslogin = '127.0.0.1'; - $this->statut = 1; + $this->statut = 1; // deprecated + $this->status = 1; $this->entity = 1; return 1; @@ -3371,24 +3389,36 @@ class User extends CommonObject $socialnetworks = getArrayOfSocialNetworks(); - $this->firstname = $ldapuser->{$conf->global->LDAP_FIELD_FIRSTNAME}; - $this->lastname = $ldapuser->{$conf->global->LDAP_FIELD_NAME}; - $this->login = $ldapuser->{$conf->global->LDAP_FIELD_LOGIN}; - $this->pass = $ldapuser->{$conf->global->LDAP_FIELD_PASSWORD}; - $this->pass_indatabase_crypted = $ldapuser->{$conf->global->LDAP_FIELD_PASSWORD_CRYPTED}; + $tmpvar = getDolGlobalString('LDAP_FIELD_FIRSTNAME'); + $this->firstname = $ldapuser->$tmpvar; + $tmpvar = getDolGlobalString('LDAP_FIELD_NAME'); + $this->lastname = $ldapuser->$tmpvar; + $tmpvar = getDolGlobalString('LDAP_FIELD_LOGIN'); + $this->login = $ldapuser->$tmpvar; + $tmpvar = getDolGlobalString('LDAP_FIELD_PASSWORD'); + $this->pass = $ldapuser->$tmpvar; + $tmpvar = getDolGlobalString('LDAP_FIELD_PASSWORD_CRYPTED'); + $this->pass_indatabase_crypted = $ldapuser->$tmpvar; - $this->office_phone = $ldapuser->{$conf->global->LDAP_FIELD_PHONE}; - $this->user_mobile = $ldapuser->{$conf->global->LDAP_FIELD_MOBILE}; - $this->office_fax = $ldapuser->{$conf->global->LDAP_FIELD_FAX}; - $this->email = $ldapuser->{$conf->global->LDAP_FIELD_MAIL}; + $tmpvar = getDolGlobalString('LDAP_FIELD_PHONE'); + $this->office_phone = $ldapuser->$tmpvar; + $tmpvar = getDolGlobalString('LDAP_FIELD_MOBILE'); + $this->user_mobile = $ldapuser->$tmpvar; + $tmpvar = getDolGlobalString('LDAP_FIELD_FAX'); + $this->office_fax = $ldapuser->$tmpvar; + $tmpvar = getDolGlobalString('LDAP_FIELD_MAIL'); + $this->email = $ldapuser->$tmpvar; foreach ($socialnetworks as $key => $value) { - $tmpkey = 'LDAP_FIELD_'.strtoupper($value['label']); - $this->socialnetworks[$value['label']] = $ldapuser->{$conf->global->$tmpkey}; + $tmpvar = getDolGlobalString('LDAP_FIELD_'.strtoupper($value['label'])); + $this->socialnetworks[$value['label']] = $ldapuser->$tmpvar; } - $this->ldap_sid = $ldapuser->{$conf->global->LDAP_FIELD_SID}; + $tmpvar = getDolGlobalString('LDAP_FIELD_SID'); + $this->ldap_sid = $ldapuser->$tmpvar; - $this->job = $ldapuser->{$conf->global->LDAP_FIELD_TITLE}; - $this->note_public = $ldapuser->{$conf->global->LDAP_FIELD_DESCRIPTION}; + $tmpvar = getDolGlobalString('LDAP_FIELD_TITLE'); + $this->job = $ldapuser->$tmpvar; + $tmpvar = getDolGlobalString('LDAP_FIELD_DESCRIPTION'); + $this->note_public = $ldapuser->$tmpvar; $result = $this->update($user); @@ -3470,7 +3500,7 @@ class User extends CommonObject * * @param int $deleteafterid Removed all users including the leaf $deleteafterid (and all its child) in user tree. * @param string $filter SQL filter on users. This parameter must not come from user intput. - * @return array Array of users $this->users. Note: $this->parentof is also set. + * @return array|int Array of users $this->users. Note: $this->parentof is also set. */ public function get_full_tree($deleteafterid = 0, $filter = '') { @@ -3767,6 +3797,31 @@ class User extends CommonObject } } + /** + * Return string with full Url to virtual card + * + * @param string $mode Mode for link + * @return string Url string link + */ + public function getOnlineVirtualCardUrl($mode = '') + { + global $dolibarr_main_instance_unique_id, $dolibarr_main_url_root; + global $conf; + + $encodedsecurekey = dol_hash($dolibarr_main_instance_unique_id.'uservirtualcard'.$this->id.'-'.$this->login, 'md5'); + if (isModEnabled('multicompany')) { + $entity_qr = '&entity='.((int) $conf->entity); + } else { + $entity_qr = ''; + } + // Define $urlwithroot + $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + + return $urlwithroot.'/public/users/view.php?id='.$this->id.'&securekey='.$encodedsecurekey.$entity_qr.($mode ? '&mode='.urlencode($mode) : ''); + } + /** * Load all objects into $this->users * diff --git a/htdocs/user/class/userbankaccount.class.php b/htdocs/user/class/userbankaccount.class.php index 271609139b1..6e9cc8e52af 100644 --- a/htdocs/user/class/userbankaccount.class.php +++ b/htdocs/user/class/userbankaccount.class.php @@ -241,7 +241,7 @@ class UserBankAccount extends Account $rib = $this->label." : "; } - $rib .= (string) $this; + $rib .= $this->iban; } return $rib; diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 849b08bc7f6..71339991172 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -180,9 +180,9 @@ class UserGroup extends CommonObject /** * Return array of groups objects for a particular user * - * @param int $userid User id to search - * @param boolean $load_members Load all members of the group - * @return array Array of groups objects + * @param int $userid User id to search + * @param boolean $load_members Load all members of the group + * @return array|int Array of groups objects */ public function listGroupsForUser($userid, $load_members = true) { @@ -544,7 +544,7 @@ class UserGroup extends CommonObject * Charge dans l'objet group, la liste des permissions auquels le groupe a droit * * @param string $moduletag Name of module we want permissions ('' means all) - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, >=0 if OK */ public function getrights($moduletag = '') { @@ -552,12 +552,12 @@ class UserGroup extends CommonObject if ($moduletag && isset($this->_tab_loaded[$moduletag]) && $this->_tab_loaded[$moduletag]) { // Rights for this module are already loaded, so we leave - return; + return 0; } if (!empty($this->all_permissions_are_loaded)) { // We already loaded all rights for this group, so we leave - return; + return 0; } /* diff --git a/htdocs/user/clicktodial.php b/htdocs/user/clicktodial.php index 562ab081ab8..d2f9452bac5 100644 --- a/htdocs/user/clicktodial.php +++ b/htdocs/user/clicktodial.php @@ -106,10 +106,13 @@ if ($id > 0) { $linkback = ''.$langs->trans("BackToList").''; } - $morehtmlref = ''; + $morehtmlref = ''; $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"'); $morehtmlref .= ''; + $urltovirtualcard = '/user/virtualcard.php?id='.((int) $object->id); + $morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->trans("PublicVirtualCardUrl").' - '.$object->getFullName($langs), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', 'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard, '', 'nohover'); + dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin, 'rowid', 'ref', $morehtmlref); print '
'; diff --git a/htdocs/user/document.php b/htdocs/user/document.php index b607cff7f3e..f99eb9982a2 100644 --- a/htdocs/user/document.php +++ b/htdocs/user/document.php @@ -152,10 +152,13 @@ if ($object->id) { $linkback = ''.$langs->trans("BackToList").''; } - $morehtmlref = ''; + $morehtmlref = ''; $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"'); $morehtmlref .= ''; + $urltovirtualcard = '/user/virtualcard.php?id='.((int) $object->id); + $morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->trans("PublicVirtualCardUrl").' - '.$object->getFullName($langs), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', 'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard, '', 'nohover'); + dol_banner_tab($object, 'id', $linkback, $user->hasRight("user", "user", "read") || $user->admin, 'rowid', 'ref', $morehtmlref); print '
'; diff --git a/htdocs/user/group/list.php b/htdocs/user/group/list.php index 9f7505c3de1..7e707b6b4fc 100644 --- a/htdocs/user/group/list.php +++ b/htdocs/user/group/list.php @@ -43,7 +43,7 @@ $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ09'); // Option for the css output (always '' except when 'print') $mode = GETPOST('mode', 'aZ'); -$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $search_group = GETPOST('search_group'); // Load variable for pagination @@ -152,12 +152,15 @@ if (empty($reshook)) { * View */ -$help_url=""; +$form = new Form($db); + +$help_url = ''; $title = $langs->trans("UserGroups"); $morejs = array(); $morecss = array(); - +// Build and execute select +// -------------------------------------------------------------------- $sql = "SELECT g.rowid, g.nom as name, g.note, g.entity, g.datec, g.tms as datem, COUNT(DISTINCT ugu.fk_user) as nb, COUNT(DISTINCT ugr.fk_id) as nbpermissions"; $sql .= " FROM ".MAIN_DB_PREFIX."usergroup as g"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_usergroup = g.rowid"; @@ -230,6 +233,27 @@ foreach ($search as $key => $val) { if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } +// Add $param from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; +// Add $param from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook +$param .= $hookmanager->resPrint; + +// List of mass actions available +$arrayofmassactions = array( + //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"), + //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), + //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), + //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), +); +if (!empty($permissiontodelete)) { + $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); +} +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); +} +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '
'."\n"; if ($optioncss != '') { @@ -262,21 +286,43 @@ if ($search_all) { $setupstring .= $key."=".$val.";"; } print ''."\n"; - print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'."\n"; } $moreforfilter = ''; -//$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; -//$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; +} else { + $moreforfilter = $hookmanager->resPrint; +} + +if (!empty($moreforfilter)) { + print '
'; + print $moreforfilter; + print '
'; +} + +$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; +$arrayfields = array(); +$selectedfields = ''; +if (!empty($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 '
'; -print ''."\n"; +print '
'."\n"; // Fields title search // -------------------------------------------------------------------- // ... +$totalarray = array(); +$totalarray['nbfield'] = 0; + // Fields title label // -------------------------------------------------------------------- print ''; @@ -298,12 +344,26 @@ print_liste_field_titre("DateCreationShort", $_SERVER["PHP_SELF"], "g.datec", $p $totalarray['nbfield']++; print_liste_field_titre("DateLastModification", $_SERVER["PHP_SELF"], "g.tms", $param, "", '', $sortfield, $sortorder, 'center '); $totalarray['nbfield']++; -print_liste_field_titre("", $_SERVER["PHP_SELF"]); +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; +// Hook fields +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +/*if (!empty($arrayfields['anotherfield']['checked'])) { + print ''; + $totalarray['nbfield']++; + }*/ +// Action column +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +} $totalarray['nbfield']++; // For the column action -print "\n"; - +print ''."\n"; +// Loop on record +// -------------------------------------------------------------------- $i = 0; $savnbfield = $totalarray['nbfield']; $totalarray = array(); @@ -357,17 +417,41 @@ while ($i < $imaxinloop) { print img_picto($langs->trans("GlobalGroup"), 'redstar'); } print ""; + if (!$i) { + $totalarray['nbfield']++; + } //multicompany if (isModEnabled('multicompany') && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1) { $mc->getInfo($obj->entity); print ''; + if (!$i) { + $totalarray['nbfield']++; + } } print ''; + if (!$i) { + $totalarray['nbfield']++; + } print ''; + if (!$i) { + $totalarray['nbfield']++; + } print ''; + if (!$i) { + $totalarray['nbfield']++; + } print ''; + if (!$i) { + $totalarray['nbfield']++; + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; // Action column if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { print '\n"; + print ''."\n"; } $i++; } -print "
'.$langs->trans("AnotherField").'
'.dol_escape_htmltag($mc->label).''.$obj->nb.''; print ''.$obj->nbpermissions.''; print ''.dol_print_date($db->jdate($obj->datec), "dayhour").''.dol_print_date($db->jdate($obj->datem), "dayhour").''; @@ -384,17 +468,33 @@ while ($i < $imaxinloop) { $totalarray['nbfield']++; } - print "
"; -print '
'; -print "
\n"; +// 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++; + } + }*/ + $colspan = $savnbfield; + print '
'.$langs->trans("NoRecordFound").'
'."\n"; +print '
'."\n"; + +print ''."\n"; + // End of page llxFooter(); $db->close(); diff --git a/htdocs/user/info.php b/htdocs/user/info.php index dfb1fe23d0b..7804579edd5 100644 --- a/htdocs/user/info.php +++ b/htdocs/user/info.php @@ -51,7 +51,7 @@ $feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user'); $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); // If user is not user that read and no permission to read other users, we stop -if (($object->id != $user->id) && (!$user->rights->user->user->lire)) { +if (($object->id != $user->id) && empty($user->rights->user->user->lire)) { accessforbidden(); } @@ -80,10 +80,13 @@ if ($user->rights->user->user->lire || $user->admin) { $linkback = ''.$langs->trans("BackToList").''; } -$morehtmlref = ''; +$morehtmlref = ''; $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"'); $morehtmlref .= ''; +$urltovirtualcard = '/user/virtualcard.php?id='.((int) $object->id); +$morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->trans("PublicVirtualCardUrl").' - '.$object->getFullName($langs), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', 'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard, '', 'nohover'); + dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin, 'rowid', 'ref', $morehtmlref); diff --git a/htdocs/user/list.php b/htdocs/user/list.php index 8610113f0da..3cac5d06c56 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -542,7 +542,7 @@ if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.urlencode($limit); } if ($sall != '') { - $param .= '&sall='.urlencode($sall); + $param .= '&search_all='.urlencode($sall); } if ($search_user != '') { $param .= "&search_user=".urlencode($search_user); @@ -800,7 +800,7 @@ if (!empty($arrayfields['u.tms']['checked'])) { if (!empty($arrayfields['u.statut']['checked'])) { // Status print ''; - print $form->selectarray('search_statut', array('-1'=>'', '0'=>$langs->trans('Disabled'), '1'=>$langs->trans('Enabled')), $search_statut, 0, 0, 0, '', 0, 0, 0, '', 'minwidth75imp'); + print $form->selectarray('search_statut', array('-1'=>'', '0'=>$langs->trans('Disabled'), '1'=>$langs->trans('Enabled')), $search_statut, 0, 0, 0, '', 0, 0, 0, '', 'search_status minwidth75imp maxwidth125 onrightofpage'); print ''; } // Action column diff --git a/htdocs/user/note.php b/htdocs/user/note.php index 4b64a15d217..b3ee9398374 100644 --- a/htdocs/user/note.php +++ b/htdocs/user/note.php @@ -94,10 +94,13 @@ if ($id) { $linkback = ''.$langs->trans("BackToList").''; } - $morehtmlref = ''; + $morehtmlref = ''; $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"'); $morehtmlref .= ''; + $urltovirtualcard = '/user/virtualcard.php?id='.((int) $object->id); + $morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->trans("PublicVirtualCardUrl").' - '.$object->getFullName($langs), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', 'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard, '', 'nohover'); + dol_banner_tab($object, 'id', $linkback, $user->hasRight("user", "user", "read") || $user->admin, 'rowid', 'ref', $morehtmlref); print '
'; diff --git a/htdocs/user/notify/card.php b/htdocs/user/notify/card.php index e20d7be3d9a..e63269d5fa6 100644 --- a/htdocs/user/notify/card.php +++ b/htdocs/user/notify/card.php @@ -155,10 +155,13 @@ if ($result > 0) { $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = ''; + $morehtmlref = ''; $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"'); $morehtmlref .= ''; + $urltovirtualcard = '/user/virtualcard.php?id='.((int) $object->id); + $morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->trans("PublicVirtualCardUrl").' - '.$object->getFullName($langs), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', 'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard, '', 'nohover'); + dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin, 'rowid', 'ref', $morehtmlref, '', 0, '', '', 0, ''); print '
'; diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php index 3d2e3240ce3..ee0f1d13914 100644 --- a/htdocs/user/param_ihm.php +++ b/htdocs/user/param_ihm.php @@ -343,10 +343,13 @@ if ($action == 'edit') { $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = ''; + $morehtmlref = ''; $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"'); $morehtmlref .= ''; + $urltovirtualcard = '/user/virtualcard.php?id='.((int) $object->id); + $morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->trans("PublicVirtualCardUrl").' - '.$object->getFullName($langs), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', 'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard, '', 'nohover'); + dol_banner_tab($object, 'id', $linkback, $user->hasRight("user", "user", "read") || $user->admin, 'rowid', 'ref', $morehtmlref); print '
'; diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index a65762b6183..23265513730 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -255,10 +255,13 @@ if ($user->hasRight("user", "user", "read") || $user->admin) { $linkback = ''.$langs->trans("BackToList").''; } -$morehtmlref = ''; +$morehtmlref = ''; $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"'); $morehtmlref .= ''; +$urltovirtualcard = '/user/virtualcard.php?id='.((int) $object->id); +$morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->trans("PublicVirtualCardUrl").' - '.$object->getFullName($langs), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', 'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard, '', 'nohover'); + dol_banner_tab($object, 'id', $linkback, $user->hasRight("user", "user", "read") || $user->admin, 'rowid', 'ref', $morehtmlref); diff --git a/htdocs/user/vcard.php b/htdocs/user/vcard.php index 6e7035d99ec..695cd0e556e 100644 --- a/htdocs/user/vcard.php +++ b/htdocs/user/vcard.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2023 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2020 Tobias Sekan * Copyright (C) 2021-2022 Anthony Berton @@ -21,8 +21,8 @@ /** * \file htdocs/user/vcard.php - * \ingroup societe - * \brief Onglet vcard d'un user + * \ingroup user + * \brief Page to return a user vcard */ // Load Dolibarr environment @@ -31,9 +31,6 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/vcard.class.php'; -$user2 = new User($db); - - $id = GETPOST('id', 'int'); // Security check @@ -44,106 +41,38 @@ if ($user->socid > 0) { $feature2 = 'user'; $result = restrictedArea($user, 'user', $id, 'user', $feature2); - -$result = $user2->fetch($id); +$object = new User($db); +$result = $object->fetch($id); if ($result <= 0) { - dol_print_error($user2->error); + dol_print_error($object->error); exit; } -$physicalperson = 1; - +// Data from linked company $company = new Societe($db); -if ($user2->socid) { - $result = $company->fetch($user2->socid); +if ($object->socid > 0) { + $result = $company->fetch($object->socid); } + +/* + * View + */ + // We create VCard $v = new vCard(); -$v->setProdId('Dolibarr '.DOL_VERSION); - -$v->setUid('DOLIBARR-USERID-'.$user2->id); -$v->setName($user2->lastname, $user2->firstname, "", $user2->civility_code, ""); -$v->setFormattedName($user2->getFullName($langs, 1)); - -$v->setPhoneNumber($user2->office_phone, "TYPE=WORK;VOICE"); -$v->setPhoneNumber($user2->personal_mobile, "TYPE=HOME;VOICE"); -$v->setPhoneNumber($user2->user_mobile, "TYPE=CELL;VOICE"); -$v->setPhoneNumber($user2->office_fax, "TYPE=WORK;FAX"); - -$country = $user2->country_code ? $user2->country : ''; - -$v->setAddress("", "", $user2->address, $user2->town, $user2->state, $user2->zip, $country, "TYPE=WORK;POSTAL"); -$v->setLabel("", "", $user2->address, $user2->town, $user2->state, $user2->zip, $country, "TYPE=WORK"); - -$v->setEmail($user2->email, "TYPE=WORK"); -$v->setNote($user2->note_public); -$v->setTitle($user2->job); - -// Data from linked company -if ($company->id) { - $v->setURL($company->url, "TYPE=WORK"); - if (!$user2->office_phone) { - $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE"); - } - if (!$user2->office_fax) { - $v->setPhoneNumber($company->fax, "TYPE=WORK;FAX"); - } - if (!$user2->zip) { - $v->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK;POSTAL"); - } - - // when company e-mail is empty, use only user e-mail - if (empty(trim($company->email))) { - // was set before, don't set twice - } elseif (empty(trim($user2->email))) { - // when user e-mail is empty, use only company e-mail - $v->setEmail($company->email, "TYPE=WORK"); - } else { - $tmpuser2 = explode("@", trim($user2->email)); - $tmpcompany = explode("@", trim($company->email)); - - if (strtolower(end($tmpuser2)) == strtolower(end($tmpcompany))) { - // when e-mail domain of user and company are the same, use user e-mail at first (and company e-mail at second) - $v->setEmail($user2->email, "TYPE=WORK"); - - // support by Microsoft Outlook (2019 and possible earlier) - $v->setEmail($company->email, 'INTERNET'); - } else { - // when e-mail of user and company complete different use company e-mail at first (and user e-mail at second) - $v->setEmail($company->email, "TYPE=WORK"); - - // support by Microsoft Outlook (2019 and possible earlier) - $v->setEmail($user2->email, 'INTERNET'); - } - } - - // Si user lie a un tiers non de type "particulier" - if ($company->typent_code != 'TE_PRIVATE') { - $v->setOrg($company->name); - } -} - -// Personal informations -$v->setPhoneNumber($user2->personal_mobile, "TYPE=HOME;VOICE"); -if ($user2->birth) { - $v->setBirthday($user2->birth); -} - -$db->close(); - -// Renvoi la VCard au navigateur - -$output = $v->getVCard(); +$output = $v->buildVCardString($object, $company, $langs); $filename = trim(urldecode($v->getFileName())); // "Nom prenom.vcf" $filenameurlencoded = dol_sanitizeFileName(urlencode($filename)); //$filename = dol_sanitizeFileName($filename); +top_httphead('text/x-vcard; name="'.$filename.'"'); header("Content-Disposition: attachment; filename=\"".$filename."\""); header("Content-Length: ".dol_strlen($output)); header("Connection: close"); -header("Content-Type: text/x-vcard; name=\"".$filename."\""); print $output; + +$db->close(); diff --git a/htdocs/user/virtualcard.php b/htdocs/user/virtualcard.php new file mode 100644 index 00000000000..04f8fb42030 --- /dev/null +++ b/htdocs/user/virtualcard.php @@ -0,0 +1,291 @@ + + * Copyright (C) 2005-2015 Regis Houssin + * + * 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/user/virtualcard.php + * \ingroup core + * \brief Page to setup a virtual card + */ + +// Load Dolibarr environment +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; + +// Load translation files required by page +$langs->loadLangs(array("users", "companies")); + +// Security check +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$dol_openinpopup = GETPOST('dol_openinpopup', 'aZ09'); + +if (empty($id) && empty($ref)) { + $id = $user->id; +} + +$object = new User($db); +if ($id > 0 || !empty($ref)) { + $result = $object->fetch($id, $ref, '', 1); + $object->getrights(); +} + +// Security check +$socid = 0; +if ($user->socid > 0) { + $socid = $user->socid; +} +$feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user'); + +$result = restrictedArea($user, 'user', $id, 'user&user', $feature2); + +// If user is not the user that read and has no permission to read other users, we stop +if (($object->id != $user->id) && empty($user->rights->user->user->lire)) { + accessforbidden(); +} + +/* + * Actions + */ + +if ($action == 'update') { + $tmparray = array(); + $tmparray['USER_PUBLIC_HIDE_PHOTO'] = (GETPOST('USER_PUBLIC_HIDE_PHOTO') ? 1 : 0); + $tmparray['USER_PUBLIC_HIDE_JOBPOSITION'] = (GETPOST('USER_PUBLIC_HIDE_JOBPOSITION') ? 1 : 0); + $tmparray['USER_PUBLIC_HIDE_EMAIL'] = (GETPOST('USER_PUBLIC_HIDE_EMAIL') ? 1 : 0); + $tmparray['USER_PUBLIC_HIDE_OFFICE_PHONE'] = (GETPOST('USER_PUBLIC_HIDE_OFFICE_PHONE') ? 1 : 0); + $tmparray['USER_PUBLIC_HIDE_OFFICE_FAX'] = (GETPOST('USER_PUBLIC_HIDE_OFFICE_FAX') ? 1 : 0); + $tmparray['USER_PUBLIC_HIDE_USER_MOBILE'] = (GETPOST('USER_PUBLIC_HIDE_USER_MOBILE') ? 1 : 0); + $tmparray['USER_PUBLIC_HIDE_BIRTH'] = (GETPOST('USER_PUBLIC_HIDE_BIRTH') ? 1 : 0); + $tmparray['USER_PUBLIC_HIDE_SOCIALNETWORKS'] = (GETPOST('USER_PUBLIC_HIDE_SOCIALNETWORKS') ? 1 : 0); + $tmparray['USER_PUBLIC_HIDE_ADDRESS'] = (GETPOST('USER_PUBLIC_HIDE_ADDRESS') ? 1 : 0); + $tmparray['USER_PUBLIC_HIDE_COMPANY'] = (GETPOST('USER_PUBLIC_HIDE_COMPANY') ? 1 : 0); + $tmparray['USER_PUBLIC_MORE'] = (GETPOST('USER_PUBLIC_MORE') ? GETPOST('USER_PUBLIC_MORE') : ''); + + dol_set_user_param($db, $conf, $object, $tmparray); +} + +if ($action == 'setUSER_ENABLE_PUBLIC') { + if (GETPOST('value')) { + $tmparray = array('USER_ENABLE_PUBLIC' => 1); + } else { + $tmparray = array('USER_ENABLE_PUBLIC' => 0); + } + dol_set_user_param($db, $conf, $object, $tmparray); +} + + +/* + * View + */ + +$form = new Form($db); + +$person_name = !empty($object->firstname) ? $object->lastname.", ".$object->firstname : $object->lastname; +$title = $person_name." - ".$langs->trans('Info'); +$help_url = ''; +llxHeader('', $title, $help_url); + +$head = user_prepare_head($object); + +$title = $langs->trans("User"); +//print dol_get_fiche_head($head, 'info', $title, -1, 'user'); + + +$linkback = ''; + +if ($user->rights->user->user->lire || $user->admin) { + $linkback = ''.$langs->trans("BackToList").''; +} + +$morehtmlref = ''; +$morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"'); +$morehtmlref .= ''; + +$urltovirtualcard = '/user/virtualcard.php?id='.((int) $object->id); +$morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->trans("PublicVirtualCardUrl").' - '.$object->getFullName($langs), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', 'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard, '', 'nohover'); + +//dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin, 'rowid', 'ref', $morehtmlref); + + +print '
'; + +print '
'; + +/* + +print '
'; +//print '
'; + +print '
'; +*/ + +print ''.$langs->trans("UserPublicPageDesc").'

'; + +$param = '&id='.((int) $object->id); +$param .= '&dol_openinpopup=1'; + +$enabledisablehtml = $langs->trans("EnablePublicVirtualCard").' '; +if (!getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) { + // Button off, click to enable + $enabledisablehtml .= ''; + $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off'); + $enabledisablehtml .= ''; +} else { + // Button on, click to disable + $enabledisablehtml .= ''; + $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on'); + $enabledisablehtml .= ''; +} +print $enabledisablehtml; +print ''; + +print '

'; + +print '
'; +print ''; +print ''; +print ''; + +if (getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) { + print '
'; + //print $langs->trans('FollowingLinksArePublic').'
'; + print img_picto('', 'globe').' '.$langs->trans('PublicVirtualCardUrl').'
'; + + $fullexternaleurltovirtualcard = $object->getOnlineVirtualCardUrl(); + + print ''; + print ajax_autoselect('publicurluser'); + + print '
'; + + print '
'; + print ''; + + print ''; + print ''; + print ''; + print "\n"; + + // User photo + print '\n"; + + // Job position + print '\n"; + + // Email + print '\n"; + + // Office phone + print '\n"; + + // Office fax + print '\n"; + + // User mobile + print '\n"; + + // User mobile + print '\n"; + + // Social networks + print '\n"; + + // Address + print '\n"; + + // Company name + print '\n"; + + // More + print '\n"; + + print '
'.$langs->trans("Options").''.$langs->trans("Value").'
'; + print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Photo")); + print ''; + print $form->selectyesno("USER_PUBLIC_HIDE_PHOTO", (getDolUserInt('USER_PUBLIC_HIDE_PHOTO', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_PHOTO', 0, $object) : 0), 1); + print "
'; + print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("PostOrFunction")); + print ''; + print $form->selectyesno("USER_PUBLIC_HIDE_JOBPOSITION", (getDolUserInt('USER_PUBLIC_HIDE_JOBPOSITION', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_JOBPOSITION', 0, $object) : 0), 1); + print "
'; + print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Email")); + print ''; + print $form->selectyesno("USER_PUBLIC_HIDE_EMAIL", (getDolUserInt('USER_PUBLIC_HIDE_EMAIL', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_EMAIL', 0, $object) : 0), 1); + print "
'; + print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("PhonePro")); + print ''; + print $form->selectyesno("USER_PUBLIC_HIDE_OFFICE_PHONE", (getDolUserInt('USER_PUBLIC_HIDE_OFFICE_PHONE', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_OFFICE_PHONE', 0, $object) : 0), 1); + print "
'; + print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Fax")); + print ''; + print $form->selectyesno("USER_PUBLIC_HIDE_OFFICE_FAX", (getDolUserInt('USER_PUBLIC_HIDE_OFFICE_FAX', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_OFFICE_FAX', 0, $object) : 0), 1); + print "
'; + print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("PhoneMobile")); + print ''; + print $form->selectyesno("USER_PUBLIC_HIDE_USER_MOBILE", (getDolUserInt('USER_PUBLIC_HIDE_USER_MOBILE', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_USER_MOBILE', 0, $object) : 0), 1); + print "
'; + print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Birthdate")); + print ''; + print $form->selectyesno("USER_PUBLIC_HIDE_BIRTH", (getDolUserInt('USER_PUBLIC_HIDE_BIRTH', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_BIRTH', 0, $object) : 0), 1); + print "
'; + print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("SocialNetworksInformation")); + print ''; + print $form->selectyesno("USER_PUBLIC_HIDE_SOCIALNETWORKS", (getDolUserInt('USER_PUBLIC_HIDE_SOCIALNETWORKS', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_SOCIALNETWORKS', 0, $object) : 0), 1); + print "
'; + print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Address")); + print ''; + print $form->selectyesno("USER_PUBLIC_HIDE_ADDRESS", (getDolUserInt('USER_PUBLIC_HIDE_ADDRESS', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_ADDRESS', 0, $object) : 0), 1); + print "
'; + print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("CompanySection")); + print ''; + print $form->selectyesno("USER_PUBLIC_HIDE_COMPANY", (getDolUserInt('USER_PUBLIC_HIDE_COMPANY', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_COMPANY', 0, $object) : 0), 1); + print "
'; + print $langs->trans("Text"); + print ''; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $extendededitor = 0; // We force no WYSIWYG editor + $doleditor = new DolEditor('USER_PUBLIC_MORE', getDolUserString('USER_PUBLIC_MORE', '', $object), '', 160, 'dolibarr_notes', '', false, false, $extendededitor, ROWS_5, '90%'); + $doleditor->Create(); + print "
'; + print '
'; + + print '
'; + print $form->buttonsSaveCancel("Save", ($dol_openinpopup ? "Cancel" : ""), array(), 0, '', $dol_openinpopup); + print '
'; +} + + +print dol_get_fiche_end(); + +print '
'; + + +print '
'; + + +print dol_get_fiche_end(); + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/variants/card.php b/htdocs/variants/card.php index 634290ca187..5f1065f5171 100644 --- a/htdocs/variants/card.php +++ b/htdocs/variants/card.php @@ -305,7 +305,7 @@ if ($action == 'create') { // Show object lines $result = $object->getLinesArray(); - print load_fiche_titre($langs->trans("PossibleValues") . (!empty($object->lines) ? ' (' . count($object->lines) . ')' : '')); + print load_fiche_titre($langs->trans("PossibleValues") . (!empty($object->lines) ? '(' . count($object->lines) . ')' : '')); print '
diff --git a/htdocs/variants/class/ProductAttribute.class.php b/htdocs/variants/class/ProductAttribute.class.php index ae82873d8bd..74ff3fe238c 100644 --- a/htdocs/variants/class/ProductAttribute.class.php +++ b/htdocs/variants/class/ProductAttribute.class.php @@ -119,6 +119,11 @@ class ProductAttribute extends CommonObject */ public $line; + /** + * @var int Number of product that use this attribute + */ + public $is_used_by_products; + /** * Constructor @@ -914,7 +919,7 @@ class ProductAttribute extends CommonObject $parameters = array('rowid' => $rowid, 'position' => $position); $action = ''; $reshook = $hookmanager->executeHooks('afterPositionOfAttributeUpdate', $parameters, $this, $action); - return 1; + return ($reshook >= 0 ? 1 : -1); } } diff --git a/htdocs/variants/class/ProductCombination2ValuePair.class.php b/htdocs/variants/class/ProductCombination2ValuePair.class.php index dee18dc99e1..5f4ab8480a5 100644 --- a/htdocs/variants/class/ProductCombination2ValuePair.class.php +++ b/htdocs/variants/class/ProductCombination2ValuePair.class.php @@ -83,9 +83,11 @@ class ProductCombination2ValuePair /** * Creates a product combination 2 value pair - * @return int <0 KO, >0 OK + * + * @param User $user User that create + * @return int <0 KO, >0 OK */ - public function create() + public function create($user) { $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_attribute_combination2val (fk_prod_combination, fk_prod_attr, fk_prod_attr_val) diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 6949ccb183f..5128f31d0c5 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -851,15 +851,15 @@ if (!empty($id) || !empty($ref)) { $aaa = ''; if (count($productCombinations)) { - $aaa = ''; - $aaa .= ''; $aaa .= ' '; - $aaa .= ' '; - $aaa .= ' '; - $aaa .= ' '; - $aaa .= ' '; - $aaa .= ' '; + $aaa .= ' '; + $aaa .= ' '; + $aaa .= ' '; + $aaa .= ' '; + $aaa .= ' '; $aaa .= ''; + $aaa .= ajax_combobox("bulk_action"); $aaa .= ''; } $massactionbutton = $aaa; diff --git a/htdocs/variants/tpl/productattributevalueline_edit.tpl.php b/htdocs/variants/tpl/productattributevalueline_edit.tpl.php index 3b842962258..60fc81c7418 100644 --- a/htdocs/variants/tpl/productattributevalueline_edit.tpl.php +++ b/htdocs/variants/tpl/productattributevalueline_edit.tpl.php @@ -54,7 +54,7 @@ $coldisplay++; ref); ?>"> $line); + $parameters = array('line' => $line); $reshook = $hookmanager->executeHooks('formEditProductOptions', $parameters, $object, $action); if (!empty($hookmanager->resPrint)) { print $hookmanager->resPrint; diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php index d676f8a6ee9..2c2c93acbca 100644 --- a/htdocs/viewimage.php +++ b/htdocs/viewimage.php @@ -52,44 +52,34 @@ if (!defined('NOREQUIREAJAX')) { // Some value of modulepart can be used to get resources that are public so no login are required. // Note that only directory logo is free to access without login. -if (isset($_GET["modulepart"]) && $_GET["modulepart"] == 'mycompany' && preg_match('/^\/?logos\//', $_GET['file'])) { - if (!defined("NOLOGIN")) { - define("NOLOGIN", 1); +$needlogin = 1; +if (isset($_GET["modulepart"])) { + // For logo of company + if ($_GET["modulepart"] == 'mycompany' && preg_match('/^\/?logos\//', $_GET['file'])) { + $needlogin = 0; } - if (!defined("NOCSRFCHECK")) { - define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. + // For barcode live generation + if ($_GET["modulepart"] == 'barcode') { + $needlogin = 0; } - if (!defined("NOIPCHECK")) { - define("NOIPCHECK", 1); // Do not check IP defined into conf $dolibarr_main_restrict_ip + // Some value of modulepart can be used to get resources that are public so no login are required. + if ($_GET["modulepart"] == 'medias') { + $needlogin = 0; + } + if ($_GET["modulepart"] == 'userphotopublic') { + $needlogin = 0; + } + // Used by TakePOS Auto Order + if ($_GET["modulepart"] == 'product' && isset($_GET["publictakepos"])) { + $needlogin = 0; } } // For direct external download link, we don't need to load/check we are into a login session -if (isset($_GET["hashp"]) && !defined("NOLOGIN")) { - if (!defined("NOLOGIN")) { - define("NOLOGIN", 1); - } - if (!defined("NOCSRFCHECK")) { - define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. - } - if (!defined("NOIPCHECK")) { - define("NOIPCHECK", 1); // Do not check IP defined into conf $dolibarr_main_restrict_ip - } +if (isset($_GET["hashp"])) { + $needlogin = 0; } -// Some value of modulepart can be used to get resources that are public so no login are required. -if (isset($_GET["modulepart"]) && $_GET["modulepart"] == 'medias') { - if (!defined("NOLOGIN")) { - define("NOLOGIN", 1); - } - if (!defined("NOCSRFCHECK")) { - define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. - } - if (!defined("NOIPCHECK")) { - define("NOIPCHECK", 1); // Do not check IP defined into conf $dolibarr_main_restrict_ip - } -} - -// Used by TakePOS Auto Order -if (isset($_GET["modulepart"]) && $_GET["modulepart"] == 'product' && isset($_GET["publictakepos"])) { +// If nologin required +if (!$needlogin) { if (!defined("NOLOGIN")) { define("NOLOGIN", 1); } @@ -130,11 +120,11 @@ require 'main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $action = GETPOST('action', 'aZ09'); -$original_file = GETPOST('file', 'alphanohtml'); // Do not use urldecode here ($_GET are already decoded by PHP). -$hashp = GETPOST('hashp', 'aZ09'); -$modulepart = GETPOST('modulepart', 'alpha'); +$original_file = GETPOST('file', 'alphanohtml'); // Do not use urldecode here ($_GET are already decoded by PHP). +$hashp = GETPOST('hashp', 'aZ09', 1); // Must be read only by GET +$modulepart = GETPOST('modulepart', 'alpha', 1); // Must be read only by GET $urlsource = GETPOST('urlsource', 'alpha'); -$entity = GETPOST('entity', 'int') ?GETPOST('entity', 'int') : $conf->entity; +$entity = (GETPOST('entity', 'int') ? GETPOST('entity', 'int') : $conf->entity); // Security check if (empty($modulepart) && empty($hashp)) { @@ -148,7 +138,6 @@ if ($modulepart == 'fckeditor') { } - /* * Actions */ diff --git a/htdocs/webhook/class/target.class.php b/htdocs/webhook/class/target.class.php index 134eb99ef05..fa54f11ddb9 100644 --- a/htdocs/webhook/class/target.class.php +++ b/htdocs/webhook/class/target.class.php @@ -912,8 +912,8 @@ class Target extends CommonObject $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_target = '.((int) $this->id))); if (is_numeric($result)) { - $this->error = $this->error; - $this->errors = $this->errors; + $this->error = $objectline->error; + $this->errors = $objectline->errors; return $result; } else { $this->lines = $result; diff --git a/htdocs/webhook/target_card.php b/htdocs/webhook/target_card.php index 83f2008703f..a35f04d0138 100644 --- a/htdocs/webhook/target_card.php +++ b/htdocs/webhook/target_card.php @@ -430,7 +430,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $parameters = array(); $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } if (empty($reshook)) $object->formAddObjectLine(1, $mysoc, $soc); } diff --git a/htdocs/webservices/server_order.php b/htdocs/webservices/server_order.php index 65357174019..0f0eb79d10e 100644 --- a/htdocs/webservices/server_order.php +++ b/htdocs/webservices/server_order.php @@ -741,9 +741,9 @@ function createOrder($authentication, $order) $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label($elementtype, true); if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { - foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) { - $key = 'options_'.$key; - $newline->array_options[$key] = $line[$key]; + foreach ($extrafields->attributes[$elementtype]['label'] as $tmpkey => $tmplabel) { + $tmpkey = 'options_'.$tmpkey; + $newline->array_options[$tmpkey] = $line[$tmpkey]; } } diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php index 25eeec6430f..bf46b063e64 100644 --- a/htdocs/webservices/server_productorservice.php +++ b/htdocs/webservices/server_productorservice.php @@ -962,7 +962,7 @@ function getListOfProductsOrServices($authentication, $filterproduct) * Get list of products for a category * * @param array $authentication Array of authentication information - * @param array $id Category id + * @param int $id Category id * @param Translate $lang Force lang * @return array Array result */ diff --git a/htdocs/webservices/server_thirdparty.php b/htdocs/webservices/server_thirdparty.php index 800c2e0e2a2..1fe15576860 100644 --- a/htdocs/webservices/server_thirdparty.php +++ b/htdocs/webservices/server_thirdparty.php @@ -736,7 +736,7 @@ function getListOfThirdParties($authentication, $filterthirdparty) if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafields->attributes[$elementtype]['label']) && count($extrafields->attributes[$elementtype]['label'])) { foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label) { if (isset($obj->{$key})) { - $extrafieldsOptions['options_'.$key] = $obj->{$key}; + $extrafieldsOptions['options_'.$key] = $obj->$key; } } } diff --git a/htdocs/website/class/websitepage.class.php b/htdocs/website/class/websitepage.class.php index 8660ca0b0c1..c4efd987d0b 100644 --- a/htdocs/website/class/websitepage.class.php +++ b/htdocs/website/class/websitepage.class.php @@ -50,12 +50,24 @@ class WebsitePage extends CommonObject */ public $picto = 'file-code'; + /** + * @var string Field with ID of parent key if this field has a parent or for child tables + */ + public $fk_element = 'fk_website_page'; + + /** + * @var array List of child tables. To know object to delete on cascade. + */ + protected $childtablesoncascade = array('categorie_website_page'); + /** * @var int ID */ public $fk_website; + public $fk_page; // If translation of another page + public $pageurl; public $aliasalt; public $type_container; @@ -179,35 +191,6 @@ class WebsitePage extends CommonObject // END MODULEBUILDER PROPERTIES - // If this object has a subtable with lines - - // /** - // * @var string Name of subtable line - // */ - //public $table_element_line = 'mymodule_myobjectline'; - - /** - * @var string Field with ID of parent key if this field has a parent or for child tables - */ - public $fk_element = 'fk_website_page'; - - // /** - // * @var string Name of subtable class that manage subtable lines - // */ - //public $class_element_line = 'MyObjectline'; - - /** - * @var array List of child tables. To test if we can delete object. - */ - //protected $childtables=array(); - - /** - * @var array List of child tables. To know object to delete on cascade. - */ - protected $childtablesoncascade = array('categorie_website_page'); - - - /** * Constructor * diff --git a/htdocs/website/index.php b/htdocs/website/index.php index ae3362ab9d6..2cb775019e6 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -3294,7 +3294,7 @@ if (!GETPOST('hide_websitemenu')) { } isEditingEnabled = false; } - }; + } }); '; print $langs->trans("EditInLine"); diff --git a/htdocs/workstation/class/workstation.class.php b/htdocs/workstation/class/workstation.class.php index 1213929fed9..6f81c4a28eb 100644 --- a/htdocs/workstation/class/workstation.class.php +++ b/htdocs/workstation/class/workstation.class.php @@ -132,42 +132,6 @@ class Workstation extends CommonObject // END MODULEBUILDER PROPERTIES - // If this object has a subtable with lines - - /** - * @var int Name of subtable line - */ - //public $table_element_line = 'workstation_workstationline'; - - /** - * @var int Field with ID of parent key if this object has a parent - */ - //public $fk_element = 'fk_workstation'; - - /** - * @var int Name of subtable class that manage subtable lines - */ - //public $class_element_line = 'Workstationline'; - - /** - * @var array List of child tables. To test if we can delete object. - */ - //protected $childtables = array(); - - /** - * @var array List of child tables. To know object to delete on cascade. - * If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will - * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object - */ - //protected $childtablesoncascade = array('workstation_workstationdet'); - - /** - * @var WorkstationLine[] Array of subtable lines - */ - //public $lines = array(); - - - /** * Constructor * @@ -919,8 +883,8 @@ class Workstation extends CommonObject $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_workstation = '.((int) $this->id))); if (is_numeric($result)) { - $this->error = $this->error; - $this->errors = $this->errors; + $this->error = $objectline->error; + $this->errors = $objectline->errors; return $result; } diff --git a/qodana.yaml b/qodana.yaml index 08dc6c18395..44da591f9de 100644 --- a/qodana.yaml +++ b/qodana.yaml @@ -1,6 +1,6 @@ version: "1.0" linter: jetbrains/qodana-php:2022.3-eap -failThreshold: 0 +failThreshold: 20000 profile: name: qodana.recommended exclude: @@ -15,6 +15,7 @@ exclude: - htdocs/custom - htdocs/includes - htdocs/install/doctemplates + - htdocs/modulebuilder/template/test/functionnal - name: PhpIssetCanBeReplacedWithCoalesceInspection - name: PhpRedundantOptionalArgumentInspection - name: PhpLanguageLevelInspection @@ -61,4 +62,24 @@ exclude: - name: PhpClassConstantAccessedViaChildClassInspection - name: RegExpUnnecessaryNonCapturingGroup - name: PhpPregMatchReplaceWithComparisonInspection - - name: PhpArrayWriteIsNotUsedInspection \ No newline at end of file + - name: PhpArrayWriteIsNotUsedInspection + - name: PhpUndefinedNamespaceInspection + - name: PhpArraySearchInBooleanContextInspection + - name: PhpLoopCanBeReplacedWithStrRepeatInspection + - name: PhpPropertyOnlyWrittenInspection + - name: PhpCoveredCharacterInClassInspection + - name: PhpSameParameterValueInspection + - name: PhpSillyAssignmentInspection + - name: PhpConditionCheckedByNextConditionInspection + - name: RegExpSingleCharAlternation + - name: PhpSuspiciousNameCombinationInspection + - name: PhpObjectFieldsAreOnlyWrittenInspection + - name: PhpMissingParentConstructorInspection + - name: PhpWriteAccessToReferencedArrayValueWithoutUnsetInspection + - name: PhpArrayUsedOnlyForWriteInspection + - name: PhpArrayIndexImmediatelyRewrittenInspection + - name: PhpParameterNameChangedDuringInheritanceInspection + - name: PhpDuplicateSwitchCaseBodyInspection + - name: PhpNestedDirNameCallsCanBeReplacedWithLevelParameterInspection + - name: PhpPointlessBooleanExpressionInConditionInspection + - name: PhpUndefinedMethodInspection \ No newline at end of file diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index ec1fbd293d6..cf3f1897638 100755 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -71,6 +71,8 @@ if (empty($conf->global->MAILING_LIMIT_SENDBYCLI)) { $conf->global->MAILING_LIMIT_SENDBYCLI = 0; } +$langs->loadLangs(array("main", "mails")); + /* * Main diff --git a/scripts/members/sync_members_types_ldap2dolibarr.php b/scripts/members/sync_members_types_ldap2dolibarr.php index 12a83633725..58eefbad69a 100755 --- a/scripts/members/sync_members_types_ldap2dolibarr.php +++ b/scripts/members/sync_members_types_ldap2dolibarr.php @@ -21,9 +21,9 @@ */ /** - * \file scripts/members/sync_members_types_ldap2dolibarr.php + * \file scripts/members/sync_members_types_ldap2dolibarr.php * \ingroup ldap member - * \brief Script to update members types into Dolibarr from LDAP + * \brief Script to update members types into Dolibarr from LDAP */ if (!defined('NOSESSION')) { @@ -139,7 +139,7 @@ if ($result >= 0) { // Warning $ldapuser has a key in lowercase foreach ($ldaprecords as $key => $ldapgroup) { $membertype = new AdherentType($db); - $membertype->fetch('', $ldapgroup[$conf->global->LDAP_KEY_MEMBERS_TYPES]); + $membertype->fetch($ldapgroup[$conf->global->LDAP_KEY_MEMBERS_TYPES]); $membertype->label = $ldapgroup[$conf->global->LDAP_MEMBER_TYPE_FIELD_FULLNAME]; $membertype->description = $ldapgroup[$conf->global->LDAP_MEMBER_TYPE_FIELD_DESCRIPTION]; $membertype->entity = $conf->entity; diff --git a/scripts/user/sync_groups_ldap2dolibarr.php b/scripts/user/sync_groups_ldap2dolibarr.php index 67c14a4ee5d..2fe89b92ccb 100755 --- a/scripts/user/sync_groups_ldap2dolibarr.php +++ b/scripts/user/sync_groups_ldap2dolibarr.php @@ -176,17 +176,17 @@ if ($result >= 0) { // 1 - Association des utilisateurs du groupe LDAP au groupe Dolibarr $userList = array(); $userIdList = array(); - foreach ($ldapgroup[$conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS] as $key => $userdn) { - if ($key === 'count') { + foreach ($ldapgroup[getDolGlobalString('LDAP_GROUP_FIELD_GROUPMEMBERS')] as $tmpkey => $userdn) { + if ($tmpkey === 'count') { continue; } if (empty($userList[$userdn])) { // Récupération de l'utilisateur // Schéma rfc2307: les membres sont listés dans l'attribut memberUid sous form de login uniquement - if ($conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS === 'memberUid') { + if (getDolGlobalString('LDAP_GROUP_FIELD_GROUPMEMBERS') === 'memberUid') { $userKey = array($userdn); } else { // Pour les autres schémas, les membres sont listés sous forme de DN complets $userFilter = explode(',', $userdn); - $userKey = $ldap->getAttributeValues('('.$userFilter[0].')', $conf->global->LDAP_KEY_USERS); + $userKey = $ldap->getAttributeValues('('.$userFilter[0].')', getDolGlobalString('LDAP_KEY_USERS')); } if (!is_array($userKey)) { continue; @@ -194,9 +194,9 @@ if ($result >= 0) { $fuser = new User($db); - if ($conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_SID) { + if (getDolGlobalString('LDAP_KEY_USERS') == getDolGlobalString('LDAP_FIELD_SID')) { $fuser->fetch('', '', $userKey[0]); // Chargement du user concerné par le SID - } elseif ($conf->global->LDAP_KEY_USERS == $conf->global->LDAP_FIELD_LOGIN) { + } elseif (getDolGlobalString('LDAP_KEY_USERS') == getDolGlobalString('LDAP_FIELD_LOGIN')) { $fuser->fetch('', $userKey[0]); // Chargement du user concerné par le login } diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index 12c8683bb8f..370a498ad3a 100644 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -442,6 +442,14 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase $this->assertEquals('ios', $tmp['browseros']); $this->assertEquals('tablet', $tmp['layout']); $this->assertEquals('iphone', $tmp['phone']); + + //Lynx + $user_agent = 'Lynx/2.8.8dev.3 libwww‑FM/2.14 SSL‑MM/1.4.1'; + $tmp=getBrowserInfo($user_agent); + $this->assertEquals('lynxlinks', $tmp['browsername']); + $this->assertEquals('2.8.8', $tmp['browserversion']); + $this->assertEquals('unknown', $tmp['browseros']); + $this->assertEquals('classic', $tmp['layout']); }