|
|
@@ -307,6 +307,20 @@ class document
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ static public function getFile(string $_id) {
|
|
|
+ $filePatch = file::download($_id, DIR_DATAS_DOCS);
|
|
|
+
|
|
|
+ if (file_exists($filePatch) && is_readable($filePatch)) {
|
|
|
+ $file_info = new finfo(FILEINFO_MIME_TYPE);
|
|
|
+ $mime_type = $file_info->file($filePatch);
|
|
|
+ header('Content-Type: ' . $mime_type);
|
|
|
+ header('Content-Length: ' . filesize($filePatch));
|
|
|
+ readfile($filePatch);
|
|
|
+ } else {
|
|
|
+ echo "Le fichier n'a pas été trouvé ou n'est pas lisible.";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
static public function get(float $_id){
|
|
|
db::query("SELECT "
|
|
|
. "" . DB_T_DOCUMENTS . ".id, "
|
|
|
@@ -457,8 +471,12 @@ class document
|
|
|
<div><span class="fw-bold">'.$principal["name"].'</span> ('.core::convertBytes($principal["size"]).')</div>
|
|
|
Chargé le '.core::convertDate($principal["creer"]).' par '.$principal["user"].'
|
|
|
<div id="select-attach-'.$principal["id"].'" style="color:red;"></div>
|
|
|
- </div><button type="button" title="Voir le document" class="btn btn btn-outline-secondary" onclick="window.open(\'/document.php?id=' . $principal["id"] . '\', \'_blank\')">' . icon::getFont(["icon" => "bi bi-eye-fill"]) . '</button>
|
|
|
- </li>';
|
|
|
+ </div>
|
|
|
+ <div class="btn-group">
|
|
|
+ <button type="button" title="Voir le document" class="btn btn btn-outline-secondary" onclick="window.open(\'/document.php?id=' . $principal["id"] . '\', \'_blank\')">' . icon::getFont(["icon" => "bi bi-eye-fill"]) . '</button>
|
|
|
+ <button type="button" title="Télécharger le document" class="btn btn btn-outline-secondary" onclick="downloadFile(\'/document.php?id=' . $principal["id"] . '&download=1\', \''.$principal["name"].'\')">' . icon::getFont(["icon" => "bi bi-arrow-down-square-fill"]) . '</button>
|
|
|
+ </div>
|
|
|
+ </li>';
|
|
|
foreach ($_attachs as $key => $attach) {
|
|
|
if($key != "principal"){
|
|
|
echo ' <li class="list-group-item d-flex justify-content-between align-items-start" id="attach-'.$attach["id"].'">
|
|
|
@@ -468,6 +486,7 @@ class document
|
|
|
<div id="select-attach-'.$attach["id"].'"></div>
|
|
|
</div><div class="btn-group">
|
|
|
<button type="button" title="Voir le document" class="btn btn btn-outline-secondary" onclick="window.open(\'/document.php?id=' . $attach["id"] . '\', \'_blank\')">' . icon::getFont(["icon" => "bi bi-eye-fill"]) . '</button>
|
|
|
+ <button type="button" title="Télécharger le document" class="btn btn btn-outline-secondary" onclick="downloadFile(\'/document.php?id=' . $attach["id"] . '&download=1\', \''.$attach["name"].'\')">' . icon::getFont(["icon" => "bi bi-arrow-down-square-fill"]) . '</button>
|
|
|
<button type="button" title="Document mis en avant" class="btn btn btn-outline-primary" onclick="defaultAttachment(\''.$attach["id"].'\')" id="button-default-'.$attach["id"].'">' . icon::getFont(["icon" => "bi bi-star-fill"]) . '</button>
|
|
|
<button type="button" title="Supprimer ce document" class="btn btn-outline-danger" onclick="deleteAttachment(\''.$attach["id"].'\')" id="button-delete-'.$attach["id"].'">' . icon::getFont(["icon" => "bi bi-trash"]) . '</button>
|
|
|
</div>
|