Skip to content

Commit

Permalink
Evarisk#3407 [PP/FP] fix: fetch_lines for clone and DU send mail last…
Browse files Browse the repository at this point in the history
… document
  • Loading branch information
evarisk-micka committed Oct 16, 2023
1 parent a716171 commit d7fad50
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
4 changes: 1 addition & 3 deletions class/firepermit.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ public function createFromClone(User $user, int $fromID, array $options): int

// Load source object
$object->fetch($fromID);
$firepermitdets = $object->lines;

// Load signatory and ressources form source object
$signatories = $signatory->fetchSignatory('', $fromID, $object->element);
Expand Down Expand Up @@ -224,9 +225,6 @@ public function createFromClone(User $user, int $fromID, array $options): int
}

if (!empty($options['firepermit_risk'])) {
$firepermitdet = new PreventionPlanLine($this->db);
$firepermitdets = $firepermitdet->fetchAll('', '', 0, 0, ['fk_firepermit' => $fromID]);

if (is_array($firepermitdets) && !empty($firepermitdets)) {
foreach ($firepermitdets as $line) {
$line->ref = $refFirePermitDetMod->getNextValue($line);
Expand Down
4 changes: 1 addition & 3 deletions class/preventionplan.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ public function createFromClone(User $user, int $fromID, array $options): int

// Load source object
$object->fetch($fromID);
$preventionplandets = $object->lines;

// Load signatory and ressources form source object
$signatories = $signatory->fetchSignatory('', $fromID, $object->element);
Expand Down Expand Up @@ -227,9 +228,6 @@ public function createFromClone(User $user, int $fromID, array $options): int
}

if (!empty($options['preventionplan_risk'])) {
$preventionplandet = new PreventionPlanLine($this->db);
$preventionplandets = $preventionplandet->fetchAll('', '', 0, 0, ['fk_preventionplan' => $fromID]);

if (is_array($preventionplandets) && !empty($preventionplandets)) {
foreach ($preventionplandets as $line) {
$line->ref = $refPreventionPlanDetMod->getNextValue($line);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,12 +469,14 @@

$object->fetch_projet();

if (!in_array($object->element, array('societe', 'user', 'member'))) {
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$fileparams = dol_dir_list($diroutput, 'files', 0, '');
$lastFileKey = is_array($fileparams) && !empty($fileparams) ? count($fileparams) - 2 : 0;
$filevalue[0] = $fileparams[$lastFileKey]['fullname'] ?? 0;
}
if (!in_array($object->element, array('societe', 'user', 'member'))) {
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$fileparams = dol_dir_list($diroutput, 'files', 0, '', [], 'date', 'SORT_DESC');
preg_match('#_(.*)_#U', $fileparams[0]['name'], $lastRef);
foreach ($fileparams as $fileparam) {
preg_match('/' . $lastRef[0] . '/', $fileparam['name']) ? $filevalue[] = $fileparam['fullname'] : 0;
}
}

// Define output language
$outputlangs = $langs;
Expand Down

0 comments on commit d7fad50

Please sign in to comment.