';
+ echo_warning(_("1 Echec ").$_FILES["name"]);
+ print '
';
+ }
+
+ }
+ else
+ {
+ //failed
+ // failed
+ print '';
+ echo_warning(_("2 Echec ").$_FILES["name"]);
+ print '
';
+ }
+ }
+
+ $cn->commit();
return;
}
$html = escape_xml($html);
diff --git a/include/export/export_suppl-document.php b/include/export/export_suppl-document.php
new file mode 100644
index 000000000..763614375
--- /dev/null
+++ b/include/export/export_suppl-document.php
@@ -0,0 +1,151 @@
+get('js_id',"number");
+ $operation_id=$http->get("operation_id",'number',0);
+}
+catch (Exception $exc)
+{
+ record_log($exc);
+ return;
+}
+$cn=Dossier::connect();
+
+//------------------------------------------------
+// Download only one document
+//------------------------------------------------
+if ( $js_id > 0)
+{
+ $jrn_def_id=$cn->get_value("select jr_def_id from jrn_sup_document join jrn using (jr_id) where js_id=$1",array($js_id));
+
+ global $g_user;
+ if ($jrn_def_id =="" || $g_user->check_jrn($jrn_def_id) == 'X' )
+ {
+ /* Cannot Access */
+ NoAccess();
+ exit -1;
+ }
+
+ $jrn=new Jrn_Sup_Document_SQL($cn,$js_id);
+ $cn->start();
+ 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: '.$jrn->js_mimetype);
+ header('Content-Disposition: attachment;filename="'.$jrn->js_filename.'"',FALSE);
+ header("Accept-Ranges: bytes");
+ echo $cn->lo_read($jrn->js_lob);
+ $cn->commit();
+ return;
+}
+//------------------------------------------------
+// Download all documents
+//------------------------------------------------
+if ( $operation_id > 0)
+{
+ $jrn_def_id=$cn->get_value("select jr_def_id from jrn where jr_id=$1",array($operation_id));
+
+ global $g_user;
+ if ($jrn_def_id =="" || $g_user->check_jrn($jrn_def_id) == 'X' )
+ {
+ /* Cannot Access */
+ NoAccess();
+ exit -1;
+ }
+ $jr_internal=$cn->get_value("select jr_internal from jrn where jr_id=$1",array($operation_id));
+
+ try {
+ $cn->start();
+ // find all the documents for this operation
+ $a_file=$cn->get_array("select js_lob,js_filename from jrn_sup_document where jr_id=$1",
+ [$operation_id]);
+ // save them into a temp folder
+ if ( count ($a_file) == 0 ) {
+ // @TODO send an empty file
+ return;
+ }
+ $a_file_dwn=array();
+ $store = tempnam($_ENV['TMP'], 'pdf_');
+ unlink($store);
+ mkdir($store);
+ $nb_file=count($a_file);
+ for($i=0;$i < $nb_file;$i++)
+ {
+ $filename=sprintf("%s".DIRECTORY_SEPARATOR."%s",
+ $store,
+ $a_file[$i]['js_filename']);
+
+ // avoid to overwrite a previous file with same name
+ if (file_exists($filename)) {
+ $dup=1;
+ do {
+ $filename=sprintf("%s".DIRECTORY_SEPARATOR."%s-%s",
+ $store,
+ $dup,
+ $a_file[$i]['js_filename']);
+ $dup++;
+ }while ( file_exists($filename));
+
+ }
+ $cn->lo_export($a_file[$i]['js_lob'], $filename);
+ $a_file_dwn[]=$filename;
+
+ }
+ $cn->commit();
+ // zip the folder
+ $zip = new Zip_Extended();
+ $zip_file=sprintf("%s".DIRECTORY_SEPARATOR."%s.zip"
+ ,$store
+ ,$jr_internal);
+
+ chdir($store);
+ $res=$zip->open($zip_file, ZipArchive::CREATE);
+ foreach ($a_file_dwn as $item)
+ {
+ $zip->addFile(basename($item));
+ }
+ $zip->close();
+ // send the folder to browser
+ header('Content-Type: application/zip');
+ header('Content-Disposition: attachment; filename="document-'.$jr_internal.'.zip"');
+ header('Cache-Control: private, max-age=0, must-revalidate');
+ header('Pragma: public');
+ echo file_get_contents($zip_file);
+
+ } catch (Exception $exc) {
+ record_log($exc);
+ }
+
+}
\ No newline at end of file
diff --git a/include/template/ajax_ledger+input_file.php b/include/template/ajax_ledger+input_file.php
new file mode 100644
index 000000000..5bcd27a7a
--- /dev/null
+++ b/include/template/ajax_ledger+input_file.php
@@ -0,0 +1,68 @@
+ list of files to update after uploading
+ */
+
+$dgbox=$http->request("dgbox");
+$form_id="save_file{$div}";
+$progress="progress{$div}";
+$max_post_size=convert_ini_unit(ini_get("post_max_size"));
+
+echo \HtmlInput::title_box(_("Ajout de fichier"), $dgbox);
+?>
+
diff --git a/include/template/ledger_detail_sup_files.php b/include/template/ledger_detail_sup_files.php
new file mode 100644
index 000000000..1506c1590
--- /dev/null
+++ b/include/template/ledger_detail_sup_files.php
@@ -0,0 +1,91 @@
+
+
+
+collect_objects(" where jr_id=$1 order by js_cbc_id", [$jr_id]);
+$javascript=sprintf("Supplement_Document.input_file('%s','%s','%s')",
+ $gDossier,
+ $div,
+ $jr_id);
+if ( count($a_row) > 0)
+{
+ foreach ($a_row as $item) {
+ $export="export.php?";
+ $script="Supplement_Document.delete_document('$gDossier','$div','{$item->js_id}','$jr_id')";
+ $rowid=sprintf("row_js_%s_%s",$div,$item->js_id);
+ // @var $download (url) to send file
+ $download="export.php?". http_build_query(
+ [
+ "act"=>"RAW:suppl-document"
+ ,"js_id"=>$item->js_id
+ ,"gDossier"=>$gDossier
+ ]);
+ ?>
+
+
+
+ =$item->js_description?>
+
+
+ =\Icon_Action::trash(uniqid("sdd"),$script)?>
+
+
+ "RAW:suppl-document"
+ ,"js_id"=>0
+ ,"gDossier"=>$gDossier
+ ,'operation_id'=>$jr_id
+ ]);
+
+?>
+
=_("Télécharger tous les documents")?>
+
+
+
+ -
+ =\HtmlInput::button_action(_("Ajout fichier"), $javascript);?>
+
+
+
\ No newline at end of file
diff --git a/sql/upgrade.sql b/sql/upgrade.sql
index ccc8c7fe5..8b45c75cc 100644
--- a/sql/upgrade.sql
+++ b/sql/upgrade.sql
@@ -303,7 +303,7 @@ comment on sequence seq_doc_type_stdinv is 'Sequence for standard invoice';
INSERT INTO public.menu_ref (me_code, me_menu, me_file, me_url, me_description, me_parameter, me_javascript, me_type, me_description_etendue)
-VALUES('RAW:xml-invoice', 'Exporte la facture XML', 'export_xml-invoice.php', NULL, 'export la facture électronique en XML', NULL, NULL, 'PR', NULL);
+VALUES('RAW:xml-invoice', 'Exporte la facture XML', 'export_xml-invoice.php', NULL, 'exporte la facture électronique en XML', NULL, NULL, 'PR', NULL);
insert into profile_menu (me_code,p_id, p_type_display) select 'RAW:xml-invoice',p_id,'P' from profile;
@@ -491,4 +491,11 @@ COMMENT ON COLUMN public.jrn_sup_document.js_mimetype IS 'Mimetype';
COMMENT ON COLUMN public.jrn_sup_document.js_lob IS 'OID';
COMMENT ON COLUMN public.jrn_sup_document.jr_id IS 'FK to jrn';
COMMENT ON COLUMN public.jrn_sup_document.js_description IS 'Description of document';
-COMMENT ON COLUMN public.jrn_sup_document.js_cbc_id IS 'ID in XML';
\ No newline at end of file
+COMMENT ON COLUMN public.jrn_sup_document.js_cbc_id IS 'ID in XML';
+
+
+
+INSERT INTO public.menu_ref (me_code, me_menu, me_file, me_url, me_description, me_parameter, me_javascript, me_type, me_description_etendue)
+VALUES('RAW:suppl-document', 'Exporte Document supplementaire', 'export_suppl-document.php', NULL, 'télécharge le document supp', NULL, NULL, 'PR', NULL);
+
+insert into profile_menu (me_code,p_id, p_type_display) select 'RAW:suppl-document',p_id,'P' from profile;