* * 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. */ /** * \file importzugferdindex.php * \ingroup importzugferd * \brief Home page of the ZUGFeRD Import 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'; dol_include_once('/importzugferd/class/zugferdimport.class.php'); dol_include_once('/importzugferd/lib/importzugferd.lib.php'); // Load translation files $langs->loadLangs(array("importzugferd@importzugferd")); // Security check if (!isModEnabled('importzugferd')) { accessforbidden('Module not enabled'); } /* * View */ $form = new Form($db); $title = $langs->trans('ModuleImportZugferdName'); llxHeader('', $title, '', '', 0, 0, '', '', '', 'mod-importzugferd page-index'); print load_fiche_titre($title, '', 'fa-file-import'); print '
'; // Statistics box print '
'; print '
'; print ''; print ''; print ''; print ''; // Count imports by status $sql = "SELECT status, COUNT(*) as nb FROM ".MAIN_DB_PREFIX."importzugferd_import"; $sql .= " WHERE entity = ".(int)$conf->entity; $sql .= " GROUP BY status"; $stats = array(0 => 0, 1 => 0, 2 => 0); $resql = $db->query($sql); if ($resql) { while ($obj = $db->fetch_object($resql)) { $stats[$obj->status] = $obj->nb; } } $import = new ZugferdImport($db); print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '
'.$langs->trans('Statistics').'
'.$langs->trans('TotalImported').''.array_sum($stats).'
'.$import->LibStatut(0, 1).''.$stats[0].'
'.$import->LibStatut(1, 1).''.$stats[1].'
'.$import->LibStatut(2, 1).''.$stats[2].'
'; print '
'; print '
'; // fichethirdleft // Quick actions and recent imports print '
'; print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '
'.$langs->trans('QuickActions').'
'; print ''; print ' '.$langs->trans('ZugferdImport'); print ''; print '   '; print ''; print ' '.$langs->trans('ImportList'); print ''; print '   '; print ''; print ' '.$langs->trans('ProductMapping'); print ''; print '
'; print '
'; // Recent imports print '
'; print '
'; print ''; print ''; print ''; print ''; $sql = "SELECT i.rowid, i.ref, i.invoice_number, i.invoice_date, i.seller_name, i.total_ttc, i.status"; $sql .= " FROM ".MAIN_DB_PREFIX."importzugferd_import as i"; $sql .= " WHERE i.entity = ".(int)$conf->entity; $sql .= " ORDER BY i.date_creation DESC"; $sql .= " LIMIT 10"; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); if ($num > 0) { while ($obj = $db->fetch_object($resql)) { print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; } } else { print ''; } } print '
'.$langs->trans('RecentImports').'
'.$obj->ref.''.dol_escape_htmltag($obj->invoice_number).''.dol_print_date($db->jdate($obj->invoice_date), 'day').''.dol_escape_htmltag($obj->seller_name).''.price($obj->total_ttc).' EUR'.$import->LibStatut($obj->status, 0).'
'.$langs->trans('NoRecordFound').'
'; print '
'; print '
'; // fichetwothirdright print '
'; // fichecenter print '
'; llxFooter(); $db->close();