diff --git a/include/class/document.class.php b/include/class/document.class.php index d3b916760..b55d58e7d 100644 --- a/include/class/document.class.php +++ b/include/class/document.class.php @@ -467,6 +467,9 @@ class Document $this->db->start(); $name=$_FILES['file_upload']['name']; $document_saved=array(); + $http=new HttpInput(); + $aDescription=$http->post("input_desc","array",array()); + $description=""; for ($i=0; $id_lob=$oid; $this->d_filename=$_FILES['file_upload']['name'][$i]; $this->d_mimetype=$_FILES['file_upload']['type'][$i]; - $this->d_description=strip_tags($_POST['input_desc'][$i]); + if ( isset($aDescription[$i])) { + $description=$aDescription[$i]; + } + $this->d_description=$description; // insert into the table $sql="insert into document (ag_id, d_lob,d_filename,d_mimetype,d_number,d_description)" . " values ($1,$2,$3,$4,$5,$6) returning d_id"; @@ -545,8 +551,19 @@ class Document $this->db->start(); $ret=$this->db->exec_sql( "select d_id,d_lob,d_filename,d_mimetype from document where d_id=$1", [$this->d_id]); + if (Database::num_row($ret)==0) { + // send it to stdout + ini_set('zlib.output_compression', 'Off'); + header("Pragma: public"); + header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + header("Cache-Control: must-revalidate"); + header('Content-type: text'); + header('Content-Disposition: attachment;filename="vide.txt"', FALSE); + header("Accept-Ranges: bytes"); + echo "VIDE-EMPTY"; return; } $row=Database::fetch_array($ret, 0); @@ -555,7 +572,7 @@ class Document $this->db->lo_export($row['d_lob'], $tmp); $this->d_mimetype=$row['d_mimetype']; $this->d_filename=$row['d_filename']; - + $file=fopen($tmp, 'r'); // send it to stdout ini_set('zlib.output_compression', 'Off'); header("Pragma: public"); @@ -565,7 +582,6 @@ class Document header('Content-type: '.$this->d_mimetype); header('Content-Disposition: attachment;filename="'.$this->d_filename.'"', FALSE); header("Accept-Ranges: bytes"); - $file=fopen($tmp, 'r'); while (!feof($file)) { echo fread($file, 8192); @@ -573,7 +589,6 @@ class Document fclose($file); unlink($tmp); - $this->db->commit(); } diff --git a/include/class/follow_up.class.php b/include/class/follow_up.class.php index ea0ab2594..6c8c16c1c 100644 --- a/include/class/follow_up.class.php +++ b/include/class/follow_up.class.php @@ -416,6 +416,7 @@ class Follow_Up /* for new files */ $upload=new IFile(); $upload->name="file_upload[]"; + $upload->set_multiple(true); $upload->setAlertOnSize(true); $upload->readOnly=$readonly; $upload->value=""; diff --git a/include/lib/ifile.class.php b/include/lib/ifile.class.php index a0ee85fc0..60a3f38ba 100644 --- a/include/lib/ifile.class.php +++ b/include/lib/ifile.class.php @@ -31,10 +31,23 @@ class IFile extends HtmlInput { // if true , the size is tested and a box is displaid private $alert_on_size; + private $multiple ; // false by default, if true allow to select several files function __construct($p_name = "", $p_value = "", $p_id = "") { parent::__construct($p_name, $p_value, $p_id); $this->alert_on_size=false; + $this->multiple=false; + } + + public function get_multiple(): bool + { + return $this->multiple; + } + + public function set_multiple(bool $multiple): IFile + { + $this->multiple = $multiple; + return $this; } /** @@ -61,7 +74,11 @@ class IFile extends HtmlInput $this->value=($p_value==null)?$this->value:$p_value; if ( $this->readOnly==true) return $this->display(); if ($this->id=="") $this->id=uniqid("file_"); - $r=sprintf('', + $multiple=""; + if ( $this->multiple) $multiple=" multiple "; + + $r=sprintf('', + $multiple, $this->name, $this->id, $this->value); diff --git a/include/template/follow_up-display.php b/include/template/follow_up-display.php index bc2cb14dd..d541393a2 100644 --- a/include/template/follow_up-display.php +++ b/include/template/follow_up-display.php @@ -472,8 +472,26 @@ if ( $this->ag_id > 0 && Document_Option::is_enable_operation_detail($this->dt_i **********************************************************************************************************************/ ?> -
+
+ +
+

Fichiers à ajouter:

+
    +
  1. + input(); + ?> + +
  2. +
+ + "> + +
+
@@ -563,7 +581,7 @@ function addFiles() { try { docAdded=document.getElementById('add_file'); new_element=document.createElement('li'); - new_element.innerHTML=' '; + new_element.innerHTML=''; new_element.innerHTML+='" onclick="document.getElementById(\'add_file\').removeChild(this.parentNode)" class="icon">'; @@ -574,26 +592,7 @@ try { catch(exception) { alert(''); alert(exception.message);} } - -
-

Fichiers à ajouter:

-
    -
  1. - input(); - ?> - - - -
  2. -
- - "> - -
- +
Document créé le ag_timestamp ?> par ag_owner?>