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 && 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.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
dol_include_once('/importzugferd/class/zugferdimport.class.php');
dol_include_once('/importzugferd/lib/importzugferd.lib.php');
// Load translation files
$langs->loadLangs(array("importzugferd@importzugferd", "bills", "companies"));
// Get parameters
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha');
// Initialize object
$object = new ZugferdImport($db);
// Load object
if ($id > 0 || !empty($ref)) {
$result = $object->fetch($id, $ref);
if ($result <= 0) {
setEventMessages($langs->trans('RecordNotFound'), null, 'errors');
header('Location: '.dol_buildpath('/importzugferd/list.php', 1));
exit;
}
}
// Security check
if (!$user->hasRight('importzugferd', 'import', 'read')) {
accessforbidden();
}
$permissiontodelete = $user->hasRight('importzugferd', 'import', 'delete');
/*
* Actions
*/
// Delete confirmation
if ($action == 'delete' && $confirm == 'yes' && $permissiontodelete) {
$result = $object->delete($user);
if ($result > 0) {
setEventMessages($langs->trans('RecordDeleted'), null, 'mesgs');
header('Location: '.dol_buildpath('/importzugferd/list.php', 1));
exit;
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
}
/*
* View
*/
$form = new Form($db);
$title = $langs->trans('ImportRecord').' - '.$object->ref;
llxHeader('', $title, '', '', 0, 0, '', '', '', 'mod-importzugferd page-card');
// Confirmation dialog for delete
if ($action == 'delete') {
print $form->formconfirm(
$_SERVER["PHP_SELF"].'?id='.$object->id,
$langs->trans('DeleteImportRecord'),
$langs->trans('ConfirmDeleteImportRecord', $object->ref),
'delete',
'',
0,
1
);
}
// Header
print '
';
print '
';
print '
';
// Ref
print '';
print '| '.$langs->trans('Ref').' | ';
print ''.$object->ref.' | ';
print '
';
// Invoice number
print '';
print '| '.$langs->trans('InvoiceNumber').' | ';
print ''.dol_escape_htmltag($object->invoice_number).' | ';
print '
';
// Invoice date
print '';
print '| '.$langs->trans('InvoiceDate').' | ';
print ''.dol_print_date($object->invoice_date, 'day').' | ';
print '
';
// Seller
print '';
print '| '.$langs->trans('Supplier').' | ';
print '';
if ($object->fk_soc > 0) {
$supplier = new Societe($db);
$supplier->fetch($object->fk_soc);
print $supplier->getNomUrl(1);
print ' ('.dol_escape_htmltag($object->seller_name).')';
} else {
print dol_escape_htmltag($object->seller_name);
}
print ' | ';
print '
';
// VAT ID
print '';
print '| '.$langs->trans('VATIntra').' | ';
print ''.dol_escape_htmltag($object->seller_vat).' | ';
print '
';
// Buyer reference
print '';
print '| '.$langs->trans('BuyerReference').' | ';
print ''.dol_escape_htmltag($object->buyer_reference).' | ';
print '
';
// Total HT
print '';
print '| '.$langs->trans('TotalHT').' | ';
print ''.price($object->total_ht).' '.$object->currency.' | ';
print '
';
// Total TTC
print '';
print '| '.$langs->trans('TotalTTC').' | ';
print ''.price($object->total_ttc).' '.$object->currency.' | ';
print '
';
// Supplier invoice
print '';
print '| '.$langs->trans('SupplierInvoice').' | ';
print '';
if ($object->fk_facture_fourn > 0) {
$invoice = new FactureFournisseur($db);
$invoice->fetch($object->fk_facture_fourn);
print $invoice->getNomUrl(1);
} else {
print '-';
}
print ' | ';
print '
';
// Status
print '';
print '| '.$langs->trans('Status').' | ';
print ''.$object->getLibStatut(1).' | ';
print '
';
// Error message
if ($object->status == ZugferdImport::STATUS_ERROR && !empty($object->error_message)) {
print '';
print '| '.$langs->trans('ErrorMessage').' | ';
print ''.dol_escape_htmltag($object->error_message).' | ';
print '
';
}
// PDF filename
print '';
print '| '.$langs->trans('File').' | ';
print ''.dol_escape_htmltag($object->pdf_filename).' | ';
print '
';
// Date creation
print '';
print '| '.$langs->trans('DateCreation').' | ';
print ''.dol_print_date($object->date_creation, 'dayhour').' | ';
print '
';
print '
';
print '
';
// Action buttons
print '';
// Show XML content (collapsed)
if (!empty($object->xml_content)) {
// Format XML for better readability using class method
$formattedXml = ZugferdImport::formatXmlForDisplay($object->xml_content);
print '
';
print '';
print '
';
print '';
print '| '.$langs->trans('XMLContent').' | ';
print '
';
print '';
print '';
print ''.$langs->trans('ClickToExpand').'';
print '';
print ' ';
print dol_escape_htmltag($formattedXml);
print '';
print ' ';
print ' | ';
print '
';
print '
';
print '
';
}
llxFooter();
$db->close();