*
* 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 .
*/
/**
* \file index.php
* \ingroup exportzugferd
* \brief Home page for ExportZugferd module
*/
// Load Dolibarr environment
$res = 0;
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
$res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
}
$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME'];
$tmp2 = realpath(__FILE__);
$i = strlen($tmp) - 1;
$j = strlen($tmp2) - 1;
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
$i--;
$j--;
}
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
$res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
}
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
$res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
}
if (!$res && file_exists("../main.inc.php")) {
$res = @include "../main.inc.php";
}
if (!$res && file_exists("../../main.inc.php")) {
$res = @include "../../main.inc.php";
}
if (!$res) {
die("Include of main fails");
}
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
// Security check
if (!$user->hasRight('exportzugferd', 'read')) {
accessforbidden();
}
$langs->loadLangs(array('exportzugferd@exportzugferd', 'bills'));
/*
* View
*/
$form = new Form($db);
llxHeader('', $langs->trans('ExportZugferd'), '', '', 0, 0, '', '', '', 'mod-exportzugferd page-index');
print load_fiche_titre($langs->trans('ExportZugferd'), '', 'fa-file-export');
print '
';
print '
';
// Info box
print '
';
print '
';
print '';
print '| ' . $langs->trans('Information') . ' | ';
print '
';
print '';
print '| ' . $langs->trans('ZugferdProfile') . ' | ';
print '' . getDolGlobalString('EXPORTZUGFERD_PROFILE', 'EN16931') . ' | ';
print '
';
print '';
print '| ' . $langs->trans('AutoGenerateZugferd') . ' | ';
print '' . yn(getDolGlobalInt('EXPORTZUGFERD_AUTO_GENERATE')) . ' | ';
print '
';
print '
';
print '
';
print '
';
print '
';
// Recent invoices with ZUGFeRD
print '
';
print '
';
print '';
print '| ' . $langs->trans('RecentInvoicesWithZugferd') . ' | ';
print '
';
// Get recent invoices
$sql = "SELECT f.rowid, f.ref, f.datef, f.total_ttc, s.nom as socname";
$sql .= " FROM " . MAIN_DB_PREFIX . "facture as f";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
$sql .= " WHERE f.entity IN (" . getEntity('invoice') . ")";
$sql .= " ORDER BY f.datef DESC";
$sql .= " LIMIT 10";
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
if ($num > 0) {
while ($obj = $db->fetch_object($resql)) {
$invoice = new Facture($db);
$invoice->fetch($obj->rowid);
// Check if XML exists
$dir = $conf->facture->dir_output . '/' . dol_sanitizeFileName($obj->ref);
$hasXML = file_exists($dir . '/factur-x.xml') || file_exists($dir . '/xrechnung-' . $obj->ref . '.xml');
print '';
print '| ' . $invoice->getNomUrl(1) . ' | ';
print '' . htmlspecialchars($obj->socname) . ' | ';
print '' . price($obj->total_ttc) . ' ' . $conf->currency . ' | ';
print '';
if ($hasXML) {
print '' . $langs->trans('ZugferdXMLFile') . '';
} else {
print '';
print $langs->trans('GenerateZugferdXML');
print '';
}
print ' | ';
print '
';
}
} else {
print '| ' . $langs->trans('NoRecordFound') . ' |
';
}
$db->free($resql);
} else {
dol_print_error($db);
}
print '
';
print '
';
print '
';
print '
';
llxFooter();
$db->close();