Skip to content

Commit

Permalink
#303 [Control] add: need counter filetype for prevent multiple docume…
Browse files Browse the repository at this point in the history
…nt in email
  • Loading branch information
nicolas-eoxia committed May 5, 2023
1 parent f1e9150 commit a6323fa
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions view/session/session_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@
if ($object->status == $object::STATUS_LOCKED && $signatory->checkSignatoriesSignatures($object->id, $object->element)) {
$fileparams = dol_most_recent_file($upload_dir . '/' . $object->element . 'document' . '/' . $object->ref);
$file = $fileparams['fullname'];
if (file_exists($file) && !preg_match('/specimen/', $fileparams['name'])) {
if (file_exists($file) && !strstr($fileparams['name'], 'specimen')) {
$forcebuilddoc = 0;
} else {
$forcebuilddoc = 1;
Expand Down Expand Up @@ -674,9 +674,16 @@
}
$filelist = dol_dir_list($upload_dir . '/' . $object->element . 'document' . '/' . $ref, 'files', 0, '', '', 'date', SORT_DESC);
if (!empty($filelist) && is_array($filelist)) {
$filetype = ['attendancesheetdocument' => 0, 'completioncertificatedocument' => 0];
foreach ($filelist as $file) {
if (!preg_match('/specimen/', $file['name'])) {
$files[] = $file['fullname'];
if (!strstr($file['name'], 'specimen')) {
if (strstr($file['name'], str_replace(' ', '_', $langs->transnoentities('attendancesheetdocument'))) && $filetype['attendancesheetdocument'] == 0) {
$files[] = $file['fullname'];
$filetype['attendancesheetdocument'] = 1;
} elseif (strstr($file['name'], str_replace(' ', '_', $langs->transnoentities('completioncertificatedocument'))) && $filetype['completioncertificatedocument'] < $nbTrainee) {
$files[] = $file['fullname'];
$filetype['completioncertificatedocument']++;
}
}
}
}
Expand Down

0 comments on commit a6323fa

Please sign in to comment.