sof...@hephaestos.ovh.adullact.org
unread,Apr 14, 2021, 1:00:26 PM4/14/21Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to openmairi...@googlegroups.com
Author: softime
Date: 2021-04-14 19:00:23 +0200 (Wed, 14 Apr 2021)
New Revision: 10020
Modified:
branches/4.14.0-develop/HISTORY.txt
branches/4.14.0-develop/obj/document_numerise.class.php
branches/4.14.0-develop/tests/binary_files/dyn/config.inc.php
Log:
* WIP : Gestion des pieces de format autre que PDF
Modified: branches/4.14.0-develop/HISTORY.txt
===================================================================
--- branches/4.14.0-develop/HISTORY.txt 2021-04-14 15:40:17 UTC (rev 10019)
+++ branches/4.14.0-develop/HISTORY.txt 2021-04-14 17:00:23 UTC (rev 10020)
@@ -27,6 +27,9 @@
* Correction - Le numéro d'ordre apparait de nouveau dans les fichiers générés
pour SITADEL.
Ticket #9498.
+* Évolution - Modification des extensions de fichiers possibles lors de l'ajout
+ de pièces numérisées.
+ Ticket #????.
4.13.3 (unreleased)
Modified: branches/4.14.0-develop/obj/document_numerise.class.php
===================================================================
--- branches/4.14.0-develop/obj/document_numerise.class.php 2021-04-14 15:40:17 UTC (rev 10019)
+++ branches/4.14.0-develop/obj/document_numerise.class.php 2021-04-14 17:00:23 UTC (rev 10020)
@@ -688,6 +688,19 @@
//
$style .= " col".$nb_col;
+ // Action de prévisualisation
+ $preview_action = sprintf('%s&obj=%s&action=%s&idx=%s&retour=tab', OM_ROUTE_FORM, $obj, 400, $row['document_numerise']);
+ $preview_button = sprintf(
+ $template_icon_preview,
+ $row['document_numerise'],
+ $preview_action,
+ __("Prévisualiser")
+ );
+ $file = $this->f->storage->get($row['uid']);
+ if ($file['metadata']['mimetype'] !== 'application/pdf') {
+ $preview_button = '';
+ }
+
// Si on est dans la visualisation du DA, on affiche le numéro du dossier
// d'instruction auquel est rataché la pièce et le nom du fichier
if ($contexte === 'dossier_autorisation') {
@@ -695,12 +708,7 @@
$ct_list_dn .= sprintf(
$template_line_4col,
$style,
- sprintf(
- $template_icon_preview,
- $row['document_numerise'],
- sprintf('%s&obj=%s&action=%s&idx=%s&retour=tab', OM_ROUTE_FORM, $obj, 400, $row['document_numerise']),
- __("Prévisualiser")
- ),
+ $preview_button,
$row['dossier'],
sprintf(
$template_filename,
@@ -715,13 +723,8 @@
$ct_list_dn .= sprintf(
$template_line_3col,
$style,
+ $preview_button,
sprintf(
- $template_icon_preview,
- $row['document_numerise'],
- sprintf('%s&obj=%s&action=%s&idx=%s&retour=tab', OM_ROUTE_FORM, $obj, 400, $row['document_numerise']),
- __("Prévisualiser")
- ),
- sprintf(
$template_filename,
$row['document_numerise'],
$row['document_numerise'],
@@ -740,12 +743,7 @@
$template_icon_view,
$row['document_numerise']
),
- sprintf(
- $template_icon_preview,
- $row['document_numerise'],
- sprintf('%s&obj=%s&action=%s&idx=%s&retour=tab', OM_ROUTE_FORM, $obj, 400, $row['document_numerise']),
- __("Prévisualiser")
- )
+ $preview_button
),
sprintf(
$template_filename,
@@ -1573,9 +1571,17 @@
$this->valF["date_creation"] = "";
}
- //Génération automatique nom du fichier
+ // Génération automatique du nom du fichier
if ($val["nom_fichier"] == "" || $this->getParameter("maj") != 0) {
- $this->valF['nom_fichier'] = $this->generateFilename($this->valF["date_creation"], $document_numerise_type);
+ // Récupère l'extension sur le fichier temporaire
+ $temporary_test = explode("|", $this->valF['uid']);
+ if (isset($temporary_test[0]) === true && $temporary_test[0] == "tmp") {
+ if (isset($temporary_test[1]) === true) {
+ $tmp_filename = $this->f->storage->getFilename_temporary($temporary_test[1]);
+ $extension = strtolower(substr($tmp_filename, strrpos($tmp_filename, '.')));
+ }
+ }
+ $this->valF['nom_fichier'] = $this->generateFilename($this->valF["date_creation"], $document_numerise_type, $extension);
}
}
@@ -1817,7 +1823,7 @@
//Tableau des contraintes
$params = array(
"constraint" => array(
- "extension" => ".pdf"
+ "extension" => ".gif;.jpg;.jpeg;.png;.pdf;.doc;.docx;.odt;.xls;.xlsx;.ods;.tiff;.bitmap;"
),
);
@@ -2045,18 +2051,19 @@
* Génère le nom du fichier avec les information du formulaire
* @param string $date Date de création du document
* @param string $codeDoc Code du type de document
+ * @param string $ext Extension du fichier
* @return string Nom du fichier
*/
- private function generateFilename($date, $codeDoc) {
+ private function generateFilename($date, $codeDoc, $ext = '.pdf') {
//Change le format de la date
$date = date("Ymd", strtotime($date));
//Compose le nom du fichier date + code document + extension
- $filename = $date.$codeDoc.'.pdf';
+ $filename = $date.$codeDoc.$ext;
$counter = 1;
while ($this->filename_exists_for_dossier_instruction($filename)) {
- $filename = $date.$codeDoc.'-'.$counter.'.pdf';
+ $filename = $date.$codeDoc.'-'.$counter.$ext;
$counter++;
}
//Retourne le nom du fichier
Modified: branches/4.14.0-develop/tests/binary_files/dyn/config.inc.php
===================================================================
--- branches/4.14.0-develop/tests/binary_files/dyn/config.inc.php 2021-04-14 15:40:17 UTC (rev 10019)
+++ branches/4.14.0-develop/tests/binary_files/dyn/config.inc.php 2021-04-14 17:00:23 UTC (rev 10020)
@@ -1,3 +1,4 @@
<?php
$config = array();
+$config["upload_extension"] = ".gif;.jpg;.jpeg;.png;.txt;.pdf;.csv;.doc;.docx;.odt;.xls;.xlsx;.ods;.tiff;.bitmap;";
?>