- ZUGFeRD/Factur-X XML-Generierung (EN16931) - XRechnung 3.0 Unterstützung - PDF-Einbettung (echtes ZUGFeRD-PDF) - Option XML nach Einbettung zu löschen - ODT-Template Unterstützung - E-Mail Anhang Funktion - XML-Vorschau Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
226 lines
6.8 KiB
PHP
Executable file
226 lines
6.8 KiB
PHP
Executable file
<?php
|
|
/* Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
|
|
* Copyright (C) 2018-2019 Nicolas ZABOURI <info@inovea-conseil.com>
|
|
* Copyright (C) 2019-2024 Frédéric France <frederic.france@free.fr>
|
|
* Copyright (C) 2026 Eduard Wisch <data@data-it-solution.de>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
/**
|
|
* \defgroup exportzugferd Module ExportZugferd
|
|
* \brief ExportZugferd module descriptor.
|
|
*
|
|
* \file htdocs/exportzugferd/core/modules/modExportZugferd.class.php
|
|
* \ingroup exportzugferd
|
|
* \brief Description and activation file for module ExportZugferd
|
|
*/
|
|
include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
|
|
|
|
|
|
/**
|
|
* Description and activation class for module ExportZugferd
|
|
*/
|
|
class modExportZugferd extends DolibarrModules
|
|
{
|
|
/**
|
|
* Constructor. Define names, constants, directories, boxes, permissions
|
|
*
|
|
* @param DoliDB $db Database handler
|
|
*/
|
|
public function __construct($db)
|
|
{
|
|
global $conf, $langs;
|
|
|
|
$this->db = $db;
|
|
|
|
// Id for module (must be unique).
|
|
$this->numero = 500017;
|
|
|
|
// Key text used to identify module (for permissions, menus, etc...)
|
|
$this->rights_class = 'exportzugferd';
|
|
|
|
// Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...'
|
|
$this->family = "financial";
|
|
|
|
// Module position in the family on 2 digits ('01', '10', '20', ...)
|
|
$this->module_position = '91';
|
|
|
|
// Module label (no space allowed)
|
|
$this->name = preg_replace('/^mod/i', '', get_class($this));
|
|
|
|
// Module description
|
|
$this->description = "ExportZugferdDescription";
|
|
$this->descriptionlong = "ExportZugferdDescriptionLong";
|
|
|
|
// Author
|
|
$this->editor_name = 'Data IT Solution';
|
|
$this->editor_url = '';
|
|
|
|
// Version
|
|
$this->version = '2.0';
|
|
|
|
// Key used in llx_const table to save module status
|
|
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
|
|
|
|
// Module icon
|
|
$this->picto = 'object_exportzugferd@exportzugferd';
|
|
|
|
// Define some features supported by module
|
|
$this->module_parts = array(
|
|
'triggers' => 0,
|
|
'login' => 0,
|
|
'substitutions' => 0,
|
|
'menus' => 0,
|
|
'tpl' => 0,
|
|
'barcode' => 0,
|
|
'models' => 0,
|
|
'printing' => 0,
|
|
'theme' => 0,
|
|
'css' => array(),
|
|
'js' => array(),
|
|
'hooks' => array(
|
|
'data' => array(
|
|
'pdfgeneration',
|
|
'odtgeneration',
|
|
'invoicecard',
|
|
'formmail',
|
|
),
|
|
'entity' => '0',
|
|
),
|
|
'moduleforexternal' => 0,
|
|
'websitetemplates' => 0,
|
|
'captcha' => 0
|
|
);
|
|
|
|
// Data directories to create when module is enabled
|
|
$this->dirs = array("/exportzugferd/temp");
|
|
|
|
// Config pages
|
|
$this->config_page_url = array("setup.php@exportzugferd");
|
|
|
|
// Dependencies
|
|
$this->hidden = getDolGlobalInt('MODULE_EXPORTZUGFERD_DISABLED');
|
|
$this->depends = array('modFacture');
|
|
$this->requiredby = array();
|
|
$this->conflictwith = array();
|
|
|
|
// Constants
|
|
$this->const = array(
|
|
1 => array('EXPORTZUGFERD_PROFILE', 'chaine', 'EN16931', 'Default ZUGFeRD profile', 0, 'current', 1),
|
|
2 => array('EXPORTZUGFERD_EMBED_PDF', 'chaine', '0', 'Embed XML in PDF (requires FPDI)', 0, 'current', 1),
|
|
);
|
|
|
|
// Boxes/Widgets
|
|
$this->boxes = array();
|
|
|
|
// Cronjobs
|
|
$this->cronjobs = array();
|
|
|
|
// Permissions provided by this module
|
|
$r = 0;
|
|
$this->rights[$r][0] = $this->numero + $r + 1;
|
|
$this->rights[$r][1] = 'Read ZUGFeRD exports';
|
|
$this->rights[$r][3] = 0;
|
|
$this->rights[$r][4] = 'read';
|
|
$this->rights[$r][5] = '';
|
|
$r++;
|
|
|
|
$this->rights[$r][0] = $this->numero + $r + 1;
|
|
$this->rights[$r][1] = 'Create/Download ZUGFeRD exports';
|
|
$this->rights[$r][3] = 0;
|
|
$this->rights[$r][4] = 'export';
|
|
$this->rights[$r][5] = '';
|
|
$r++;
|
|
|
|
// Main menu entries to add
|
|
$this->menu = array();
|
|
$r = 0;
|
|
|
|
// Add top menu entry
|
|
$this->menu[$r++] = array(
|
|
'fk_menu' => 'fk_mainmenu=billing',
|
|
'type' => 'left',
|
|
'titre' => 'ExportZugferd',
|
|
'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth valignmiddle"'),
|
|
'mainmenu' => 'billing',
|
|
'leftmenu' => 'exportzugferd',
|
|
'url' => '/exportzugferd/index.php',
|
|
'langs' => 'exportzugferd@exportzugferd',
|
|
'position' => 1000 + $r,
|
|
'enabled' => 'isModEnabled("exportzugferd")',
|
|
'perms' => '$user->hasRight("exportzugferd", "read")',
|
|
'target' => '',
|
|
'user' => 0,
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Function called when module is enabled.
|
|
*
|
|
* @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes')
|
|
* @return int 1 if OK, 0 if KO
|
|
*/
|
|
public function init($options = '')
|
|
{
|
|
$result = $this->_load_tables('/install/mysql/', 'exportzugferd');
|
|
if ($result < 0) {
|
|
return -1;
|
|
}
|
|
|
|
// Create extrafield for Leitweg-ID on thirdparty (customer)
|
|
include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
|
$extrafields = new ExtraFields($this->db);
|
|
|
|
// Add Leitweg-ID field for XRechnung (German public sector invoices)
|
|
// Only add if it doesn't exist
|
|
$result = $extrafields->addExtraField(
|
|
'leitweg_id', // attribute code
|
|
'Leitweg-ID (XRechnung)', // label
|
|
'varchar', // type
|
|
100, // position
|
|
'50', // size
|
|
'thirdparty', // element type
|
|
0, // unique
|
|
0, // required
|
|
'', // default value
|
|
'', // params
|
|
1, // always editable
|
|
'', // permission
|
|
1, // list (show in list)
|
|
'', // computed value
|
|
'', // entity
|
|
'', // lang file
|
|
'exportzugferd@exportzugferd', // module
|
|
'isModEnabled("exportzugferd")' // enabled condition
|
|
);
|
|
|
|
$sql = array();
|
|
|
|
return $this->_init($sql, $options);
|
|
}
|
|
|
|
/**
|
|
* Function called when module is disabled.
|
|
*
|
|
* @param string $options Options when disabling module
|
|
* @return int 1 if OK, 0 if KO
|
|
*/
|
|
public function remove($options = '')
|
|
{
|
|
$sql = array();
|
|
|
|
return $this->_remove($sql, $options);
|
|
}
|
|
}
|