[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpcompta-dev] r616 - in trunk/rapport_avance: . include sql
From: |
phpcompta-dev |
Subject: |
[Phpcompta-dev] r616 - in trunk/rapport_avance: . include sql |
Date: |
Wed, 11 Dec 2013 23:40:08 +0100 (CET) |
Author: danydb
Date: 2013-12-11 23:40:08 +0100 (Wed, 11 Dec 2013)
New Revision: 616
Modified:
trunk/rapport_avance/include/class_rapav_listing_compute.php
trunk/rapport_avance/include/class_rapav_listing_compute_fiche.php
trunk/rapport_avance/include/class_rapport_avance_sql.php
trunk/rapport_avance/include/declaration.inc.php
trunk/rapport_avance/rapav_constant.php
trunk/rapport_avance/raw.php
trunk/rapport_avance/sql/2-listing_compute_fiche.sql
Log:
task #0000942: Listing : conversion des documents en PDF
Conversion des documents en PDF, mais ?\195?\160 besoin d'utiliser UNO de
libreoffice
Modified: trunk/rapport_avance/include/class_rapav_listing_compute.php
===================================================================
--- trunk/rapport_avance/include/class_rapav_listing_compute.php
2013-12-11 20:39:37 UTC (rev 615)
+++ trunk/rapport_avance/include/class_rapav_listing_compute.php
2013-12-11 22:40:08 UTC (rev 616)
@@ -187,7 +187,11 @@
$detail=$odetail->next($r_detail,$e);
echo th( $detail->lc_code);
}
- echo th("");
+ echo th("Fichier");
+ if ( GENERATE_PDF == 'YES')
+ {
+ echo th('PDF');
+ }
echo '</tr>';
}
/** for each detail */
@@ -215,6 +219,16 @@
$href= "extension.raw.php?".http_build_query($arg);
echo td('<a href="'.$href.'">'.$fiche->lf_filename);
}
+ if ( $fiche->lf_pdf != "")
+ {
+ $arg=array("gDossier"=>$_REQUEST['gDossier'],
+ "plugin_code"=>$_REQUEST['plugin_code'],
+ "ac"=>$_REQUEST['ac'],
+ 'act'=>'show_pdf',
+ 'lf_id'=>$fiche->lf_id);
+ $href= "extension.raw.php?".http_build_query($arg);
+ echo td('<a href="'.$href.'">'.$fiche->lf_pdf_filename);
+ }
echo '</tr>';
}
echo '</table>';
@@ -276,6 +290,20 @@
$fiche->generate_document();
}
}
+ function create_pdf()
+ {
+ global $cn;
+ $ofiche=new RAPAV_Listing_Compute_Fiche();
+ $r_fiche=$ofiche->seek (" where lc_id = $1",array($this->data->lc_id));
+ $nb_fiche=Database::num_row($r_fiche);
+ if (isNumber($p_id)==0) {$p_id=0;}
+ /* For each card */
+ for ($i = 0;$i < $nb_fiche;$i++)
+ {
+ $fiche=$ofiche->next($r_fiche,$i);
+ $file=$fiche->create_pdf();
+ }
+ }
/**
* @brief display a form to generate CSV
*/
Modified: trunk/rapport_avance/include/class_rapav_listing_compute_fiche.php
===================================================================
--- trunk/rapport_avance/include/class_rapav_listing_compute_fiche.php
2013-12-11 20:39:37 UTC (rev 615)
+++ trunk/rapport_avance/include/class_rapav_listing_compute_fiche.php
2013-12-11 22:40:08 UTC (rev 616)
@@ -444,5 +444,28 @@
$this->update();
$cn->commit();
}
+ function create_pdf()
+ {
+ global $cn;
+ if (GENERATE_PDF == 'NO') return;
+ $cn->start();
+ if ( $this->lf_filename=="")return;
+
+ $file=$_ENV['TMP']."/".$this->lf_filename;
+
+ $cn->lo_export($this->lf_lob,$file);
+
+ // remove extension
+ $ext= strrpos($this->lf_filename,".");
+ $dst_file= substr($this->lf_filename, 0, $ext);
+ $dst_file.=".pdf";
+ passthru(OFFICE.$file,$status);
+ // reload it into database
+ $this->lf_pdf=$cn->lo_import($_ENV['TMP']."/".$dst_file);
+ $this->lf_pdf_filename=$dst_file;
+ $this->update();
+ $cn->commit();
+
+ }
}
Modified: trunk/rapport_avance/include/class_rapport_avance_sql.php
===================================================================
--- trunk/rapport_avance/include/class_rapport_avance_sql.php 2013-12-11
20:39:37 UTC (rev 615)
+++ trunk/rapport_avance/include/class_rapport_avance_sql.php 2013-12-11
22:40:08 UTC (rev 616)
@@ -484,6 +484,8 @@
var $lf_filename;
var $lf_mimetype;
var $lc_id;
+ var $lf_pdf;
+ var $lf_pdf_filename;
/* example private
$variable=array("easy_name"=>column_name,"email"=>"column_name_email","val3"=>0);
*/
@@ -501,15 +503,19 @@
, "lf_lob" => "lf_lob"
, "lf_filename" => "lf_filename"
, "lf_mimetype" => "lf_mimetype"
+ , "lf_pdf" => "lf_pdf"
+ , "lf_pdf_filename" => "lf_pdf_filename"
);
$this->type = array(
"lf_id" => "numeric",
"lc_id" => "numeric",
"f_id" => "numeric"
- , "lf_lob" => "set_me"
+ , "lf_lob" => "oid"
, "lf_filename" => "text"
, "lf_mimetype" => "text"
+ , "lf_pdf" => "oid"
+ , "lf_pdf_filename" => "text"
);
$this->default = array(
Modified: trunk/rapport_avance/include/declaration.inc.php
===================================================================
--- trunk/rapport_avance/include/declaration.inc.php 2013-12-11 20:39:37 UTC
(rev 615)
+++ trunk/rapport_avance/include/declaration.inc.php 2013-12-11 22:40:08 UTC
(rev 616)
@@ -92,6 +92,10 @@
$listing=new RAPAV_Listing_Compute();
$listing->load($_GET['lc_id']);
$listing->generate($_GET['numerotation']);
+
+ if ( GENERATE_PDF == 'YES')
+ $listing->create_pdf();
+
$listing->display(false);
exit();
}
Modified: trunk/rapport_avance/rapav_constant.php
===================================================================
--- trunk/rapport_avance/rapav_constant.php 2013-12-11 20:39:37 UTC (rev
615)
+++ trunk/rapport_avance/rapav_constant.php 2013-12-11 22:40:08 UTC (rev
616)
@@ -10,6 +10,10 @@
require_once ('class_database.php');
global $cn,$rapav_version,$errcode;
+/** -- pour utiliser unoconv démarrer un server libreoffice
+ * libreoffice --headless --accept="socket,host=127.0.0.1,port=2002;urp;"
--nofirststartwizard */
+define ('OFFICE','unoconv ');
+define ('GENERATE_PDF','NO');
$cn=new Database (dossier::id());
$rapav_version=4;
?>
Modified: trunk/rapport_avance/raw.php
===================================================================
--- trunk/rapport_avance/raw.php 2013-12-11 20:39:37 UTC (rev 615)
+++ trunk/rapport_avance/raw.php 2013-12-11 22:40:08 UTC (rev 616)
@@ -186,4 +186,51 @@
$cn->commit();
}
+/**
+ * Show generated file
+ */
+if ($act=="show_pdf")
+{
+ $decl = new RAPAV_Listing_Compute_Fiche();
+ $decl->lf_id = $lf_id;
+ $decl->load();
+
+ $cn->start();
+ if ($decl->lf_pdf == "")
+ {
+ 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/plain');
+ header('Content-Disposition: attachment;filename=vide.txt',
FALSE);
+ header("Accept-Ranges: bytes");
+ echo "******************";
+ echo _("Fichier effacé");
+ echo "******************";
+ exit();
+ }
+ $tmp = tempnam($_ENV['TMP'], 'document_');
+
+ $cn->lo_export($decl->lf_pdf, $tmp);
+
+ 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: application/pdf');
+ header('Content-Disposition: attachment;filename="' .
$decl->lf_filename . '.pdf"', FALSE);
+ header("Accept-Ranges: bytes");
+ $file = fopen($tmp, 'r');
+ while (!feof($file))
+ echo fread($file, 8192);
+
+ fclose($file);
+
+ unlink($tmp);
+
+ $cn->commit();
+}
?>
Modified: trunk/rapport_avance/sql/2-listing_compute_fiche.sql
===================================================================
--- trunk/rapport_avance/sql/2-listing_compute_fiche.sql 2013-12-11
20:39:37 UTC (rev 615)
+++ trunk/rapport_avance/sql/2-listing_compute_fiche.sql 2013-12-11
22:40:08 UTC (rev 616)
@@ -7,7 +7,9 @@
lf_id serial NOT NULL, -- PK
f_id bigint NOT NULL, -- FK to fiche
lf_lob oid, -- Generated file if any
+ lf_pdf oid, -- Generated file if any
lf_filename text, -- Name of the generated file. It should be based on the
name of the template + unique id
+ lf_pdf_filename text, -- Generated file if any
lf_mimetype text, -- Same mimetype as in table listing
lc_id bigint,
CONSTRAINT listing_compute_fiche_pkey PRIMARY KEY (lf_id ),
@@ -30,6 +32,8 @@
COMMENT ON COLUMN rapport_advanced.listing_compute_fiche.lf_id IS 'PK';
COMMENT ON COLUMN rapport_advanced.listing_compute_fiche.f_id IS 'FK to fiche';
COMMENT ON COLUMN rapport_advanced.listing_compute_fiche.lf_lob IS 'Generated
file if any';
+COMMENT ON COLUMN rapport_advanced.listing_compute_fiche.lf_pdf IS 'PDF File';
COMMENT ON COLUMN rapport_advanced.listing_compute_fiche.lf_filename IS 'Name
of the generated file. It should be based on the name of the template + unique
id';
+COMMENT ON COLUMN rapport_advanced.listing_compute_fiche.lf_pdf_filename IS
'Name of the PDF file.base of lf_filename';
COMMENT ON COLUMN rapport_advanced.listing_compute_fiche.lf_mimetype IS 'Same
mimetype as in table listing';
---
PhpCompta est un logiciel de comptabilité libre en ligne (full web)
Projet opensource http://www.phpcompta.eu
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpcompta-dev] r616 - in trunk/rapport_avance: . include sql,
phpcompta-dev <=