mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-08 18:48:22 +01:00
Merge branch 'develop' into dev_new_default_email_template_ticket
This commit is contained in:
@@ -1,22 +1,22 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2010-2020 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2011-2022 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2012-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2015-2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2016 Bahfir abbes <bafbes@gmail.com>
|
||||
* Copyright (C) 2017 ATM Consulting <support@atm-consulting.fr>
|
||||
* Copyright (C) 2017-2019 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
* Copyright (C) 2017 Rui Strecht <rui.strecht@aliartalentos.com>
|
||||
/* Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2010-2020 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2011-2022 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2012-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2015-2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2016 Bahfir abbes <bafbes@gmail.com>
|
||||
* Copyright (C) 2017 ATM Consulting <support@atm-consulting.fr>
|
||||
* Copyright (C) 2017-2019 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
* Copyright (C) 2017 Rui Strecht <rui.strecht@aliartalentos.com>
|
||||
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2018 Josep Lluís Amador <joseplluis@lliuretic.cat>
|
||||
* Copyright (C) 2023 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
|
||||
* Copyright (C) 2021 Grégory Blémand <gregory.blemand@atm-consulting.fr>
|
||||
* Copyright (C) 2023 Lenin Rivas <lenin.rivas777@gmail.com>
|
||||
* Copyright (C) 2018 Josep Lluís Amador <joseplluis@lliuretic.cat>
|
||||
* Copyright (C) 2023 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
|
||||
* Copyright (C) 2021 Grégory Blémand <gregory.blemand@atm-consulting.fr>
|
||||
* Copyright (C) 2023 Lenin Rivas <lenin.rivas777@gmail.com>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
|
||||
*
|
||||
@@ -4925,6 +4925,15 @@ abstract class CommonObject
|
||||
$haschild = 0;
|
||||
foreach ($arraytoscan as $table => $element) {
|
||||
//print $id.'-'.$table.'-'.$elementname.'<br>';
|
||||
|
||||
// Check if module is enabled (to avoid error if tables of module not created)
|
||||
if (isset($element['enabled']) && !empty($element['enabled'])) {
|
||||
$enabled = (int) dol_eval($element['enabled'], 1);
|
||||
if (empty($enabled)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if element can be deleted
|
||||
$sql = "SELECT COUNT(*) as nb";
|
||||
$sql .= " FROM ".$this->db->prefix().$table." as c";
|
||||
@@ -10333,6 +10342,7 @@ abstract class CommonObject
|
||||
|
||||
if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) {
|
||||
$fieldvalues['date_creation'] = $this->db->idate($now);
|
||||
$this->date_creation = $this->db->idate($now);
|
||||
}
|
||||
if (array_key_exists('fk_user_creat', $fieldvalues) && !($fieldvalues['fk_user_creat'] > 0)) {
|
||||
$fieldvalues['fk_user_creat'] = $user->id;
|
||||
|
||||
@@ -1149,15 +1149,16 @@ class Form
|
||||
* Return list of types of lines (product or service)
|
||||
* Example: 0=product, 1=service, 9=other (for external module)
|
||||
*
|
||||
* @param string $selected Preselected type
|
||||
* @param string $htmlname Name of field in html form
|
||||
* @param int<0,1>|string $showempty Add an empty field
|
||||
* @param int $hidetext Do not show label 'Type' before combo box (used only if there is at least 2 choices to select)
|
||||
* @param integer $forceall 1=Force to show products and services in combo list, whatever are activated modules, 0=No force, 2=Force to show only Products, 3=Force to show only services, -1=Force none (and set hidden field to 'service')
|
||||
* @param string $morecss More css
|
||||
* @param string $selected Preselected type
|
||||
* @param string $htmlname Name of field in html form
|
||||
* @param int<0,1>|string $showempty Add an empty field
|
||||
* @param int $hidetext Do not show label 'Type' before combo box (used only if there is at least 2 choices to select)
|
||||
* @param integer $forceall 1=Force to show products and services in combo list, whatever are activated modules, 0=No force, 2=Force to show only Products, 3=Force to show only services, -1=Force none (and set hidden field to 'service')
|
||||
* @param string $morecss More css
|
||||
* @param int $useajaxcombo 1=Use ajaxcombo
|
||||
* @return void
|
||||
*/
|
||||
public function select_type_of_lines($selected = '', $htmlname = 'type', $showempty = 0, $hidetext = 0, $forceall = 0, $morecss = "")
|
||||
public function select_type_of_lines($selected = '', $htmlname = 'type', $showempty = 0, $hidetext = 0, $forceall = 0, $morecss = "", $useajaxcombo = 1)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs;
|
||||
@@ -1166,11 +1167,11 @@ class Form
|
||||
if ($forceall == 1 || (empty($forceall) && isModEnabled("product") && isModEnabled("service"))
|
||||
|| (empty($forceall) && !isModEnabled('product') && !isModEnabled('service'))) {
|
||||
if (empty($hidetext)) {
|
||||
print $langs->trans("Type") . ': ';
|
||||
print $langs->trans("Type").'...';
|
||||
}
|
||||
print '<select class="flat'.($morecss ? ' '.$morecss : '').'" id="select_' . $htmlname . '" name="' . $htmlname . '">';
|
||||
if ($showempty) {
|
||||
print '<option value="-1"';
|
||||
print '<option value="-1" class="opacitymedium"'.($useajaxcombo ? '' : ' disabled="disabled"');
|
||||
if ($selected == -1) {
|
||||
print ' selected';
|
||||
}
|
||||
@@ -1196,7 +1197,10 @@ class Form
|
||||
print '>' . $langs->trans("Service");
|
||||
|
||||
print '</select>';
|
||||
print ajax_combobox('select_' . $htmlname);
|
||||
|
||||
if ($useajaxcombo) {
|
||||
print ajax_combobox('select_' . $htmlname);
|
||||
}
|
||||
//if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
|
||||
}
|
||||
if ((empty($forceall) && !isModEnabled('product') && isModEnabled("service")) || $forceall == 3) {
|
||||
@@ -2228,7 +2232,17 @@ class Form
|
||||
$sql .= " AND u.fk_soc IS NULL";
|
||||
}
|
||||
if (!empty($morefilter)) {
|
||||
$sql .= " " . $morefilter;
|
||||
$errormessage = '';
|
||||
$sql .= forgeSQLFromUniversalSearchCriteria($morefilter, $errormessage);
|
||||
if ($errormessage) {
|
||||
$this->errors[] = $errormessage;
|
||||
dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
|
||||
if ($outputmode == 0) {
|
||||
return 'Error bad param $morefilter';
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Add hook to filter on user (for example on usergroup define in custom modules)
|
||||
@@ -2425,28 +2439,29 @@ class Form
|
||||
* Return select list of users. Selected users are stored into session.
|
||||
* List of users are provided into $_SESSION['assignedtouser'].
|
||||
*
|
||||
* @param string $action Value for $action
|
||||
* @param string $htmlname Field name in form
|
||||
* @param int<0,1> $show_empty 0=list without the empty value, 1=add empty value
|
||||
* @param int[] $exclude Array list of users id to exclude
|
||||
* @param int<0,1> $disabled If select list must be disabled
|
||||
* @param int[]|string $include Array list of users id to include or 'hierarchy' to have only supervised users
|
||||
* @param int[]|int $enableonly Array list of users id to be enabled. All other must be disabled
|
||||
* @param string $force_entity '0' or Ids of environment to force
|
||||
* @param int $maxlength Maximum length of string into list (0=no limit)
|
||||
* @param int<0,1> $showstatus 0=show user status only if status is disabled, 1=always show user status into label, -1=never show user status
|
||||
* @param string $morefilter Add more filters into sql request
|
||||
* @param int $showproperties Show properties of each attendees
|
||||
* @param int[] $listofuserid Array with properties of each user
|
||||
* @param int[] $listofcontactid Array with properties of each contact
|
||||
* @param int[] $listofotherid Array with properties of each other contact
|
||||
* @return string HTML select string
|
||||
* @param string $action Value for $action
|
||||
* @param string $htmlname Field name in form
|
||||
* @param int<0,1> $show_empty 0=list without the empty value, 1=add empty value
|
||||
* @param int[] $exclude Array list of users id to exclude
|
||||
* @param int<0,1> $disabled If select list must be disabled
|
||||
* @param int[]|''|'hierarchy'|'hierarchyme' $include Array list of users id to include or 'hierarchy' to have only supervised users
|
||||
* @param int[]|int $enableonly Array list of users id to be enabled. All other must be disabled
|
||||
* @param string $force_entity '0' or Ids of environment to force
|
||||
* @param int $maxlength Maximum length of string into list (0=no limit)
|
||||
* @param int<0,1> $showstatus 0=show user status only if status is disabled, 1=always show user status into label, -1=never show user status
|
||||
* @param string $morefilter Add more filters into sql request (Example: '(employee:=:1)'). This value must not come from user input.
|
||||
* @param int $showproperties Show properties of each attendees
|
||||
* @param int[] $listofuserid Array with properties of each user
|
||||
* @param int[] $listofcontactid Array with properties of each contact
|
||||
* @param int[] $listofotherid Array with properties of each other contact
|
||||
* @param int $canremoveowner 1 if we can remove owner, 0=no way
|
||||
* @return string HTML select string
|
||||
* @see select_dolgroups()
|
||||
*/
|
||||
public function select_dolusers_forevent($action = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = array(), $enableonly = array(), $force_entity = '0', $maxlength = 0, $showstatus = 0, $morefilter = '', $showproperties = 0, $listofuserid = array(), $listofcontactid = array(), $listofotherid = array())
|
||||
public function select_dolusers_forevent($action = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = array(), $enableonly = array(), $force_entity = '0', $maxlength = 0, $showstatus = 0, $morefilter = '', $showproperties = 0, $listofuserid = array(), $listofcontactid = array(), $listofotherid = array(), $canremoveowner = 1)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs;
|
||||
global $langs, $user;
|
||||
|
||||
$userstatic = new User($this->db);
|
||||
$out = '';
|
||||
@@ -2479,8 +2494,25 @@ class Form
|
||||
$ownerid = $value['id'];
|
||||
$out .= ' (' . $langs->trans("Owner") . ')';
|
||||
}
|
||||
// Add picto to delete owner/assignee
|
||||
if ($nbassignetouser > 1 && $action != 'view') {
|
||||
$out .= ' <input type="image" style="border: 0px;" src="' . img_picto($langs->trans("Remove"), 'delete', '', 0, 1) . '" value="' . $userstatic->id . '" class="removedassigned reposition" id="removedassigned_' . $userstatic->id . '" name="removedassigned_' . $userstatic->id . '">';
|
||||
$canremoveassignee = 1;
|
||||
if ($i == 0) {
|
||||
// We are on the owner of the event
|
||||
if (!$canremoveowner) {
|
||||
$canremoveassignee = 0;
|
||||
}
|
||||
if (!$user->hasRight('agenda', 'allactions', 'create')) {
|
||||
$canremoveassignee = 0; // Can't remove the owner
|
||||
}
|
||||
} else {
|
||||
// We are not on the owner of the event but on a secondary assignee
|
||||
}
|
||||
if ($canremoveassignee) {
|
||||
// If user has all permission, he should be ableto remove a assignee.
|
||||
// If user has not all permission, he can onlyremove assignee of other (he can't remove itself)
|
||||
$out .= ' <input type="image" style="border: 0px;" src="' . img_picto($langs->trans("Remove"), 'delete', '', 0, 1) . '" value="' . $userstatic->id . '" class="removedassigned reposition" id="removedassigned_' . $userstatic->id . '" name="removedassigned_' . $userstatic->id . '">';
|
||||
}
|
||||
}
|
||||
// Show my availability
|
||||
if ($showproperties) {
|
||||
@@ -7404,6 +7436,7 @@ class Form
|
||||
$hourend = $hourstart;
|
||||
}
|
||||
}
|
||||
|
||||
// Show hour
|
||||
$retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth50 ' . ($fullday ? $fullday . 'hour' : '') . '" id="' . $prefix . 'hour" name="' . $prefix . 'hour">';
|
||||
if ($emptyhours) {
|
||||
@@ -7426,7 +7459,7 @@ class Form
|
||||
|
||||
if ($m) {
|
||||
// Show minutes
|
||||
$retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth50 ' . ($fullday ? $fullday . 'min' : '') . '" id="' . $prefix . 'min" name="' . $prefix . 'min">';
|
||||
$retstring .= '<select ' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth50 ' . ($fullday ? $fullday . 'min' : '') . '" id="' . $prefix . 'min" name="' . $prefix . 'min">';
|
||||
if ($emptyhours) {
|
||||
$retstring .= '<option value="-1"> </option>';
|
||||
}
|
||||
@@ -7444,7 +7477,7 @@ class Form
|
||||
}
|
||||
|
||||
// Add a "Now" link
|
||||
if (!empty($conf->use_javascript_ajax) && $addnowlink) {
|
||||
if (!empty($conf->use_javascript_ajax) && $addnowlink && !$disabled) {
|
||||
// Script which will be inserted in the onClick of the "Now" link
|
||||
$reset_scripts = "";
|
||||
if ($addnowlink == 2) { // local computer time
|
||||
@@ -7531,7 +7564,7 @@ class Form
|
||||
}
|
||||
|
||||
// Add a "Plus one hour" link
|
||||
if ($conf->use_javascript_ajax && $addplusone) {
|
||||
if ($conf->use_javascript_ajax && $addplusone && !$disabled) {
|
||||
// Script which will be inserted in the onClick of the "Add plusone" link
|
||||
$reset_scripts = "";
|
||||
|
||||
@@ -7569,7 +7602,7 @@ class Form
|
||||
}
|
||||
|
||||
// Add a link to set data
|
||||
if ($conf->use_javascript_ajax && !empty($adddateof)) {
|
||||
if ($conf->use_javascript_ajax && !empty($adddateof) && !$disabled) {
|
||||
if (!is_array($adddateof)) {
|
||||
$arrayofdateof = array(array('adddateof' => $adddateof, 'labeladddateof' => $labeladddateof));
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user