Merge remote-tracking branch 'upstream/develop' into develop
This commit is contained in:
commit
4dc42f65da
@ -129,8 +129,11 @@ function pdf_getInstance($format='',$metric='mm',$pagetype='P')
|
||||
//$format=array($arrayformat['width'],$arrayformat['height']);
|
||||
//$metric=$arrayformat['unit'];
|
||||
|
||||
if (class_exists('TCPDI')) $pdf = new TCPDI($pagetype,$metric,$format);
|
||||
else $pdf = new TCPDF($pagetype,$metric,$format);
|
||||
$pdfa=false; // PDF-1.3
|
||||
if (! empty($conf->global->PDF_USE_1A)) $pdfa=true; // PDF1/A
|
||||
|
||||
if (class_exists('TCPDI')) $pdf = new TCPDI($pagetype,$metric,$format,true,'UTF-8',false,$pdfa);
|
||||
else $pdf = new TCPDF($pagetype,$metric,$format,true,'UTF-8',false,$pdfa);
|
||||
|
||||
// Protection and encryption of pdf
|
||||
if (! empty($conf->global->PDF_SECURITY_ENCRYPTION))
|
||||
|
||||
@ -135,7 +135,7 @@ class TCPDI extends FPDF_TPL {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function setPDFVersion($version = '1.3') {
|
||||
function setPDFVersion($version = '1.7') {
|
||||
$this->PDFVersion = $version;
|
||||
}
|
||||
|
||||
|
||||
@ -2076,14 +2076,14 @@ if ($action == 'editmeta' || $action == 'createcontainer')
|
||||
print '<tr><td class="fieldrequired">';
|
||||
print $langs->trans('WEBSITE_TITLE');
|
||||
print '</td><td>';
|
||||
print '<input type="text" class="flat quatrevingtpercent" name="WEBSITE_TITLE" value="'.dol_escape_htmltag($pagetitle).'">';
|
||||
print '<input type="text" class="flat quatrevingtpercent" name="WEBSITE_TITLE" id="WEBSITE_TITLE" value="'.dol_escape_htmltag($pagetitle).'">';
|
||||
print '</td></tr>';
|
||||
|
||||
// Alias
|
||||
print '<tr><td class="titlefieldcreate fieldrequired">';
|
||||
print $langs->trans('WEBSITE_PAGENAME');
|
||||
print '</td><td>';
|
||||
print '<input type="text" class="flat minwidth300" name="WEBSITE_PAGENAME" value="'.dol_escape_htmltag($pageurl).'">';
|
||||
print '<input type="text" class="flat minwidth300" name="WEBSITE_PAGENAME" id="WEBSITE_PAGENAME" value="'.dol_escape_htmltag($pageurl).'">';
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td class="titlefield fieldrequired">';
|
||||
@ -2138,7 +2138,6 @@ if ($action == 'editmeta' || $action == 'createcontainer')
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
if ($action == 'createcontainer')
|
||||
{
|
||||
print '<div class="center">';
|
||||
@ -2149,7 +2148,26 @@ if ($action == 'editmeta' || $action == 'createcontainer')
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
|
||||
if ($action == 'createcontainer')
|
||||
{
|
||||
print '<script type="text/javascript" language="javascript">
|
||||
jQuery(document).ready(function() {
|
||||
var disableautofillofalias = 0;
|
||||
jQuery("#WEBSITE_TITLE").keyup(function() {
|
||||
if (disableautofillofalias == 0)
|
||||
{
|
||||
var valnospecial = jQuery("#WEBSITE_TITLE").val().replace(/[^\w]/gi, \'-\').toLowerCase();
|
||||
valnospecial = valnospecial.replace(/\-+/g, \'-\').replace(/\-$/, \'\');
|
||||
console.log("disableautofillofalias=0 so we replace WEBSITE_TITLE with "+valnospecial);
|
||||
jQuery("#WEBSITE_PAGENAME").val(valnospecial);
|
||||
}
|
||||
});
|
||||
jQuery("#WEBSITE_PAGENAME").keyup(function() {
|
||||
disableautofillofalias = 1;
|
||||
});
|
||||
});
|
||||
</script>';
|
||||
}
|
||||
//print '</div>';
|
||||
|
||||
//dol_fiche_end();
|
||||
|
||||
97
scripts/invoices/facturex-pdfextractxml.py
Executable file
97
scripts/invoices/facturex-pdfextractxml.py
Executable file
@ -0,0 +1,97 @@
|
||||
#! /usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2017 Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
|
||||
from optparse import OptionParser
|
||||
import sys
|
||||
from facturx import get_facturx_xml_from_pdf
|
||||
from facturx.facturx import logger
|
||||
import logging
|
||||
from os.path import isfile, isdir
|
||||
|
||||
__author__ = "Alexis de Lattre <alexis.delattre@akretion.com>"
|
||||
__date__ = "August 2017"
|
||||
__version__ = "0.1"
|
||||
|
||||
options = [
|
||||
{'names': ('-l', '--log-level'), 'dest': 'log_level',
|
||||
'action': 'store', 'default': 'info',
|
||||
'help': "Set log level. Possible values: debug, info, warn, error. "
|
||||
"Default value: info."},
|
||||
{'names': ('-d', '--disable-xsd-check'), 'dest': 'disable_xsd_check',
|
||||
'action': 'store_true', 'default': False,
|
||||
'help': "De-activate XML Schema Definition check on Factur-X XML file "
|
||||
"(the check is enabled by default)"},
|
||||
]
|
||||
|
||||
|
||||
def main(options, arguments):
|
||||
if options.log_level:
|
||||
log_level = options.log_level.lower()
|
||||
log_map = {
|
||||
'debug': logging.DEBUG,
|
||||
'info': logging.INFO,
|
||||
'warn': logging.WARN,
|
||||
'error': logging.ERROR,
|
||||
}
|
||||
if log_level in log_map:
|
||||
logger.setLevel(log_map[log_level])
|
||||
else:
|
||||
logger.error(
|
||||
'Wrong value for log level (%s). Possible values: %s',
|
||||
log_level, ', '.join(log_map.keys()))
|
||||
sys.exit(1)
|
||||
|
||||
if len(arguments) != 2:
|
||||
logger.error(
|
||||
'This command requires 2 arguments (%d used). '
|
||||
'Use --help to get the details.', len(arguments))
|
||||
sys.exit(1)
|
||||
pdf_filename = arguments[0]
|
||||
out_xml_filename = arguments[1]
|
||||
if not isfile(pdf_filename):
|
||||
logger.error('Argument %s is not a filename', pdf_filename)
|
||||
sys.exit(1)
|
||||
if isdir(out_xml_filename):
|
||||
logger.error(
|
||||
'2nd argument %s is a directory name (should be a the '
|
||||
'output XML filename)', out_xml_filename)
|
||||
sys.exit(1)
|
||||
pdf_file = open(pdf_filename)
|
||||
check_xsd = True
|
||||
if options.disable_xsd_check:
|
||||
check_xsd = False
|
||||
# The important line of code is below !
|
||||
try:
|
||||
(xml_filename, xml_string) = get_facturx_xml_from_pdf(
|
||||
pdf_file, check_xsd=check_xsd)
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
sys.exit(1)
|
||||
if xml_filename and xml_string:
|
||||
if isfile(out_xml_filename):
|
||||
logger.warn(
|
||||
'File %s already exists. Overwriting it!', out_xml_filename)
|
||||
xml_file = open(out_xml_filename, 'w')
|
||||
xml_file.write(xml_string)
|
||||
xml_file.close()
|
||||
logger.info('File %s generated', out_xml_filename)
|
||||
else:
|
||||
logger.warn('File %s has not been created', out_xml_filename)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
usage = "Usage: facturx-pdfextractxml <invoice.pdf> <factur-x_xml.xml>"
|
||||
epilog = "Author: %s\n\nVersion: %s" % (__author__, __version__)
|
||||
description = "This extracts the XML file from a Factur-X invoice."
|
||||
parser = OptionParser(usage=usage, epilog=epilog, description=description)
|
||||
for option in options:
|
||||
param = option['names']
|
||||
del option['names']
|
||||
parser.add_option(*param, **option)
|
||||
options, arguments = parser.parse_args()
|
||||
sys.argv[:] = arguments
|
||||
main(options, arguments)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user