2
0
forked from Wavyzz/dolibarr

Debug clone tasks

This commit is contained in:
Laurent Destailleur
2024-09-10 01:57:46 +02:00
parent 870a5248ec
commit def1cfe27e
6 changed files with 36 additions and 14 deletions

View File

@@ -1776,7 +1776,7 @@ if (!$error && ($massaction == 'clonetasks' || ($action == 'clonetasks' && $conf
// Check if current user is contact of the new project (necessary only if project is not public)
$iscontactofnewproject = 0;
if (empty($newproject->public)) {
$tmps = $newproject->getProjectsAuthorizedForUser($user, 0, 1, 0, '(fk_statut:=:1)'); // We check only open project (cloning on closed is not allowed
$tmps = $newproject->getProjectsAuthorizedForUser($user, 0, 1, 0, '(fk_statut:=:1)'); // We check only open project (cloning on closed is not allowed)
$tmparray = explode(',', $tmps);
if (!in_array($newproject->id, $tmparray)) {
$iscontactofnewproject = 1;
@@ -1799,7 +1799,7 @@ if (!$error && ($massaction == 'clonetasks' || ($action == 'clonetasks' && $conf
require_once DOL_DOCUMENT_ROOT . "/core/modules/project/task/" . getDolGlobalString('PROJECT_TASK_ADDON') . '.php';
$modTask = new $classnamemodtask();
'@phan-var-force ModeleNumRefTask $modTask';
$defaultref = $modTask->getNextValue(null, $newproject);
$defaultref = $modTask->getNextValue(null, $clone_task);
}
if (!$error) {

View File

@@ -124,9 +124,9 @@ class mod_task_simple extends ModeleNumRefTask
/**
* Return next value
*
* @param Societe|string $objsoc Object third party
* @param Task|string $object Object Task
* @return string|-1 Value if OK, -1 if KO
* @param null|Societe|string $objsoc Object third party
* @param null|Task|string $object Object Task
* @return string|int<-1,0> Value if OK, <=0 if KO
*/
public function getNextValue($objsoc, $object)
{

View File

@@ -121,9 +121,9 @@ class mod_task_universal extends ModeleNumRefTask
/**
* Return next value
*
* @param Societe|string $objsoc Object third party
* @param Task|string $object Object task
* @return string|int Value if OK, 0 if KO
* @param null|Societe|string $objsoc Object third party
* @param null|Task|string $object Object Task
* @return string|int<-1,0> Value if OK, <=0 if KO
*/
public function getNextValue($objsoc = '', $object = '')
{

View File

@@ -38,7 +38,7 @@ abstract class ModelePDFTask extends CommonDocGenerator
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
@@ -62,5 +62,19 @@ abstract class ModelePDFTask extends CommonDocGenerator
*/
abstract class ModeleNumRefTask extends CommonNumRefGenerator
{
// No overload code
/**
* Return next value
*
* @param null|Societe|string $objsoc Object third party
* @param null|Task|string $object Object Task
* @return string|int<-1,0> Value if OK, <=0 if KO
*/
abstract public function getNextValue($objsoc, $object);
/**
* Return an example of numbering
*
* @return string Example
*/
abstract public function getExample();
}

View File

@@ -91,11 +91,11 @@ class InterfaceEventOrganization extends DolibarrTriggers
$task->label = $taskLabel;
$task->fk_project = $object->id;
$defaultref = '';
$obj = !getDolGlobalString('PROJECT_TASK_ADDON') ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON;
$classnamemodtask = getDolGlobalString('PROJECT_TASK_ADDON', 'mod_task_simple');
if (getDolGlobalString('PROJECT_TASK_ADDON') && is_readable(DOL_DOCUMENT_ROOT . "/core/modules/project/task/" . getDolGlobalString('PROJECT_TASK_ADDON') . ".php")) {
require_once DOL_DOCUMENT_ROOT . "/core/modules/project/task/" . getDolGlobalString('PROJECT_TASK_ADDON') . '.php';
$modTask = new $obj();
$defaultref = $modTask->getNextValue($object->thirdparty, null);
$modTask = new $classnamemodtask();
$defaultref = $modTask->getNextValue($object->thirdparty, $task);
}
if (is_numeric($defaultref) && $defaultref <= 0) {
$defaultref = '';

View File

@@ -1651,7 +1651,15 @@ class Project extends CommonObject
// No filter. Use this if user has permission to see all project
}
$sql .= $filter;
// Manage filter
$errormessage = '';
$sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage);
if ($errormessage) {
$this->errors[] = $errormessage;
dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
$sql .= $filter;
}
//print $sql;
$resql = $this->db->query($sql);