Skip to content

Commit

Permalink
Merge pull request #426 from nicolas-eoxia/fix_hr_project_creation
Browse files Browse the repository at this point in the history
#424 [Admin] fix: HR_PROJECT creation don't create all tasks and missing contact assign
  • Loading branch information
nicolas-eoxia authored Jul 21, 2023
2 parents c6a7622 + 1d97493 commit 1a08f05
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions admin/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@
$project->date_c = $now;
$currentYear = dol_print_date(dol_now(), '%Y');
$fiscalMonthStart = $conf->global->SOCIETE_FISCAL_MONTH_START;
$DateStart = dol_mktime('0', '0', '0', $fiscalMonthStart ?: '1', '1', $currentYear);
$project->date_start = $DateStart;
$dateStart = dol_mktime('0', '0', '0', $fiscalMonthStart ?: '1', '1', $currentYear);
$project->date_start = $dateStart;

$project->usage_task = 1;

$DateStartAddYear = dol_time_plus_duree($DateStart, 1, 'y');
$DateStartAddYearMonth = dol_time_plus_duree($DateStartAddYear, -1, 'd');
$dateEnd = dol_print_date($DateStartAddYearMonth, 'dayrfc');
$dateStartAddYear = dol_time_plus_duree($dateStart, 1, 'y');
$dateStartAddYearMonth = dol_time_plus_duree($dateStartAddYear, -1, 'd');
$dateEnd = dol_print_date($dateStartAddYearMonth, 'dayrfc');
$project->date_end = $dateEnd;
$project->statut = 1;

Expand All @@ -109,7 +109,7 @@
$users = $userTmp->get_full_tree(0, 'u.employee = 1 AND u.fk_soc IS NULL AND u.statut = 1');
if (!empty($users) && is_array($users)) {
foreach ($users as $userSingle) {
$project->add_contact($userSingle['id'], 161, 'internal');
$project->add_contact($userSingle['id'], 'PROJECTCONTRIBUTOR', 'internal');
}
}

Expand All @@ -122,9 +122,9 @@
if (!empty($taskRefClass) && is_readable(DOL_DOCUMENT_ROOT . '/core/modules/project/task/' . $taskRefClass . '.php')) {
require_once DOL_DOCUMENT_ROOT . '/core/modules/project/task/' . $conf->global->PROJECT_TASK_ADDON . '.php';
$modTask = new $taskRefClass();
$taskRef = $modTask->getNextValue('', null);
$modTask->getNextValue('', null);
} else {
$taskRef = '';
$modTask = null;
$error++;
}

Expand All @@ -134,7 +134,7 @@
foreach ($hrProjectTasks as $hrProjectTask) {
$task->date_c = $now;
$task->fk_project = $projectID;
$task->ref = $taskRef;
$task->ref = $modTask->getNextValue('', null);
$task->label = $langs->transnoentities($hrProjectTask['name']);
$taskID = $task->create($user);
dolibarr_set_const($db, $hrProjectTask['code'], $taskID, 'integer', 0, '', $conf->entity);
Expand All @@ -146,7 +146,7 @@
foreach ($users as $userSingle) {
if (is_array($taskArray) && !empty($taskArray)) {
foreach ($taskArray as $task) {
$task->add_contact($userSingle['id'], 181, 'internal');
$task->add_contact($userSingle['id'], 'TASKCONTRIBUTOR', 'internal');
}
}
}
Expand Down

0 comments on commit 1a08f05

Please sign in to comment.