noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
export_xml-invoice.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * NOALYSS is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * NOALYSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with NOALYSS; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19*/
20// Copyright Author Dany De Bontridder danydb@aevalys.eu 22/10/23
21
22
23/**
24 * @file
25 * @brief export the XML invoice from JRN.JR_DOCUMENT_XML
26 */
27if ( ! defined ('ALLOWED')) die (_('Non autorisé'));
28
30
31try
32{
33 $jr_id=$http->get('jr_id',"number");
34}
35catch (Exception $exc)
36{
37 record_log($exc);
38 return;
39}
40
41$cn=Dossier::connect();
42
43$r=$cn->exec_sql("select jr_def_id from jrn where jr_id=$1",array($jr_id));
44
45if ( Database::num_row($r) == 0 )
46{
47 echo_error("Invalid operation id jr_id=$jr_id");
48 exit;
49}
51$jrn=$a['jr_def_id'];
52global $g_user;
53if ($g_user->check_jrn($jrn) == 'X' )
54{
55 /* Cannot Access */
56 NoAccess();
57 exit -1;
58}
59
60$ret=$cn->exec_sql("select jr_pj_name,jr_pj_number ,jr_document_xml from jrn where jr_id=$1",
61 array($jr_id));
62
63if ( Database::num_row ($ret) == 0 )
64 return;
65
67
68if ( $row['jr_document_xml']==null )
69{
70 ini_set('zlib.output_compression','Off');
71 header("Pragma: public");
72 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
73 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
74 header("Cache-Control: must-revalidate");
75 header('Content-type: '.'text/plain');
76 header('Content-Disposition: attachment;filename=vide.txt',FALSE);
77 header("Accept-Ranges: bytes");
78 echo "******************";
79 echo _("Fichier effacé");
80 echo "******************";
81 exit();
82}
83$tmp=tempnam($_ENV['TMP'],'document_');
84
85$new_name=$row['jr_pj_name'];
88if ( ! empty($receipt_number) && strpos($new_name,$receipt_number) === false ) {
89
91}
92// replace extension by xml (normally a PDF)
93//@var $pos_ext (int) where is the last dot
94$pos_ext=strrpos($new_name,'.');
95if ( $pos_ext == 0)
96{
97 // there is no extension
98 $new_name.='.xml';
99}else {
100 $new_name=substr_replace($new_name,'.xml',$pos_ext);
101}
102$cn->start();
103
104$cn->lo_export($row['jr_document_xml'],$tmp);
105$cn->commit();
106
107ini_set('zlib.output_compression','Off');
108header("Pragma: public");
109header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
110header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
111header("Cache-Control: must-revalidate");
112header('Content-type: application/xml');
113header('Content-Disposition: attachment;filename="'.$new_name.'"',FALSE);
114header("Accept-Ranges: bytes");
115
116$file=fopen($tmp,'r');
117while ( !feof ($file) )
118 echo fread($file,8192);
119
120fclose($file);
121
122unlink ($tmp);
noalyss_str_replace($search, $replace, $string)
NoAccess($js=1)
Echo no access and stop.
echo_error($p_log, $p_line="", $p_message="")
log error into the /tmp/noalyss_error.log it doesn't work on windows
record_log($p_message)
Record an error message into the log file of the server or in the log folder of NOALYSS Record also t...
global $g_user
if no group available , then stop
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
$jr_id
_("actif, passif,charge,...")
static fetch_array($ret, $p_indice=0, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_array
static num_row($ret)
wrapper for the function pg_num_rows
manage the http input (get , post, request) and extract from an array
for($e=0; $e< count($afiche); $e++) exit
$new_name
$receipt_number
if(! empty($receipt_number) &&strpos($new_name, $receipt_number)===false) $pos_ext
clean_filename($p_filename)
sanitize the filename remove character which could be a problem,