Repository navigation
Expand file tree
/
Copy pathksef_fix.php
More file actions
72 lines (63 loc) · 2.69 KB
/
Copy pathksef_fix.php
File metadata and controls
72 lines (63 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/* Copyright (C) 2026 InPoint Automation Sp z o.o.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file ksef/ksef_fix.php
* \ingroup ksef
* \brief Fixing issues in DB
*/
if (!defined('CSRFCHECK_WITH_TOKEN')) {
define('CSRFCHECK_WITH_TOKEN', '1');
}
$res = 0;
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"] . "/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");
global $conf, $langs, $user, $db;
dol_include_once('/ksef/lib/ksef.lib.php');
$langs->loadLangs(array('admin', 'ksef@ksef'));
$action = GETPOST('action', 'aZ09');
$key = GETPOST('req', 'aZ09');
$back = GETPOST('backtopage', 'alpha');
if (!preg_match('#^/(?![/\\\\])#', $back) || ksefRequirementBackRefused($back)) {
$back = '';
}
if ($action === 'bankdefault' && isModEnabled('ksef') && isModEnabled('banque') && $user->hasRight('banque', 'configurer')) {
if (ksefRequirementBankDefault($db, $user, GETPOSTINT('account'))) {
setEventMessages($langs->trans('KSEF_BankAccountMadeDefault'), null, 'mesgs');
}
header('Location: ' . ($back !== '' ? $back : DOL_URL_ROOT . '/compta/bank/card.php?id=' . GETPOSTINT('account')));
exit;
}
if (!isModEnabled('ksef') || empty($user->admin)) {
accessforbidden();
}
if ($action === 'vatnone') {
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
if (GETPOSTINT('undo')) {
dolibarr_del_const($db, 'KSEF_VAT_CODES_NONE', $conf->entity);
} else {
dolibarr_set_const($db, 'KSEF_VAT_CODES_NONE', '1', 'chaine', 0, '', $conf->entity);
}
}
if ($action === 'fix' && $key !== '') {
$r = ksefRequirementFix($db, $user, $key);
setEventMessages($r['message'], null, $r['ok'] ? 'mesgs' : 'errors');
}
header('Location: ' . ($back !== '' ? $back : dol_buildpath('/ksef/ksefindex.php', 1)));
exit;