All checks were successful
Deploy mahnung / deploy (push) Successful in 13s
Das Schreiben liegt im Rechnungsordner, war aber nicht indexiert (Dolibarr: 'unknown'). Neu: ModelePDFMahnung::alsBeilageIndexieren() — Eintrag mit gen_or_uploaded = 'uploaded' und Rechnungsbezug, vorhandener Eintrag wird aktualisiert. Beide Vorlagen (PDF, ODT inkl. ODT→PDF). Regel KB #1641. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
100 lines
3.6 KiB
PHP
100 lines
3.6 KiB
PHP
<?php
|
|
/* 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, version 3.
|
|
*/
|
|
|
|
/**
|
|
* \file htdocs/custom/mahnung/core/modules/mahnung/modules_mahnung.php
|
|
* \ingroup mahnung
|
|
* \brief Abstrakte Basis-Klasse für Mahnung-Dokumentengeneratoren.
|
|
*/
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
|
|
|
|
/**
|
|
* Elternklasse der Mahnung-Dokumentengeneratoren (PDF, ODT).
|
|
*/
|
|
abstract class ModelePDFMahnung extends CommonDocGenerator
|
|
{
|
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
|
/**
|
|
* Gibt die Liste der aktiven Dokumentenmodelle zurück.
|
|
*
|
|
* @param DoliDB $db Datenbank-Handler
|
|
* @param int $maxfilenamelength Max Länge
|
|
* @return array|int
|
|
*/
|
|
public static function liste_modeles($db, $maxfilenamelength = 0)
|
|
{
|
|
// phpcs:enable
|
|
$type = 'mahnung';
|
|
$list = array();
|
|
|
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
|
$list = getListOfModels($db, $type, $maxfilenamelength);
|
|
|
|
return $list;
|
|
}
|
|
|
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
|
/**
|
|
* Erzeugt das Dokument auf der Festplatte.
|
|
*
|
|
* @param object $object Mahnung-Objekt
|
|
* @param Translate $outputlangs Ausgabesprache
|
|
* @param string $srctemplatepath Pfad zum Template (ODT)
|
|
* @param int $hidedetails Details ausblenden
|
|
* @param int $hidedesc Beschreibung ausblenden
|
|
* @param int $hideref Referenz ausblenden
|
|
* @return int 1=OK, <=0=Fehler
|
|
*/
|
|
abstract public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0);
|
|
// phpcs:enable
|
|
|
|
/**
|
|
* Mahnschreiben im Rechnungsordner als „hochgeladen" indexieren.
|
|
*
|
|
* Die Mahnung liegt bewusst bei der Rechnung, damit sie im Reiter der Rechnung erscheint.
|
|
* Sie ist aber kein Belegdokument der Rechnung: nach Eddys Regel (13.10.2026, KB #1641)
|
|
* steht sie nur im Reiter, nie vorne im Kasten der Rechnungskarte. Ohne Indexeintrag
|
|
* führte Dolibarr sie als „unknown". Vorhandener Eintrag (Mahnung neu erzeugt) wird
|
|
* aktualisiert, nicht verdoppelt. Fehler nur protokollieren — die Datei liegt bereits.
|
|
*
|
|
* @param string $fullpath Absoluter Pfad der erzeugten Datei
|
|
* @param Facture $facture Gemahnte Rechnung (Belegbezug)
|
|
* @return void
|
|
*/
|
|
protected function alsBeilageIndexieren($fullpath, $facture)
|
|
{
|
|
global $user;
|
|
|
|
if (empty($fullpath) || !is_file($fullpath) || strpos($fullpath, DOL_DATA_ROOT.'/') !== 0) {
|
|
return;
|
|
}
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
|
require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
|
|
|
|
$dir = dirname($fullpath);
|
|
$name = basename($fullpath);
|
|
$relDir = ltrim(substr($dir, strlen(DOL_DATA_ROOT)), '/');
|
|
|
|
$ecm = new EcmFiles($this->db);
|
|
if ($ecm->fetch(0, '', $relDir.'/'.$name) > 0) {
|
|
$ecm->gen_or_uploaded = 'uploaded';
|
|
$ecm->label = md5_file($fullpath);
|
|
if (is_object($facture) && !empty($facture->id)) {
|
|
$ecm->src_object_type = $facture->table_element;
|
|
$ecm->src_object_id = (int) $facture->id;
|
|
}
|
|
if ($ecm->update($user) < 0) {
|
|
dol_syslog(get_class($this).'::alsBeilageIndexieren Update fehlgeschlagen: '.$relDir.'/'.$name, LOG_WARNING);
|
|
}
|
|
return;
|
|
}
|
|
if (addFileIntoDatabaseIndex($dir, $name, '', 'uploaded', 0, is_object($facture) ? $facture : null) < 0) {
|
|
dol_syslog(get_class($this).'::alsBeilageIndexieren Anlegen fehlgeschlagen: '.$relDir.'/'.$name, LOG_WARNING);
|
|
}
|
|
}
|
|
}
|