This repository was archived by the owner on Apr 27, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.php
More file actions
127 lines (110 loc) · 5.17 KB
/
bootstrap.php
File metadata and controls
127 lines (110 loc) · 5.17 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
require_once 'functions.php'; // Include your class definitions
// Instantiate core classes
$app = new App();
$settings = new Settings();
$template = new TemplateEngine('themes/' . $settings->getSetting('theme'));
$paths = new Paths();
$themes = new Themes();
if (!$settings->getSetting("newinstall")) {
if (isset($_SESSION['hasAlert'])){
echo $_SESSION['hasAlert'];
};
$db = new Database("sqlite:./facturiavize.db");
$hasAlert = isset($_COOKIE['hasAlert']) ? $_COOKIE['hasAlert'] : 0;
$alertType = isset($_COOKIE['alertType']) ? $_COOKIE['alertType'] : "info";
$alertIcon = isset($_COOKIE['alertIcon']) ? $_COOKIE['alertIcon'] : "fas fa-info";
$alertTitle = isset($_COOKIE['alertTitle']) ? $_COOKIE['alertTitle'] : "Notă";
$alertDescription = isset($_COOKIE['alertDescription']) ? $_COOKIE['alertDescription'] : "Dacă vezi acest mesaj, raportează o problemă!";
$renderData=[
'referrer' => $_SERVER['REQUEST_URI'],
'hasAlert' => $hasAlert,
'alertType' => $alertType,
'alertIcon' => $alertIcon,
'alertTitle' => $alertTitle,
'alertDescription' => $alertDescription,
/* == App Meta == */
'appName' => $app->getAppName(),
'appVer' => $app->getVersion(),
'showMenu' => true,
/* === Paths === */
'themePath' => $paths->getPath("themesFolder").'/'.$settings->getSetting("theme"),
];
setcookie('hasAlert', '', time() - 3600, '/');
setcookie('alertType', '', time() - 3600, '/');
setcookie('alertIcon', '', time() - 3600, '/');
setcookie('alertTitle', '', time() - 3600, '/');
setcookie('alertDescription', '', time() - 3600, '/');
// Return instances for reuse
return [
'app' => $app,
'settings' => $settings,
'template' => $template,
'paths' => $paths,
'themes' => $themes,
'renderData' => $renderData,
'db' => $db,
];
} else {
$initapp = isset($_POST['numef']) ? $_POST['numef'] : '';
if($initapp){
$cuif = isset($_POST['cuif']) ? $_POST['cuif'] : '';
$numef = isset($_POST['numef']) ? $_POST['numef'] : '';
$onrcf = isset($_POST['onrcf']) ? $_POST['onrcf'] : '';
$adresaf = isset($_POST['adresaf']) ? $_POST['adresaf'] : '';
$ibanf = isset($_POST['ibanf']) ? $_POST['ibanf'] : '';
$telefonf = isset($_POST['telefonf']) ? $_POST['telefonf'] : '';
$emailf = isset($_POST['emailf']) ? $_POST['emailf'] : '';
$tvaf = (isset($_POST['tvaf']) && $_POST['tvaf'] !== '') ? (int)$_POST['tvaf'] : 0;
// SQL connection
$db = new Database("sqlite:./facturiavize.db");
$db->insert("INSERT INTO `furnizori` (`cui`, `numefirma`, `onrc`, `adresa`, `iban`, `telefon`, `email`, `tva`) VALUES (?, ?, ?, ?, ?, ?, ?, ?)",[$cuif, $numef, $onrcf, $adresaf, $ibanf, $telefonf, $emailf, $tvaf]);
// Disable first-run
$settings->setSetting("newinstall",false);
header("Location: /");
die();
};
$cuiF = isset($_POST['cuifanaf']) ? $_POST['cuifanaf'] : '';
$interogareAnaf="";
if($cuiF){
$apiAnaf = new RestClient([
'base_url' => 'https://webservicesp.anaf.ro/api/',
'headers' => ['Content-Type' => 'application/json']
]);
$dataPacket = array(
[
'cui' => $cuiF,
'data' => date("Y-m-d"),
],
);
$interogareAnaf = $apiAnaf->post('PlatitorTvaRest/v9/tva', json_encode($dataPacket));
$interogareAnaf = json_decode($interogareAnaf->response, true);
};
$renderData=[
'referrer' => $_SERVER['REQUEST_URI'],
'hasAlert' => 0,
/* == App Meta == */
'appName' => $app->getAppName(),
'appVer' => $app->getVersion(),
'showMenu' => false,
/* == Paths == */
'themePath' => $paths->getPath("themesFolder").'/'.$settings->getSetting("theme"),
'cuiFCautareAnaf' => $cuiF,
"defaultFacturiPathValue" => getenv('HOMEDRIVE').getenv('HOMEPATH').'\Downloads\Export\Facturi',
"defaultAvizePathValue" => getenv('HOMEDRIVE').getenv('HOMEPATH').'\Downloads\Export\Avize',
];
if($interogareAnaf && isset($interogareAnaf['found']['0']['date_generale']['cui'])){
$renderData = array_merge($renderData, [
/* == Interogare ANAF == */
'cuiF' => $interogareAnaf['found']['0']['date_generale']['cui'],
'numeF' => $interogareAnaf['found']['0']['date_generale']['denumire'],
'adresaF' => $interogareAnaf['found']['0']['date_generale']['adresa'],
'onrcF' => $interogareAnaf['found']['0']['date_generale']['nrRegCom'],
'ibanF' => $interogareAnaf['found']['0']['date_generale']['iban'],
'telefonF' => $interogareAnaf['found']['0']['date_generale']['telefon'],
]
);
}
echo $template->render('firstrun.html', $renderData);
die();
};