added class sessione and propagate and day off
@ -44,7 +44,7 @@ class LoginController extends Controller
|
|||||||
$throttles = (bool) setting('throttle_enabled');
|
$throttles = (bool) setting('throttle_enabled');
|
||||||
|
|
||||||
//Redirect URL that can be passed as hidden field.
|
//Redirect URL that can be passed as hidden field.
|
||||||
$to = $request->has('to') ? '?to='.$request->get('to') : '';
|
$to = $request->has('to') ? '?to=' . $request->get('to') : '';
|
||||||
|
|
||||||
if ($throttles && $this->hasTooManyLoginAttempts($request)) {
|
if ($throttles && $this->hasTooManyLoginAttempts($request)) {
|
||||||
return $this->sendLockoutResponse($request);
|
return $this->sendLockoutResponse($request);
|
||||||
@ -60,20 +60,20 @@ class LoginController extends Controller
|
|||||||
$this->incrementLoginAttempts($request);
|
$this->incrementLoginAttempts($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->to('login'.$to)
|
return redirect()->to('login' . $to)
|
||||||
->withErrors(trans('auth.failed'));
|
->withErrors(trans('auth.failed'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = Auth::getProvider()->retrieveByCredentials($credentials);
|
$user = Auth::getProvider()->retrieveByCredentials($credentials);
|
||||||
|
|
||||||
if ($user->isBanned()) {
|
if ($user->isBanned()) {
|
||||||
return redirect()->to('login'.$to)
|
return redirect()->to('login' . $to)
|
||||||
->withErrors(trans('auth.banned'));
|
->withErrors(trans('auth.banned'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$maxSessions = setting('max_active_sessions');
|
$maxSessions = setting('max_active_sessions');
|
||||||
if ($maxSessions && $sessions->getActiveSessionsCount($user->id) >= $maxSessions) {
|
if ($maxSessions && $sessions->getActiveSessionsCount($user->id) >= $maxSessions) {
|
||||||
return redirect()->to('login'.$to)
|
return redirect()->to('login' . $to)
|
||||||
->withErrors(trans('auth.max_sessions_reached'));
|
->withErrors(trans('auth.max_sessions_reached'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,21 +94,22 @@ class LoginController extends Controller
|
|||||||
$this->clearLoginAttempts($request);
|
$this->clearLoginAttempts($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
$redirectPage = $request->get('to');
|
// Redirezione basata sul ruolo con la prima lettera maiuscola e prefisso 'userarea/'
|
||||||
|
if ($user->hasRole('Admin')) {
|
||||||
if (setting('2fa.enabled') && $user->twoFactorEnabled()) {
|
return redirect()->to('userarea/admin.php');
|
||||||
return $this->logoutAndRedirectToTokenPage($request, $user, $redirectPage);
|
} elseif ($user->hasRole('User')) {
|
||||||
|
return redirect()->to('userarea/index.php');
|
||||||
|
} elseif ($user->hasRole('teacher')) {
|
||||||
|
return redirect()->to('userarea/teacher.php');
|
||||||
|
} elseif ($user->hasRole('school_owner')) {
|
||||||
|
return redirect()->to('userarea/school.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
event(new LoggedIn);
|
// Fallback nel caso il ruolo non corrisponda
|
||||||
|
return redirect()->intended('userarea/default.php');
|
||||||
if ($redirectPage) {
|
|
||||||
return redirect()->to($redirectPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
return redirect()->intended();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function logoutAndRedirectToTokenPage(Request $request, $user, ?string $redirectPage): RedirectResponse
|
protected function logoutAndRedirectToTokenPage(Request $request, $user, ?string $redirectPage): RedirectResponse
|
||||||
{
|
{
|
||||||
Auth::logout();
|
Auth::logout();
|
||||||
|
|||||||
@ -30,6 +30,7 @@
|
|||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"akaunting/laravel-setting": "^1.2.9",
|
"akaunting/laravel-setting": "^1.2.9",
|
||||||
"anhskohbo/no-captcha": "3.*",
|
"anhskohbo/no-captcha": "3.*",
|
||||||
|
"endroid/qr-code": "^6.0",
|
||||||
"guzzlehttp/guzzle": "^7.2",
|
"guzzlehttp/guzzle": "^7.2",
|
||||||
"intervention/image": "^2.3",
|
"intervention/image": "^2.3",
|
||||||
"jenssegers/agent": "^2.5",
|
"jenssegers/agent": "^2.5",
|
||||||
|
|||||||
74
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "7ed20966daeba17c2b7fec1306f6026f",
|
"content-hash": "e88a79d9daab1216f18318680b38681e",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "akaunting/laravel-setting",
|
"name": "akaunting/laravel-setting",
|
||||||
@ -741,6 +741,78 @@
|
|||||||
],
|
],
|
||||||
"time": "2023-10-06T06:47:41+00:00"
|
"time": "2023-10-06T06:47:41+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "endroid/qr-code",
|
||||||
|
"version": "6.0.6",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/endroid/qr-code.git",
|
||||||
|
"reference": "11e6a94458dab8dd18736c11892130ec788b5028"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/endroid/qr-code/zipball/11e6a94458dab8dd18736c11892130ec788b5028",
|
||||||
|
"reference": "11e6a94458dab8dd18736c11892130ec788b5028",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"bacon/bacon-qr-code": "^3.0",
|
||||||
|
"php": "^8.2"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"endroid/quality": "dev-main",
|
||||||
|
"ext-gd": "*",
|
||||||
|
"khanamiryan/qrcode-detector-decoder": "^2.0.2",
|
||||||
|
"setasign/fpdf": "^1.8.2"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-gd": "Enables you to write PNG images",
|
||||||
|
"khanamiryan/qrcode-detector-decoder": "Enables you to use the image validator",
|
||||||
|
"roave/security-advisories": "Makes sure package versions with known security issues are not installed",
|
||||||
|
"setasign/fpdf": "Enables you to use the PDF writer"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-main": "6.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Endroid\\QrCode\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Jeroen van den Enden",
|
||||||
|
"email": "info@endroid.nl"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Endroid QR Code",
|
||||||
|
"homepage": "https://github.com/endroid/qr-code",
|
||||||
|
"keywords": [
|
||||||
|
"code",
|
||||||
|
"endroid",
|
||||||
|
"php",
|
||||||
|
"qr",
|
||||||
|
"qrcode"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/endroid/qr-code/issues",
|
||||||
|
"source": "https://github.com/endroid/qr-code/tree/6.0.6"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/endroid",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2025-03-14T23:29:08+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "firebase/php-jwt",
|
"name": "firebase/php-jwt",
|
||||||
"version": "v6.10.1",
|
"version": "v6.10.1",
|
||||||
|
|||||||
BIN
public/phototeachers/qrcodes/2-df968f3ff71def10.png
Normal file
|
After Width: | Height: | Size: 352 B |
@ -1,109 +1,111 @@
|
|||||||
html.color-header .topbar .navbar-nav .nav-link {
|
html.color-header .topbar .navbar-nav .nav-link {
|
||||||
color: #fff
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
html.color-header .topbar .navbar .navbar-nav .nav-link:hover,
|
html.color-header .topbar .navbar .navbar-nav .nav-link:hover,
|
||||||
html.color-header .topbar .navbar .navbar-nav .nav-link:focus {
|
html.color-header .topbar .navbar .navbar-nav .nav-link:focus {
|
||||||
background-color: rgb(255 255 255 / 12%);
|
background-color: rgb(255 255 255 / 12%);
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
}
|
}
|
||||||
html.color-header .search-bar a.btn,
|
html.color-header .search-bar a.btn,
|
||||||
html.color-header .search-bar a.btn:focus{
|
html.color-header .search-bar a.btn:focus {
|
||||||
color: #221f1f;
|
color: #221f1f;
|
||||||
background-color: #ffffff;
|
background-color: #ffffff;
|
||||||
}
|
}
|
||||||
html.color-header::placeholder {
|
html.color-header::placeholder {
|
||||||
color: #08090a!important;
|
color: #08090a !important;
|
||||||
opacity: .5!important
|
opacity: 0.5 !important;
|
||||||
}
|
}
|
||||||
html.color-header .search-show {
|
html.color-header .search-show {
|
||||||
color: #221f1f
|
color: #221f1f;
|
||||||
}
|
}
|
||||||
html.color-header .user-info .user-name {
|
html.color-header .user-info .user-name {
|
||||||
color: #fff
|
color: #fff;
|
||||||
}
|
}
|
||||||
html.color-header .user-info .designattion {
|
html.color-header .user-info .designattion {
|
||||||
color: #fff
|
color: #fff;
|
||||||
}
|
}
|
||||||
html.color-header .user-box {
|
html.color-header .user-box {
|
||||||
border-left: 1px solid rgb(255 255 255 / .15) !important;
|
border-left: 1px solid rgb(255 255 255 / 0.15) !important;
|
||||||
border-right: 1px solid rgb(255 255 255 / .15) !important;
|
border-right: 1px solid rgb(255 255 255 / 0.15) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
html.color-header .mobile-toggle-menu {
|
html.color-header .mobile-toggle-menu {
|
||||||
color: #fff
|
color: #fff;
|
||||||
}
|
}
|
||||||
.switcher-body .headercolor1 {
|
.switcher-body .headercolor1 {
|
||||||
background: #0727d7!important
|
background: #0727d7 !important;
|
||||||
}
|
}
|
||||||
.switcher-body .headercolor2 {
|
.switcher-body .headercolor2 {
|
||||||
background: #23282c!important
|
background: #23282c !important;
|
||||||
}
|
}
|
||||||
.switcher-body .headercolor3 {
|
.switcher-body .headercolor3 {
|
||||||
background: #e10a1f!important
|
background: #e10a1f !important;
|
||||||
}
|
}
|
||||||
.switcher-body .headercolor4 {
|
.switcher-body .headercolor4 {
|
||||||
background: #157d4c!important
|
background: #157d4c !important;
|
||||||
}
|
}
|
||||||
.switcher-body .headercolor5 {
|
.switcher-body .headercolor5 {
|
||||||
background: #673ab7!important
|
background: #673ab7 !important;
|
||||||
}
|
}
|
||||||
.switcher-body .headercolor6 {
|
.switcher-body .headercolor6 {
|
||||||
background: #795548!important
|
background: #795548 !important;
|
||||||
}
|
}
|
||||||
.switcher-body .headercolor7 {
|
.switcher-body .headercolor7 {
|
||||||
background: #d3094e!important
|
background: #d3094e !important;
|
||||||
}
|
}
|
||||||
.switcher-body .headercolor8 {
|
.switcher-body .headercolor8 {
|
||||||
background: #ff9800!important
|
background: #ff9800 !important;
|
||||||
|
}
|
||||||
|
.switcher-body .headercolor9 {
|
||||||
|
background: #9e5f00 !important;
|
||||||
}
|
}
|
||||||
html.headercolor1 .topbar {
|
html.headercolor1 .topbar {
|
||||||
background: #0727d7
|
background: #0727d7;
|
||||||
}
|
}
|
||||||
html.headercolor2 .topbar {
|
html.headercolor2 .topbar {
|
||||||
background: #23282c
|
background: #23282c;
|
||||||
}
|
}
|
||||||
html.headercolor3 .topbar {
|
html.headercolor3 .topbar {
|
||||||
background: #e10a1f
|
background: #e10a1f;
|
||||||
}
|
}
|
||||||
html.headercolor4 .topbar {
|
html.headercolor4 .topbar {
|
||||||
background: #157d4c
|
background: #157d4c;
|
||||||
}
|
}
|
||||||
html.headercolor5 .topbar {
|
html.headercolor5 .topbar {
|
||||||
background: #673ab7
|
background: #673ab7;
|
||||||
}
|
}
|
||||||
html.headercolor6 .topbar {
|
html.headercolor6 .topbar {
|
||||||
background: #795548
|
background: #795548;
|
||||||
}
|
}
|
||||||
html.headercolor7 .topbar {
|
html.headercolor7 .topbar {
|
||||||
background: #d3094e
|
background: #d3094e;
|
||||||
}
|
}
|
||||||
html.headercolor8 .topbar {
|
html.headercolor8 .topbar {
|
||||||
background: #ff9800
|
background: #ff9800;
|
||||||
|
}
|
||||||
|
html.headercolor9 .topbar {
|
||||||
|
background: #f7c77f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* sidebar color */
|
/* sidebar color */
|
||||||
|
|
||||||
|
html.color-sidebar .sidebar-wrapper {
|
||||||
html.color-sidebar .sidebar-wrapper{
|
background-color: #171717;
|
||||||
background-color: #171717;
|
|
||||||
border-right: 1px solid rgb(228 228 228 / 0%);
|
border-right: 1px solid rgb(228 228 228 / 0%);
|
||||||
}
|
}
|
||||||
html.color-sidebar .sidebar-header{
|
html.color-sidebar .sidebar-header {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
border-right: 1px solid #e4e4e400;
|
border-right: 1px solid #e4e4e400;
|
||||||
border-bottom: 1px solid rgb(255 255 255 / 15%);
|
border-bottom: 1px solid rgb(255 255 255 / 15%);
|
||||||
position: absolute;
|
position: absolute;
|
||||||
}
|
}
|
||||||
html.color-sidebar .logo-icon {
|
html.color-sidebar .logo-icon {
|
||||||
filter: invert(1) grayscale(100%) brightness(200%);
|
filter: invert(1) grayscale(100%) brightness(200%);
|
||||||
}
|
}
|
||||||
|
|
||||||
html.color-sidebar .menu-label{
|
html.color-sidebar .menu-label {
|
||||||
color: rgb(255 255 255 / 65%);
|
color: rgb(255 255 255 / 65%);
|
||||||
}
|
}
|
||||||
|
|
||||||
html.color-sidebar .sidebar-wrapper .sidebar-header .logo-text {
|
html.color-sidebar .sidebar-wrapper .sidebar-header .logo-text {
|
||||||
@ -115,10 +117,13 @@ html.color-sidebar .sidebar-wrapper .sidebar-header .toggle-icon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
html.color-sidebar .simplebar-scrollbar:before {
|
html.color-sidebar .simplebar-scrollbar:before {
|
||||||
background: rgba(255, 255, 255, .4)
|
background: rgba(255, 255, 255, 0.4);
|
||||||
}
|
}
|
||||||
|
|
||||||
html.color-sidebar .sidebar-wrapper .metismenu .mm-active>a, html.color-sidebar .sidebar-wrapper .metismenu a:active, html.color-sidebar .sidebar-wrapper .metismenu a:focus, html.color-sidebar .sidebar-wrapper .metismenu a:hover {
|
html.color-sidebar .sidebar-wrapper .metismenu .mm-active > a,
|
||||||
|
html.color-sidebar .sidebar-wrapper .metismenu a:active,
|
||||||
|
html.color-sidebar .sidebar-wrapper .metismenu a:focus,
|
||||||
|
html.color-sidebar .sidebar-wrapper .metismenu a:hover {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
background: rgb(255 255 255 / 15%);
|
background: rgb(255 255 255 / 15%);
|
||||||
@ -133,7 +138,6 @@ html.color-sidebar .sidebar-wrapper .metismenu ul {
|
|||||||
background: rgb(255 255 255 / 0%);
|
background: rgb(255 255 255 / 0%);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
html.color-sidebar .sidebar-wrapper {
|
html.color-sidebar .sidebar-wrapper {
|
||||||
background-size: 100% 100%;
|
background-size: 100% 100%;
|
||||||
background-attachment: fixed;
|
background-attachment: fixed;
|
||||||
@ -141,35 +145,31 @@ html.color-sidebar .sidebar-wrapper {
|
|||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.switcher-wrapper .sidebarcolor1 {
|
.switcher-wrapper .sidebarcolor1 {
|
||||||
background-image: url(../images/bg-themes/1.png);
|
background-image: url(../images/bg-themes/1.png);
|
||||||
}
|
}
|
||||||
.switcher-wrapper .sidebarcolor2 {
|
.switcher-wrapper .sidebarcolor2 {
|
||||||
background-image: url(../images/bg-themes/2.png);
|
background-image: url(../images/bg-themes/2.png);
|
||||||
}
|
}
|
||||||
.switcher-wrapper .sidebarcolor3 {
|
.switcher-wrapper .sidebarcolor3 {
|
||||||
background-image: url(../images/bg-themes/3.png);
|
background-image: url(../images/bg-themes/3.png);
|
||||||
}
|
}
|
||||||
.switcher-wrapper .sidebarcolor4 {
|
.switcher-wrapper .sidebarcolor4 {
|
||||||
background-image: url(../images/bg-themes/4.png);
|
background-image: url(../images/bg-themes/4.png);
|
||||||
}
|
}
|
||||||
.switcher-wrapper .sidebarcolor5 {
|
.switcher-wrapper .sidebarcolor5 {
|
||||||
background-image: url(../images/bg-themes/5.png);
|
background-image: url(../images/bg-themes/5.png);
|
||||||
}
|
}
|
||||||
.switcher-wrapper .sidebarcolor6 {
|
.switcher-wrapper .sidebarcolor6 {
|
||||||
background-image: url(../images/bg-themes/6.png);
|
background-image: url(../images/bg-themes/6.png);
|
||||||
}
|
}
|
||||||
.switcher-wrapper .sidebarcolor7 {
|
.switcher-wrapper .sidebarcolor7 {
|
||||||
background-image: url(../images/bg-themes/7.png);
|
background-image: url(../images/bg-themes/7.png);
|
||||||
}
|
}
|
||||||
.switcher-wrapper .sidebarcolor8 {
|
.switcher-wrapper .sidebarcolor8 {
|
||||||
background-image: url(../images/bg-themes/8.png);
|
background-image: url(../images/bg-themes/8.png);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
html.color-sidebar.sidebarcolor1 .sidebar-wrapper {
|
html.color-sidebar.sidebarcolor1 .sidebar-wrapper {
|
||||||
background-image: url(../images/bg-themes/1.png);
|
background-image: url(../images/bg-themes/1.png);
|
||||||
}
|
}
|
||||||
@ -201,10 +201,3 @@ html.color-sidebar.sidebarcolor7 .sidebar-wrapper {
|
|||||||
html.color-sidebar.sidebarcolor8 .sidebar-wrapper {
|
html.color-sidebar.sidebarcolor8 .sidebar-wrapper {
|
||||||
background-image: url(../images/bg-themes/8.png);
|
background-image: url(../images/bg-themes/8.png);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,202 +1,235 @@
|
|||||||
$("html").attr("class", "semi-dark color-header headercolor2");
|
$("html").attr(
|
||||||
|
"class",
|
||||||
|
"semi-dark color-header " +
|
||||||
|
(localStorage.getItem("headerColor") || "headercolor4") +
|
||||||
|
" color-sidebar " +
|
||||||
|
(localStorage.getItem("sidebarColor") || "sidebarcolor9"),
|
||||||
|
);
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
new PerfectScrollbar(".app-container"),
|
new PerfectScrollbar(".app-container"),
|
||||||
new PerfectScrollbar(".header-message-list"),
|
new PerfectScrollbar(".header-message-list"),
|
||||||
new PerfectScrollbar(".header-notifications-list"),
|
new PerfectScrollbar(".header-notifications-list"),
|
||||||
$(".mobile-search-icon").on("click", function () {
|
$(".mobile-search-icon").on("click", function () {
|
||||||
$(".search-bar").addClass("full-search-bar");
|
$(".search-bar").addClass("full-search-bar");
|
||||||
}),
|
}),
|
||||||
$(".search-close").on("click", function () {
|
$(".search-close").on("click", function () {
|
||||||
$(".search-bar").removeClass("full-search-bar");
|
$(".search-bar").removeClass("full-search-bar");
|
||||||
}),
|
}),
|
||||||
$(".mobile-toggle-menu").on("click", function () {
|
$(".mobile-toggle-menu").on("click", function () {
|
||||||
$(".wrapper").addClass("toggled");
|
$(".wrapper").addClass("toggled");
|
||||||
}),
|
}),
|
||||||
$(".dark-mode").on("click", function () {
|
$(".dark-mode").on("click", function () {
|
||||||
if ($(".dark-mode-icon i").attr("class") == "bx bx-sun") {
|
if ($(".dark-mode-icon i").attr("class") == "bx bx-sun") {
|
||||||
$(".dark-mode-icon i").attr("class", "bx bx-moon");
|
$(".dark-mode-icon i").attr("class", "bx bx-moon");
|
||||||
$("html").attr("class", "light-theme");
|
$("html").attr("class", "light-theme");
|
||||||
} else {
|
} else {
|
||||||
$(".dark-mode-icon i").attr("class", "bx bx-sun");
|
$(".dark-mode-icon i").attr("class", "bx bx-sun");
|
||||||
$("html").attr("class", "dark-theme");
|
$("html").attr("class", "dark-theme");
|
||||||
}
|
|
||||||
}),
|
|
||||||
$(".toggle-icon").click(function () {
|
|
||||||
$(".wrapper").hasClass("toggled")
|
|
||||||
? ($(".wrapper").removeClass("toggled"),
|
|
||||||
$(".sidebar-wrapper").unbind("hover"))
|
|
||||||
: ($(".wrapper").addClass("toggled"),
|
|
||||||
$(".sidebar-wrapper").hover(
|
|
||||||
function () {
|
|
||||||
$(".wrapper").addClass("sidebar-hovered");
|
|
||||||
},
|
|
||||||
function () {
|
|
||||||
$(".wrapper").removeClass("sidebar-hovered");
|
|
||||||
}
|
}
|
||||||
));
|
}),
|
||||||
}),
|
$(".toggle-icon").click(function () {
|
||||||
$(document).ready(function () {
|
$(".wrapper").hasClass("toggled")
|
||||||
$(window).on("scroll", function () {
|
? ($(".wrapper").removeClass("toggled"),
|
||||||
$(this).scrollTop() > 300
|
$(".sidebar-wrapper").unbind("hover"))
|
||||||
? $(".back-to-top").fadeIn()
|
: ($(".wrapper").addClass("toggled"),
|
||||||
: $(".back-to-top").fadeOut();
|
$(".sidebar-wrapper").hover(
|
||||||
}),
|
function () {
|
||||||
$(".back-to-top").on("click", function () {
|
$(".wrapper").addClass("sidebar-hovered");
|
||||||
return (
|
},
|
||||||
$("html, body").animate(
|
function () {
|
||||||
{
|
$(".wrapper").removeClass("sidebar-hovered");
|
||||||
scrollTop: 0,
|
},
|
||||||
},
|
));
|
||||||
600
|
}),
|
||||||
),
|
$(document).ready(function () {
|
||||||
!1
|
$(window).on("scroll", function () {
|
||||||
);
|
$(this).scrollTop() > 300
|
||||||
});
|
? $(".back-to-top").fadeIn()
|
||||||
}),
|
: $(".back-to-top").fadeOut();
|
||||||
$(function () {
|
}),
|
||||||
for (
|
$(".back-to-top").on("click", function () {
|
||||||
var e = window.location,
|
return (
|
||||||
o = $(".metismenu li a")
|
$("html, body").animate(
|
||||||
.filter(function () {
|
{
|
||||||
return this.href == e;
|
scrollTop: 0,
|
||||||
})
|
},
|
||||||
.addClass("")
|
600,
|
||||||
.parent()
|
),
|
||||||
.addClass("mm-active");
|
!1
|
||||||
o.is("li");
|
);
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
$(function () {
|
||||||
|
for (
|
||||||
|
var e = window.location,
|
||||||
|
o = $(".metismenu li a")
|
||||||
|
.filter(function () {
|
||||||
|
return this.href == e;
|
||||||
|
})
|
||||||
|
.addClass("")
|
||||||
|
.parent()
|
||||||
|
.addClass("mm-active");
|
||||||
|
o.is("li");
|
||||||
|
|
||||||
|
)
|
||||||
|
o = o
|
||||||
|
.parent("")
|
||||||
|
.addClass("mm-show")
|
||||||
|
.parent("")
|
||||||
|
.addClass("mm-active");
|
||||||
|
}),
|
||||||
|
$(function () {
|
||||||
|
$("#menu").metisMenu();
|
||||||
|
}),
|
||||||
|
$(".chat-toggle-btn").on("click", function () {
|
||||||
|
$(".chat-wrapper").toggleClass("chat-toggled");
|
||||||
|
}),
|
||||||
|
$(".chat-toggle-btn-mobile").on("click", function () {
|
||||||
|
$(".chat-wrapper").removeClass("chat-toggled");
|
||||||
|
}),
|
||||||
|
$(".email-toggle-btn").on("click", function () {
|
||||||
|
$(".email-wrapper").toggleClass("email-toggled");
|
||||||
|
}),
|
||||||
|
$(".email-toggle-btn-mobile").on("click", function () {
|
||||||
|
$(".email-wrapper").removeClass("email-toggled");
|
||||||
|
}),
|
||||||
|
$(".compose-mail-btn").on("click", function () {
|
||||||
|
$(".compose-mail-popup").show();
|
||||||
|
}),
|
||||||
|
$(".compose-mail-close").on("click", function () {
|
||||||
|
$(".compose-mail-popup").hide();
|
||||||
|
}),
|
||||||
|
$(".switcher-btn").on("click", function () {
|
||||||
|
$(".switcher-wrapper").toggleClass("switcher-toggled");
|
||||||
|
}),
|
||||||
|
$(".close-switcher").on("click", function () {
|
||||||
|
$(".switcher-wrapper").removeClass("switcher-toggled");
|
||||||
|
}),
|
||||||
|
$("#lightmode").on("click", function () {
|
||||||
|
$("html").attr("class", "light-theme");
|
||||||
|
}),
|
||||||
|
$("#darkmode").on("click", function () {
|
||||||
|
$("html").attr("class", "dark-theme");
|
||||||
|
}),
|
||||||
|
$("#semidark").on("click", function () {
|
||||||
|
$("html").attr("class", "semi-dark");
|
||||||
|
}),
|
||||||
|
$("#minimaltheme").on("click", function () {
|
||||||
|
$("html").attr("class", "minimal-theme");
|
||||||
|
}),
|
||||||
|
$("#headercolor1").on("click", function () {
|
||||||
|
$("html").addClass("color-header headercolor1"),
|
||||||
|
$("html").removeClass(
|
||||||
|
"headercolor2 headercolor3 headercolor4 headercolor5 headercolor6 headercolor7 headercolor8 headercolor9",
|
||||||
|
);
|
||||||
|
localStorage.setItem("headerColor", "headercolor1");
|
||||||
|
});
|
||||||
|
|
||||||
)
|
|
||||||
o = o.parent("").addClass("mm-show").parent("").addClass("mm-active");
|
|
||||||
}),
|
|
||||||
$(function () {
|
|
||||||
$("#menu").metisMenu();
|
|
||||||
}),
|
|
||||||
$(".chat-toggle-btn").on("click", function () {
|
|
||||||
$(".chat-wrapper").toggleClass("chat-toggled");
|
|
||||||
}),
|
|
||||||
$(".chat-toggle-btn-mobile").on("click", function () {
|
|
||||||
$(".chat-wrapper").removeClass("chat-toggled");
|
|
||||||
}),
|
|
||||||
$(".email-toggle-btn").on("click", function () {
|
|
||||||
$(".email-wrapper").toggleClass("email-toggled");
|
|
||||||
}),
|
|
||||||
$(".email-toggle-btn-mobile").on("click", function () {
|
|
||||||
$(".email-wrapper").removeClass("email-toggled");
|
|
||||||
}),
|
|
||||||
$(".compose-mail-btn").on("click", function () {
|
|
||||||
$(".compose-mail-popup").show();
|
|
||||||
}),
|
|
||||||
$(".compose-mail-close").on("click", function () {
|
|
||||||
$(".compose-mail-popup").hide();
|
|
||||||
}),
|
|
||||||
$(".switcher-btn").on("click", function () {
|
|
||||||
$(".switcher-wrapper").toggleClass("switcher-toggled");
|
|
||||||
}),
|
|
||||||
$(".close-switcher").on("click", function () {
|
|
||||||
$(".switcher-wrapper").removeClass("switcher-toggled");
|
|
||||||
}),
|
|
||||||
$("#lightmode").on("click", function () {
|
|
||||||
$("html").attr("class", "light-theme");
|
|
||||||
}),
|
|
||||||
$("#darkmode").on("click", function () {
|
|
||||||
$("html").attr("class", "dark-theme");
|
|
||||||
}),
|
|
||||||
$("#semidark").on("click", function () {
|
|
||||||
$("html").attr("class", "semi-dark");
|
|
||||||
}),
|
|
||||||
$("#minimaltheme").on("click", function () {
|
|
||||||
$("html").attr("class", "minimal-theme");
|
|
||||||
}),
|
|
||||||
$("#headercolor1").on("click", function () {
|
|
||||||
$("html").addClass("color-header headercolor1"),
|
|
||||||
$("html").removeClass(
|
|
||||||
"headercolor2 headercolor3 headercolor4 headercolor5 headercolor6 headercolor7 headercolor8"
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
$("#headercolor2").on("click", function () {
|
$("#headercolor2").on("click", function () {
|
||||||
$("html").addClass("color-header headercolor2"),
|
$("html").addClass("color-header headercolor2"),
|
||||||
$("html").removeClass(
|
$("html").removeClass(
|
||||||
"headercolor1 headercolor3 headercolor4 headercolor5 headercolor6 headercolor7 headercolor8"
|
"headercolor1 headercolor3 headercolor4 headercolor5 headercolor6 headercolor7 headercolor8 headercolor9",
|
||||||
);
|
);
|
||||||
}),
|
localStorage.setItem("headerColor", "headercolor2");
|
||||||
$("#headercolor3").on("click", function () {
|
|
||||||
$("html").addClass("color-header headercolor3"),
|
|
||||||
$("html").removeClass(
|
|
||||||
"headercolor1 headercolor2 headercolor4 headercolor5 headercolor6 headercolor7 headercolor8"
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
$("#headercolor4").on("click", function () {
|
|
||||||
$("html").addClass("color-header headercolor4"),
|
|
||||||
$("html").removeClass(
|
|
||||||
"headercolor1 headercolor2 headercolor3 headercolor5 headercolor6 headercolor7 headercolor8"
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
$("#headercolor5").on("click", function () {
|
|
||||||
$("html").addClass("color-header headercolor5"),
|
|
||||||
$("html").removeClass(
|
|
||||||
"headercolor1 headercolor2 headercolor4 headercolor3 headercolor6 headercolor7 headercolor8"
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
$("#headercolor6").on("click", function () {
|
|
||||||
$("html").addClass("color-header headercolor6"),
|
|
||||||
$("html").removeClass(
|
|
||||||
"headercolor1 headercolor2 headercolor4 headercolor5 headercolor3 headercolor7 headercolor8"
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
$("#headercolor7").on("click", function () {
|
|
||||||
$("html").addClass("color-header headercolor7"),
|
|
||||||
$("html").removeClass(
|
|
||||||
"headercolor1 headercolor2 headercolor4 headercolor5 headercolor6 headercolor3 headercolor8"
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
$("#headercolor8").on("click", function () {
|
|
||||||
$("html").addClass("color-header headercolor8"),
|
|
||||||
$("html").removeClass(
|
|
||||||
"headercolor1 headercolor2 headercolor4 headercolor5 headercolor6 headercolor7 headercolor3"
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// sidebar colors
|
$("#headercolor3").on("click", function () {
|
||||||
$("#sidebarcolor1").click(theme1);
|
$("html").addClass("color-header headercolor3"),
|
||||||
$("#sidebarcolor2").click(theme2);
|
$("html").removeClass(
|
||||||
$("#sidebarcolor3").click(theme3);
|
"headercolor1 headercolor2 headercolor4 headercolor5 headercolor6 headercolor7 headercolor8 headercolor9",
|
||||||
$("#sidebarcolor4").click(theme4);
|
);
|
||||||
$("#sidebarcolor5").click(theme5);
|
localStorage.setItem("headerColor", "headercolor3");
|
||||||
$("#sidebarcolor6").click(theme6);
|
});
|
||||||
$("#sidebarcolor7").click(theme7);
|
|
||||||
$("#sidebarcolor8").click(theme8);
|
|
||||||
|
|
||||||
function theme1() {
|
$("#headercolor4").on("click", function () {
|
||||||
$("html").attr("class", "color-sidebar sidebarcolor1");
|
$("html").addClass("color-header headercolor4"),
|
||||||
}
|
$("html").removeClass(
|
||||||
|
"headercolor1 headercolor2 headercolor3 headercolor5 headercolor6 headercolor7 headercolor8 headercolor9",
|
||||||
|
);
|
||||||
|
localStorage.setItem("headerColor", "headercolor4");
|
||||||
|
});
|
||||||
|
|
||||||
function theme2() {
|
$("#headercolor5").on("click", function () {
|
||||||
$("html").attr("class", "color-sidebar sidebarcolor2");
|
$("html").addClass("color-header headercolor5"),
|
||||||
}
|
$("html").removeClass(
|
||||||
|
"headercolor1 headercolor2 headercolor4 headercolor3 headercolor6 headercolor7 headercolor8 headercolor9",
|
||||||
|
);
|
||||||
|
localStorage.setItem("headerColor", "headercolor5");
|
||||||
|
});
|
||||||
|
|
||||||
function theme3() {
|
$("#headercolor6").on("click", function () {
|
||||||
$("html").attr("class", "color-sidebar sidebarcolor3");
|
$("html").addClass("color-header headercolor6"),
|
||||||
}
|
$("html").removeClass(
|
||||||
|
"headercolor1 headercolor2 headercolor4 headercolor5 headercolor3 headercolor7 headercolor8 headercolor9",
|
||||||
|
);
|
||||||
|
localStorage.setItem("headerColor", "headercolor6");
|
||||||
|
});
|
||||||
|
|
||||||
function theme4() {
|
$("#headercolor7").on("click", function () {
|
||||||
$("html").attr("class", "color-sidebar sidebarcolor4");
|
$("html").addClass("color-header headercolor7"),
|
||||||
}
|
$("html").removeClass(
|
||||||
|
"headercolor1 headercolor2 headercolor4 headercolor5 headercolor6 headercolor3 headercolor8 headercolor9",
|
||||||
|
);
|
||||||
|
localStorage.setItem("headerColor", "headercolor7");
|
||||||
|
});
|
||||||
|
|
||||||
function theme5() {
|
$("#headercolor8").on("click", function () {
|
||||||
$("html").attr("class", "color-sidebar sidebarcolor5");
|
$("html").addClass("color-header headercolor8"),
|
||||||
}
|
$("html").removeClass(
|
||||||
|
"headercolor1 headercolor2 headercolor4 headercolor5 headercolor6 headercolor7 headercolor3 headercolor9",
|
||||||
|
);
|
||||||
|
localStorage.setItem("headerColor", "headercolor8");
|
||||||
|
});
|
||||||
|
|
||||||
function theme6() {
|
$("#headercolor9").on("click", function () {
|
||||||
$("html").attr("class", "color-sidebar sidebarcolor6");
|
$("html").addClass("color-header headercolor9"),
|
||||||
}
|
$("html").removeClass(
|
||||||
|
"headercolor1 headercolor2 headercolor3 headercolor4 headercolor5 headercolor6 headercolor7 headercolor8",
|
||||||
|
);
|
||||||
|
localStorage.setItem("headerColor", "headercolor9");
|
||||||
|
});
|
||||||
|
|
||||||
function theme7() {
|
// sidebar colors
|
||||||
$("html").attr("class", "color-sidebar sidebarcolor7");
|
$("#sidebarcolor1").click(theme1);
|
||||||
}
|
$("#sidebarcolor2").click(theme2);
|
||||||
|
$("#sidebarcolor3").click(theme3);
|
||||||
|
$("#sidebarcolor4").click(theme4);
|
||||||
|
$("#sidebarcolor5").click(theme5);
|
||||||
|
$("#sidebarcolor6").click(theme6);
|
||||||
|
$("#sidebarcolor7").click(theme7);
|
||||||
|
$("#sidebarcolor8").click(theme8);
|
||||||
|
|
||||||
function theme8() {
|
function theme1() {
|
||||||
$("html").attr("class", "color-sidebar sidebarcolor8");
|
$("html").attr("class", "color-sidebar sidebarcolor1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function theme2() {
|
||||||
|
$("html").attr("class", "color-sidebar sidebarcolor2");
|
||||||
|
}
|
||||||
|
|
||||||
|
function theme3() {
|
||||||
|
$("html").attr("class", "color-sidebar sidebarcolor3");
|
||||||
|
}
|
||||||
|
|
||||||
|
function theme4() {
|
||||||
|
$("html").attr("class", "color-sidebar sidebarcolor4");
|
||||||
|
}
|
||||||
|
|
||||||
|
function theme5() {
|
||||||
|
$("html").attr("class", "color-sidebar sidebarcolor5");
|
||||||
|
}
|
||||||
|
|
||||||
|
function theme6() {
|
||||||
|
$("html").attr("class", "color-sidebar sidebarcolor6");
|
||||||
|
}
|
||||||
|
|
||||||
|
function theme7() {
|
||||||
|
$("html").attr("class", "color-sidebar sidebarcolor7");
|
||||||
|
}
|
||||||
|
|
||||||
|
function theme8() {
|
||||||
|
$("html").attr("class", "color-sidebar sidebarcolor8");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
277
public/userarea/class_categories.php
Normal file
@ -0,0 +1,277 @@
|
|||||||
|
<?php
|
||||||
|
// Forza la visualizzazione degli errori
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
ini_set('display_startup_errors', 1);
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
|
include('include/headscript.php');
|
||||||
|
|
||||||
|
// Connessione al database
|
||||||
|
$dbHandler = DBHandlerSelect::getInstance();
|
||||||
|
$pdo = $dbHandler->getConnection();
|
||||||
|
|
||||||
|
// Gestione delle azioni (aggiunta, modifica, cancellazione)
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
if (isset($_POST['action'])) {
|
||||||
|
$action = $_POST['action'];
|
||||||
|
|
||||||
|
// Aggiunta di una nuova categoria
|
||||||
|
if ($action === 'add') {
|
||||||
|
$name = $_POST['name'] ?? '';
|
||||||
|
$description = $_POST['description'] ?? null;
|
||||||
|
$status = $_POST['status'] === 'active' ? 'active' : 'inactive';
|
||||||
|
|
||||||
|
if (empty($name)) {
|
||||||
|
$error = "Il nome della categoria è obbligatorio.";
|
||||||
|
} else {
|
||||||
|
$stmt = $pdo->prepare("
|
||||||
|
INSERT INTO class_categories (name, description, status)
|
||||||
|
VALUES (?, ?, ?)
|
||||||
|
");
|
||||||
|
$success = $stmt->execute([$name, $description, $status]);
|
||||||
|
|
||||||
|
if ($success) {
|
||||||
|
$success_message = "Categoria aggiunta con successo!";
|
||||||
|
} else {
|
||||||
|
$error = "Errore durante l'aggiunta della categoria.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Modifica di una categoria esistente
|
||||||
|
if ($action === 'edit') {
|
||||||
|
$id = $_POST['id'] ?? 0;
|
||||||
|
$name = $_POST['name'] ?? '';
|
||||||
|
$description = $_POST['description'] ?? null;
|
||||||
|
$status = $_POST['status'] === 'active' ? 'active' : 'inactive';
|
||||||
|
|
||||||
|
if (empty($name)) {
|
||||||
|
$error = "Il nome della categoria è obbligatorio.";
|
||||||
|
} else {
|
||||||
|
$stmt = $pdo->prepare("
|
||||||
|
UPDATE class_categories
|
||||||
|
SET name = ?, description = ?, status = ?
|
||||||
|
WHERE id = ?
|
||||||
|
");
|
||||||
|
$success = $stmt->execute([$name, $description, $status, $id]);
|
||||||
|
|
||||||
|
if ($success) {
|
||||||
|
$success_message = "Categoria aggiornata con successo!";
|
||||||
|
} else {
|
||||||
|
$error = "Errore durante l'aggiornamento della categoria.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cancellazione di una categoria
|
||||||
|
if ($action === 'delete') {
|
||||||
|
$id = $_POST['id'] ?? 0;
|
||||||
|
$stmt = $pdo->prepare("DELETE FROM class_categories WHERE id = ?");
|
||||||
|
$success = $stmt->execute([$id]);
|
||||||
|
|
||||||
|
if ($success) {
|
||||||
|
$success_message = "Categoria eliminata con successo!";
|
||||||
|
} else {
|
||||||
|
$error = "Errore durante l'eliminazione della categoria.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reindirizza per evitare il doppio invio del form
|
||||||
|
header("Location: class_categories.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recupera tutte le categorie
|
||||||
|
$stmt = $pdo->prepare("SELECT * FROM class_categories ORDER BY created_at DESC");
|
||||||
|
$stmt->execute();
|
||||||
|
$categories = $stmt->fetchAll();
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link rel="icon" href="assets/images/favicon-32x32.png" type="image/png" />
|
||||||
|
<?php include('cssinclude.php'); ?>
|
||||||
|
<?php include('siteinfo.php'); ?>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="wrapper">
|
||||||
|
<?php include('include/navbar.php'); ?>
|
||||||
|
<?php include('include/topbar.php'); ?>
|
||||||
|
<div class="page-wrapper">
|
||||||
|
<div class="page-content">
|
||||||
|
<div class="card radius-10">
|
||||||
|
<div class="card-header">
|
||||||
|
<div class="d-flex align-items-center">
|
||||||
|
<div>
|
||||||
|
<h6 class="mb-0">Gestione Categorie Classi</h6>
|
||||||
|
</div>
|
||||||
|
<div class="ms-auto">
|
||||||
|
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addCategoryModal">
|
||||||
|
Aggiungi Categoria
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<?php if (isset($success_message)): ?>
|
||||||
|
<div class="alert alert-success" role="alert">
|
||||||
|
<?php echo $success_message; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if (isset($error)): ?>
|
||||||
|
<div class="alert alert-danger" role="alert">
|
||||||
|
<?php echo $error; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table id="categoriesTable" class="table table-striped table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Nome</th>
|
||||||
|
<th>Descrizione</th>
|
||||||
|
<th>Stato</th>
|
||||||
|
<th>Data Creazione</th>
|
||||||
|
<th>Ultimo Aggiornamento</th>
|
||||||
|
<th>Azioni</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($categories as $category): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo htmlspecialchars($category['id']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($category['name']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($category['description'] ?? ''); ?></td>
|
||||||
|
<td>
|
||||||
|
<span class="badge <?php echo $category['status'] === 'active' ? 'bg-success' : 'bg-danger'; ?>">
|
||||||
|
<?php echo $category['status'] === 'active' ? 'Attivo' : 'Inattivo'; ?>
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td><?php echo htmlspecialchars($category['created_at']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($category['updated_at']); ?></td>
|
||||||
|
<td>
|
||||||
|
<button type="button" class="btn btn-sm btn-warning" data-bs-toggle="modal" data-bs-target="#editCategoryModal"
|
||||||
|
onclick="fillEditModal(<?php echo $category['id']; ?>, '<?php echo htmlspecialchars($category['name'], ENT_QUOTES); ?>', '<?php echo htmlspecialchars($category['description'] ?? '', ENT_QUOTES); ?>', '<?php echo $category['status']; ?>')">
|
||||||
|
Modifica
|
||||||
|
</button>
|
||||||
|
<form action="" method="POST" style="display:inline;" onsubmit="return confirm('Sei sicuro di voler eliminare questa categoria?');">
|
||||||
|
<input type="hidden" name="action" value="delete">
|
||||||
|
<input type="hidden" name="id" value="<?php echo $category['id']; ?>">
|
||||||
|
<button type="submit" class="btn btn-sm btn-danger">Elimina</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Modale per aggiungere una categoria -->
|
||||||
|
<div class="modal fade" id="addCategoryModal" tabindex="-1" aria-labelledby="addCategoryModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="addCategoryModalLabel">Aggiungi Categoria</h5>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<form action="" method="POST">
|
||||||
|
<div class="modal-body">
|
||||||
|
<input type="hidden" name="action" value="add">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="add_name" class="form-label">Nome</label>
|
||||||
|
<input type="text" class="form-control" id="add_name" name="name" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="add_description" class="form-label">Descrizione</label>
|
||||||
|
<textarea class="form-control" id="add_description" name="description" rows="3"></textarea>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="add_status" class="form-label">Stato</label>
|
||||||
|
<div class="form-check form-switch">
|
||||||
|
<input class="form-check-input" type="checkbox" id="add_status" name="status" value="active" checked>
|
||||||
|
<label class="form-check-label" for="add_status">Attivo</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Chiudi</button>
|
||||||
|
<button type="submit" class="btn btn-primary">Aggiungi</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Modale per modificare una categoria -->
|
||||||
|
<div class="modal fade" id="editCategoryModal" tabindex="-1" aria-labelledby="editCategoryModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="editCategoryModalLabel">Modifica Categoria</h5>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<form action="" method="POST">
|
||||||
|
<div class="modal-body">
|
||||||
|
<input type="hidden" name="action" value="edit">
|
||||||
|
<input type="hidden" name="id" id="edit_id">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="edit_name" class="form-label">Nome</label>
|
||||||
|
<input type="text" class="form-control" id="edit_name" name="name" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="edit_description" class="form-label">Descrizione</label>
|
||||||
|
<textarea class="form-control" id="edit_description" name="description" rows="3"></textarea>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="edit_status" class="form-label">Stato</label>
|
||||||
|
<div class="form-check form-switch">
|
||||||
|
<input class="form-check-input" type="checkbox" id="edit_status" name="status" value="active">
|
||||||
|
<label class="form-check-label" for="edit_status">Attivo</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Chiudi</button>
|
||||||
|
<button type="submit" class="btn btn-primary">Salva Modifiche</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="overlay toggle-icon"></div>
|
||||||
|
<a href="javaScript:;" class="back-to-top"><i class='bx bxs-up-arrow-alt'></i></a>
|
||||||
|
<?php include('include/footer.php'); ?>
|
||||||
|
</div>
|
||||||
|
<?php include('jsinclude.php'); ?>
|
||||||
|
|
||||||
|
<!-- Script per inizializzare DataTables e gestire il modale di modifica -->
|
||||||
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#categoriesTable').DataTable({
|
||||||
|
"language": {
|
||||||
|
"url": "//cdn.datatables.net/plug-ins/1.10.25/i18n/Italian.json"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function fillEditModal(id, name, description, status) {
|
||||||
|
document.getElementById('edit_id').value = id;
|
||||||
|
document.getElementById('edit_name').value = name;
|
||||||
|
document.getElementById('edit_description').value = description;
|
||||||
|
document.getElementById('edit_status').checked = (status === 'active');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
612
public/userarea/class_types.php
Normal file
@ -0,0 +1,612 @@
|
|||||||
|
<?php
|
||||||
|
// Forza la visualizzazione degli errori
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
ini_set('display_startup_errors', 1);
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
|
include('include/headscript.php');
|
||||||
|
|
||||||
|
// Connessione al database
|
||||||
|
$dbHandler = DBHandlerSelect::getInstance();
|
||||||
|
$pdo = $dbHandler->getConnection();
|
||||||
|
|
||||||
|
// Verifica che iduserlogin sia definito
|
||||||
|
if (!isset($iduserlogin)) {
|
||||||
|
die("Errore: ID utente non definito.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recupera l'ID della scuola in base all'utente loggato
|
||||||
|
$stmt = $pdo->prepare("SELECT id, name FROM schools WHERE owner_id = ?");
|
||||||
|
$stmt->execute([$iduserlogin]);
|
||||||
|
$school = $stmt->fetch();
|
||||||
|
if (!$school) {
|
||||||
|
die("Errore: Nessuna scuola trovata per l'utente loggato.");
|
||||||
|
}
|
||||||
|
$school_id = $school['id'];
|
||||||
|
$school_name = $school['name'];
|
||||||
|
|
||||||
|
// Recupera tutte le categorie disponibili
|
||||||
|
$stmt = $pdo->prepare("SELECT id, name FROM class_categories WHERE status = 'active' ORDER BY name");
|
||||||
|
$stmt->execute();
|
||||||
|
$categories = $stmt->fetchAll();
|
||||||
|
|
||||||
|
// Funzione per ridimensionare l'immagine
|
||||||
|
function resizeImage($source_path, $dest_path, $max_width = 800)
|
||||||
|
{
|
||||||
|
list($width, $height, $type) = getimagesize($source_path);
|
||||||
|
if ($width <= $max_width) {
|
||||||
|
copy($source_path, $dest_path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$new_width = $max_width;
|
||||||
|
$new_height = (int)(($height * $new_width) / $width);
|
||||||
|
|
||||||
|
switch ($type) {
|
||||||
|
case IMAGETYPE_JPEG:
|
||||||
|
$source = imagecreatefromjpeg($source_path);
|
||||||
|
break;
|
||||||
|
case IMAGETYPE_PNG:
|
||||||
|
$source = imagecreatefrompng($source_path);
|
||||||
|
break;
|
||||||
|
case IMAGETYPE_GIF:
|
||||||
|
$source = imagecreatefromgif($source_path);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Exception("Formato immagine non supportato.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$dest = imagecreatetruecolor($new_width, $new_height);
|
||||||
|
if ($type == IMAGETYPE_PNG) {
|
||||||
|
imagealphablending($dest, false);
|
||||||
|
imagesavealpha($dest, true);
|
||||||
|
}
|
||||||
|
imagecopyresampled($dest, $source, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
|
||||||
|
|
||||||
|
switch ($type) {
|
||||||
|
case IMAGETYPE_JPEG:
|
||||||
|
imagejpeg($dest, $dest_path, 90);
|
||||||
|
break;
|
||||||
|
case IMAGETYPE_PNG:
|
||||||
|
imagepng($dest, $dest_path);
|
||||||
|
break;
|
||||||
|
case IMAGETYPE_GIF:
|
||||||
|
imagegif($dest, $dest_path);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
imagedestroy($source);
|
||||||
|
imagedestroy($dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gestione delle azioni (aggiunta, modifica, cancellazione)
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
if (isset($_POST['action'])) {
|
||||||
|
$action = $_POST['action'];
|
||||||
|
|
||||||
|
// Aggiunta di una nuova classe
|
||||||
|
if ($action === 'add') {
|
||||||
|
$class_category_id = $_POST['class_category_id'] ?? 0;
|
||||||
|
$name = $_POST['name'] ?? '';
|
||||||
|
$description = $_POST['description'] ?? null;
|
||||||
|
$requirements = $_POST['requirements'] ?? null;
|
||||||
|
$level = in_array($_POST['level'], ['beginner', 'intermediate', 'advanced']) ? $_POST['level'] : 'beginner';
|
||||||
|
$typical_duration = $_POST['typical_duration'] ? (int)$_POST['typical_duration'] : null;
|
||||||
|
$days_of_week = $_POST['days_of_week'] ?? '';
|
||||||
|
$start_time = $_POST['start_time'] ?? '';
|
||||||
|
$period_start = $_POST['period_start'] ?? '';
|
||||||
|
$period_end = $_POST['period_end'] ?? '';
|
||||||
|
$status = $_POST['status'] === 'active' ? 'active' : 'inactive';
|
||||||
|
|
||||||
|
if (empty($name) || $class_category_id <= 0 || empty($days_of_week) || empty($start_time) || empty($period_start) || empty($period_end)) {
|
||||||
|
$error = "I campi obbligatori non sono stati compilati.";
|
||||||
|
} else {
|
||||||
|
$photo = null;
|
||||||
|
if (isset($_FILES['photo']) && $_FILES['photo']['error'] === UPLOAD_ERR_OK) {
|
||||||
|
$file = $_FILES['photo'];
|
||||||
|
$timestamp = time();
|
||||||
|
$original_name = basename($file['name']);
|
||||||
|
$extension = strtolower(pathinfo($original_name, PATHINFO_EXTENSION));
|
||||||
|
$allowed_extensions = ['jpg', 'jpeg', 'png', 'gif'];
|
||||||
|
|
||||||
|
if (in_array($extension, $allowed_extensions)) {
|
||||||
|
$new_filename = "photoclass/{$school_id}-{$timestamp}-{$original_name}";
|
||||||
|
$temp_path = $file['tmp_name'];
|
||||||
|
try {
|
||||||
|
resizeImage($temp_path, $new_filename);
|
||||||
|
$photo = $new_filename;
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$error = "Errore durante il ridimensionamento della foto: " . $e->getMessage();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$error = "Estensione del file non consentita. Usa JPG, JPEG, PNG o GIF.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($error)) {
|
||||||
|
$stmt = $pdo->prepare("
|
||||||
|
INSERT INTO class_types (school_id, class_category_id, name, description, photo, requirements, level, typical_duration, days_of_week, start_time, period_start, period_end, status)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
|
");
|
||||||
|
$success = $stmt->execute([
|
||||||
|
$school_id,
|
||||||
|
$class_category_id,
|
||||||
|
$name,
|
||||||
|
$description,
|
||||||
|
$photo,
|
||||||
|
$requirements,
|
||||||
|
$level,
|
||||||
|
$typical_duration,
|
||||||
|
$days_of_week,
|
||||||
|
$start_time,
|
||||||
|
$period_start,
|
||||||
|
$period_end,
|
||||||
|
$status
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($success) {
|
||||||
|
$success_message = "Classe aggiunta con successo!";
|
||||||
|
} else {
|
||||||
|
$error = "Errore durante l'aggiunta della classe.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Modifica di una classe esistente
|
||||||
|
if ($action === 'edit') {
|
||||||
|
$id = $_POST['id'] ?? 0;
|
||||||
|
$class_category_id = $_POST['class_category_id'] ?? 0;
|
||||||
|
$name = $_POST['name'] ?? '';
|
||||||
|
$description = $_POST['description'] ?? null;
|
||||||
|
$requirements = $_POST['requirements'] ?? null;
|
||||||
|
$level = in_array($_POST['level'], ['beginner', 'intermediate', 'advanced']) ? $_POST['level'] : 'beginner';
|
||||||
|
$typical_duration = $_POST['typical_duration'] ? (int)$_POST['typical_duration'] : null;
|
||||||
|
$days_of_week = $_POST['days_of_week'] ?? '';
|
||||||
|
$start_time = $_POST['start_time'] ?? '';
|
||||||
|
$period_start = $_POST['period_start'] ?? '';
|
||||||
|
$period_end = $_POST['period_end'] ?? '';
|
||||||
|
$status = $_POST['status'] === 'active' ? 'active' : 'inactive';
|
||||||
|
|
||||||
|
if (empty($name) || $class_category_id <= 0 || empty($days_of_week) || empty($start_time) || empty($period_start) || empty($period_end)) {
|
||||||
|
$error = "I campi obbligatori non sono stati compilati.";
|
||||||
|
} else {
|
||||||
|
// Recupera la classe esistente per ottenere il percorso della foto attuale
|
||||||
|
$stmt = $pdo->prepare("SELECT photo FROM class_types WHERE id = ? AND school_id = ?");
|
||||||
|
$stmt->execute([$id, $school_id]);
|
||||||
|
$class = $stmt->fetch();
|
||||||
|
if (!$class) {
|
||||||
|
$error = "Classe non trovata.";
|
||||||
|
} else {
|
||||||
|
$photo = $class['photo'];
|
||||||
|
if (isset($_FILES['photo']) && $_FILES['photo']['error'] === UPLOAD_ERR_OK) {
|
||||||
|
$file = $_FILES['photo'];
|
||||||
|
$timestamp = time();
|
||||||
|
$original_name = basename($file['name']);
|
||||||
|
$extension = strtolower(pathinfo($original_name, PATHINFO_EXTENSION));
|
||||||
|
$allowed_extensions = ['jpg', 'jpeg', 'png', 'gif'];
|
||||||
|
|
||||||
|
if (in_array($extension, $allowed_extensions)) {
|
||||||
|
$new_filename = "photoclass/{$school_id}-{$timestamp}-{$original_name}";
|
||||||
|
$temp_path = $file['tmp_name'];
|
||||||
|
try {
|
||||||
|
resizeImage($temp_path, $new_filename);
|
||||||
|
$photo = $new_filename;
|
||||||
|
if ($class['photo'] && file_exists($class['photo'])) {
|
||||||
|
unlink($class['photo']);
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$error = "Errore durante il ridimensionamento della foto: " . $e->getMessage();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$error = "Estensione del file non consentita. Usa JPG, JPEG, PNG o GIF.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($error)) {
|
||||||
|
$stmt = $pdo->prepare("
|
||||||
|
UPDATE class_types
|
||||||
|
SET class_category_id = ?, name = ?, description = ?, photo = ?, requirements = ?, level = ?,
|
||||||
|
typical_duration = ?, days_of_week = ?, start_time = ?, period_start = ?, period_end = ?, status = ?
|
||||||
|
WHERE id = ? AND school_id = ?
|
||||||
|
");
|
||||||
|
$success = $stmt->execute([
|
||||||
|
$class_category_id,
|
||||||
|
$name,
|
||||||
|
$description,
|
||||||
|
$photo,
|
||||||
|
$requirements,
|
||||||
|
$level,
|
||||||
|
$typical_duration,
|
||||||
|
$days_of_week,
|
||||||
|
$start_time,
|
||||||
|
$period_start,
|
||||||
|
$period_end,
|
||||||
|
$status,
|
||||||
|
$id,
|
||||||
|
$school_id
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($success) {
|
||||||
|
$success_message = "Classe aggiornata con successo!";
|
||||||
|
} else {
|
||||||
|
$error = "Errore durante l'aggiornamento della classe.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cancellazione di una classe
|
||||||
|
if ($action === 'delete') {
|
||||||
|
$id = $_POST['id'] ?? 0;
|
||||||
|
$stmt = $pdo->prepare("SELECT photo FROM class_types WHERE id = ? AND school_id = ?");
|
||||||
|
$stmt->execute([$id, $school_id]);
|
||||||
|
$class = $stmt->fetch();
|
||||||
|
if ($class) {
|
||||||
|
if ($class['photo'] && file_exists($class['photo'])) {
|
||||||
|
unlink($class['photo']);
|
||||||
|
}
|
||||||
|
$stmt = $pdo->prepare("DELETE FROM class_types WHERE id = ? AND school_id = ?");
|
||||||
|
$success = $stmt->execute([$id, $school_id]);
|
||||||
|
|
||||||
|
if ($success) {
|
||||||
|
$success_message = "Classe eliminata con successo!";
|
||||||
|
} else {
|
||||||
|
$error = "Errore durante l'eliminazione della classe.";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$error = "Classe non trovata.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reindirizza per evitare il doppio invio del form
|
||||||
|
header("Location: class_types.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recupera tutte le classi della scuola
|
||||||
|
$stmt = $pdo->prepare("
|
||||||
|
SELECT ct.*, cc.name AS category_name
|
||||||
|
FROM class_types ct
|
||||||
|
LEFT JOIN class_categories cc ON ct.class_category_id = cc.id
|
||||||
|
WHERE ct.school_id = ?
|
||||||
|
ORDER BY ct.created_at DESC
|
||||||
|
");
|
||||||
|
$stmt->execute([$school_id]);
|
||||||
|
$classes = $stmt->fetchAll();
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link rel="icon" href="assets/images/favicon-32x32.png" type="image/png" />
|
||||||
|
<?php include('cssinclude.php'); ?>
|
||||||
|
<?php include('siteinfo.php'); ?>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="wrapper">
|
||||||
|
<?php include('include/navbar.php'); ?>
|
||||||
|
<?php include('include/topbar.php'); ?>
|
||||||
|
<div class="page-wrapper">
|
||||||
|
<div class="page-content">
|
||||||
|
<div class="card radius-10">
|
||||||
|
<div class="card-header">
|
||||||
|
<div class="d-flex align-items-center">
|
||||||
|
<div>
|
||||||
|
<h6 class="mb-0">Classi della scuola: <?php echo htmlspecialchars($school_name); ?></h6>
|
||||||
|
</div>
|
||||||
|
<div class="ms-auto">
|
||||||
|
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addClassModal">
|
||||||
|
Aggiungi Classe
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<?php if (isset($success_message)): ?>
|
||||||
|
<div class="alert alert-success" role="alert">
|
||||||
|
<?php echo $success_message; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if (isset($error)): ?>
|
||||||
|
<div class="alert alert-danger" role="alert">
|
||||||
|
<?php echo $error; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table id="classesTable" class="table table-striped table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Categoria</th>
|
||||||
|
<th>Nome</th>
|
||||||
|
<th>Descrizione</th>
|
||||||
|
<th>Foto</th>
|
||||||
|
<th>Livello</th>
|
||||||
|
<th>Durata (min)</th>
|
||||||
|
<th>Giorni</th>
|
||||||
|
<th>Orario</th>
|
||||||
|
<th>Inizio</th>
|
||||||
|
<th>Fine</th>
|
||||||
|
<th>Stato</th>
|
||||||
|
<th>Data Creazione</th>
|
||||||
|
<th>Ultimo Aggiornamento</th>
|
||||||
|
<th>Azioni</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($classes as $class): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo htmlspecialchars($class['id']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($class['category_name']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($class['name']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($class['description'] ?? ''); ?></td>
|
||||||
|
<td>
|
||||||
|
<?php if ($class['photo']): ?>
|
||||||
|
<img src="<?php echo htmlspecialchars($class['photo']); ?>" alt="Foto Classe" style="max-width: 50px; max-height: 50px;">
|
||||||
|
<?php else: ?>
|
||||||
|
Nessuna foto
|
||||||
|
<?php endif; ?>
|
||||||
|
</td>
|
||||||
|
<td><?php echo htmlspecialchars($class['level']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($class['typical_duration'] ?? ''); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($class['days_of_week']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($class['start_time']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($class['period_start']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($class['period_end']); ?></td>
|
||||||
|
<td>
|
||||||
|
<span class="badge <?php echo $class['status'] === 'active' ? 'bg-success' : 'bg-danger'; ?>">
|
||||||
|
<?php echo $class['status'] === 'active' ? 'Attivo' : 'Inattivo'; ?>
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td><?php echo htmlspecialchars($class['created_at']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($class['updated_at']); ?></td>
|
||||||
|
<td>
|
||||||
|
<button type="button" class="btn btn-sm btn-warning" data-bs-toggle="modal" data-bs-target="#editClassModal"
|
||||||
|
onclick='fillEditModal(<?php echo json_encode([
|
||||||
|
"id" => $class['id'],
|
||||||
|
"class_category_id" => $class['class_category_id'],
|
||||||
|
"name" => htmlspecialchars($class['name'], ENT_QUOTES),
|
||||||
|
"description" => htmlspecialchars($class['description'] ?? '', ENT_QUOTES),
|
||||||
|
"requirements" => htmlspecialchars($class['requirements'] ?? '', ENT_QUOTES),
|
||||||
|
"level" => $class['level'],
|
||||||
|
"typical_duration" => $class['typical_duration'] ?? '',
|
||||||
|
"days_of_week" => htmlspecialchars($class['days_of_week'], ENT_QUOTES),
|
||||||
|
"start_time" => $class['start_time'],
|
||||||
|
"period_start" => $class['period_start'],
|
||||||
|
"period_end" => $class['period_end'],
|
||||||
|
"status" => $class['status']
|
||||||
|
]); ?>)'>
|
||||||
|
Modifica
|
||||||
|
</button>
|
||||||
|
<form action="" method="POST" style="display:inline;" onsubmit="return confirm('Sei sicuro di voler eliminare questa classe?');">
|
||||||
|
<input type="hidden" name="action" value="delete">
|
||||||
|
<input type="hidden" name="id" value="<?php echo $class['id']; ?>">
|
||||||
|
<button type="submit" class="btn btn-sm btn-danger">Elimina</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Modale per aggiungere una classe -->
|
||||||
|
<div class="modal fade" id="addClassModal" tabindex="-1" aria-labelledby="addClassModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-lg">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="addClassModalLabel">Aggiungi Classe</h5>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<form action="" method="POST" enctype="multipart/form-data">
|
||||||
|
<div class="modal-body">
|
||||||
|
<input type="hidden" name="action" value="add">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="add_class_category_id" class="form-label">Categoria</label>
|
||||||
|
<select class="form-control" id="add_class_category_id" name="class_category_id" required>
|
||||||
|
<option value="">Seleziona una categoria</option>
|
||||||
|
<?php foreach ($categories as $category): ?>
|
||||||
|
<option value="<?php echo $category['id']; ?>"><?php echo htmlspecialchars($category['name']); ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="add_name" class="form-label">Nome</label>
|
||||||
|
<input type="text" class="form-control" id="add_name" name="name" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="add_description" class="form-label">Descrizione</label>
|
||||||
|
<textarea class="form-control" id="add_description" name="description" rows="3"></textarea>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="add_photo" class="form-label">Foto</label>
|
||||||
|
<input type="file" class="form-control" id="add_photo" name="photo" accept="image/*">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="add_requirements" class="form-label">Requisiti</label>
|
||||||
|
<textarea class="form-control" id="add_requirements" name="requirements" rows="2"></textarea>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="add_level" class="form-label">Livello</label>
|
||||||
|
<select class="form-control" id="add_level" name="level" required>
|
||||||
|
<option value="beginner">Beginner</option>
|
||||||
|
<option value="intermediate">Intermediate</option>
|
||||||
|
<option value="advanced">Advanced</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="add_typical_duration" class="form-label">Durata Tipica (min)</label>
|
||||||
|
<input type="number" class="form-control" id="add_typical_duration" name="typical_duration">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="add_days_of_week" class="form-label">Giorni della Settimana</label>
|
||||||
|
<input type="text" class="form-control" id="add_days_of_week" name="days_of_week" placeholder="Es. Lun, Mer, Ven" required>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4 mb-3">
|
||||||
|
<label for="add_start_time" class="form-label">Orario di Inizio</label>
|
||||||
|
<input type="time" class="form-control" id="add_start_time" name="start_time" required>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4 mb-3">
|
||||||
|
<label for="add_period_start" class="form-label">Data Inizio</label>
|
||||||
|
<input type="date" class="form-control" id="add_period_start" name="period_start" required>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4 mb-3">
|
||||||
|
<label for="add_period_end" class="form-label">Data Fine</label>
|
||||||
|
<input type="date" class="form-control" id="add_period_end" name="period_end" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="add_status" class="form-label">Stato</label>
|
||||||
|
<div class="form-check form-switch">
|
||||||
|
<input class="form-check-input" type="checkbox" id="add_status" name="status" value="active" checked>
|
||||||
|
<label class="form-check-label" for="add_status">Attivo</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Chiudi</button>
|
||||||
|
<button type="submit" class="btn btn-primary">Aggiungi</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Modale per modificare una classe -->
|
||||||
|
<div class="modal fade" id="editClassModal" tabindex="-1" aria-labelledby="editClassModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-lg">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="editClassModalLabel">Modifica Classe</h5>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<form action="" method="POST" enctype="multipart/form-data">
|
||||||
|
<div class="modal-body">
|
||||||
|
<input type="hidden" name="action" value="edit">
|
||||||
|
<input type="hidden" name="id" id="edit_id">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="edit_class_category_id" class="form-label">Categoria</label>
|
||||||
|
<select class="form-control" id="edit_class_category_id" name="class_category_id" required>
|
||||||
|
<option value="">Seleziona una categoria</option>
|
||||||
|
<?php foreach ($categories as $category): ?>
|
||||||
|
<option value="<?php echo $category['id']; ?>"><?php echo htmlspecialchars($category['name']); ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="edit_name" class="form-label">Nome</label>
|
||||||
|
<input type="text" class="form-control" id="edit_name" name="name" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="edit_description" class="form-label">Descrizione</label>
|
||||||
|
<textarea class="form-control" id="edit_description" name="description" rows="3"></textarea>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="edit_photo" class="form-label">Foto</label>
|
||||||
|
<input type="file" class="form-control" id="edit_photo" name="photo" accept="image/*">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="edit_requirements" class="form-label">Requisiti</label>
|
||||||
|
<textarea class="form-control" id="edit_requirements" name="requirements" rows="2"></textarea>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="edit_level" class="form-label">Livello</label>
|
||||||
|
<select class="form-control" id="edit_level" name="level" required>
|
||||||
|
<option value="beginner">Beginner</option>
|
||||||
|
<option value="intermediate">Intermediate</option>
|
||||||
|
<option value="advanced">Advanced</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="edit_typical_duration" class="form-label">Durata Tipica (min)</label>
|
||||||
|
<input type="number" class="form-control" id="edit_typical_duration" name="typical_duration">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="edit_days_of_week" class="form-label">Giorni della Settimana</label>
|
||||||
|
<input type="text" class="form-control" id="edit_days_of_week" name="days_of_week" required>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4 mb-3">
|
||||||
|
<label for="edit_start_time" class="form-label">Orario di Inizio</label>
|
||||||
|
<input type="time" class="form-control" id="edit_start_time" name="start_time" required>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4 mb-3">
|
||||||
|
<label for="edit_period_start" class="form-label">Data Inizio</label>
|
||||||
|
<input type="date" class="form-control" id="edit_period_start" name="period_start" required>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4 mb-3">
|
||||||
|
<label for="edit_period_end" class="form-label">Data Fine</label>
|
||||||
|
<input type="date" class="form-control" id="edit_period_end" name="period_end" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="edit_status" class="form-label">Stato</label>
|
||||||
|
<div class="form-check form-switch">
|
||||||
|
<input class="form-check-input" type="checkbox" id="edit_status" name="status" value="active">
|
||||||
|
<label class="form-check-label" for="edit_status">Attivo</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Chiudi</button>
|
||||||
|
<button type="submit" class="btn btn-primary">Salva Modifiche</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="overlay toggle-icon"></div>
|
||||||
|
<a href="javaScript:;" class="back-to-top"><i class='bx bxs-up-arrow-alt'></i></a>
|
||||||
|
<?php include('include/footer.php'); ?>
|
||||||
|
</div>
|
||||||
|
<?php include('jsinclude.php'); ?>
|
||||||
|
|
||||||
|
<!-- Script per inizializzare DataTables e gestire il modale di modifica -->
|
||||||
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#classesTable').DataTable({
|
||||||
|
"language": {
|
||||||
|
"url": "//cdn.datatables.net/plug-ins/1.10.25/i18n/Italian.json"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function fillEditModal(data) {
|
||||||
|
document.getElementById('edit_id').value = data.id;
|
||||||
|
document.getElementById('edit_class_category_id').value = data.class_category_id;
|
||||||
|
document.getElementById('edit_name').value = data.name;
|
||||||
|
document.getElementById('edit_description').value = data.description;
|
||||||
|
document.getElementById('edit_requirements').value = data.requirements;
|
||||||
|
document.getElementById('edit_level').value = data.level;
|
||||||
|
document.getElementById('edit_typical_duration').value = data.typical_duration;
|
||||||
|
document.getElementById('edit_days_of_week').value = data.days_of_week;
|
||||||
|
document.getElementById('edit_start_time').value = data.start_time;
|
||||||
|
document.getElementById('edit_period_start').value = data.period_start;
|
||||||
|
document.getElementById('edit_period_end').value = data.period_end;
|
||||||
|
document.getElementById('edit_status').checked = (data.status === 'active');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@ -15,4 +15,6 @@
|
|||||||
<!-- Theme Style CSS -->
|
<!-- Theme Style CSS -->
|
||||||
<link rel="stylesheet" href="assets/css/dark-theme.css" />
|
<link rel="stylesheet" href="assets/css/dark-theme.css" />
|
||||||
<link rel="stylesheet" href="assets/css/semi-dark.css" />
|
<link rel="stylesheet" href="assets/css/semi-dark.css" />
|
||||||
<link rel="stylesheet" href="assets/css/header-colors.css" />
|
<link rel="stylesheet" href="assets/css/header-colors.css" />
|
||||||
|
<!-- Datatables -->
|
||||||
|
<link href="https://cdn.datatables.net/1.10.25/css/dataTables.bootstrap5.min.css" rel="stylesheet">
|
||||||
318
public/userarea/day_off.php
Normal file
@ -0,0 +1,318 @@
|
|||||||
|
<?php
|
||||||
|
// Forza la visualizzazione degli errori
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
ini_set('display_startup_errors', 1);
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
|
include('include/headscript.php');
|
||||||
|
|
||||||
|
// Connessione al database
|
||||||
|
$dbHandler = DBHandlerSelect::getInstance();
|
||||||
|
$pdo = $dbHandler->getConnection();
|
||||||
|
|
||||||
|
// Verifica che iduserlogin sia definito
|
||||||
|
if (!isset($iduserlogin)) {
|
||||||
|
die("Errore: ID utente non definito.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recupera i dati della scuola in base all'utente loggato
|
||||||
|
$stmt = $pdo->prepare("SELECT id, name FROM schools WHERE owner_id = ?");
|
||||||
|
$stmt->execute([$iduserlogin]);
|
||||||
|
$school = $stmt->fetch();
|
||||||
|
if (!$school) {
|
||||||
|
die("Errore: Nessuna scuola trovata per l'utente loggato.");
|
||||||
|
}
|
||||||
|
$school_id = $school['id'];
|
||||||
|
$school_name = $school['name'];
|
||||||
|
|
||||||
|
// Gestione delle azioni (aggiunta, modifica, cancellazione)
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
if (isset($_POST['action'])) {
|
||||||
|
$action = $_POST['action'];
|
||||||
|
|
||||||
|
// Aggiunta di un giorno di chiusura
|
||||||
|
if ($action === 'add') {
|
||||||
|
$start_date = $_POST['start_date'] ?? '';
|
||||||
|
$end_date = $_POST['end_date'] ?? '';
|
||||||
|
$description = $_POST['description'] ?? null;
|
||||||
|
|
||||||
|
// Validazione: assicurarsi che end_date >= start_date
|
||||||
|
if (empty($start_date) || empty($end_date)) {
|
||||||
|
$error = "Le date di inizio e fine sono obbligatorie.";
|
||||||
|
} elseif (strtotime($end_date) < strtotime($start_date)) {
|
||||||
|
$error = "La data di fine non può essere precedente alla data di inizio.";
|
||||||
|
} else {
|
||||||
|
$stmt = $pdo->prepare("
|
||||||
|
INSERT INTO day_off (school_id, start_date, end_date, description)
|
||||||
|
VALUES (?, ?, ?, ?)
|
||||||
|
");
|
||||||
|
$success = $stmt->execute([
|
||||||
|
$school_id,
|
||||||
|
$start_date,
|
||||||
|
$end_date,
|
||||||
|
$description
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($success) {
|
||||||
|
$success_message = "Giorno di chiusura aggiunto con successo!";
|
||||||
|
} else {
|
||||||
|
$error = "Errore durante l'aggiunta del giorno di chiusura.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Modifica di un giorno di chiusura
|
||||||
|
if ($action === 'edit') {
|
||||||
|
$id = $_POST['id'] ?? 0;
|
||||||
|
$start_date = $_POST['start_date'] ?? '';
|
||||||
|
$end_date = $_POST['end_date'] ?? '';
|
||||||
|
$description = $_POST['description'] ?? null;
|
||||||
|
|
||||||
|
// Validazione: assicurarsi che end_date >= start_date
|
||||||
|
if (empty($start_date) || empty($end_date)) {
|
||||||
|
$error = "Le date di inizio e fine sono obbligatorie.";
|
||||||
|
} elseif (strtotime($end_date) < strtotime($start_date)) {
|
||||||
|
$error = "La data di fine non può essere precedente alla data di inizio.";
|
||||||
|
} else {
|
||||||
|
$stmt = $pdo->prepare("
|
||||||
|
UPDATE day_off
|
||||||
|
SET start_date = ?, end_date = ?, description = ?
|
||||||
|
WHERE id = ? AND school_id = ?
|
||||||
|
");
|
||||||
|
$success = $stmt->execute([
|
||||||
|
$start_date,
|
||||||
|
$end_date,
|
||||||
|
$description,
|
||||||
|
$id,
|
||||||
|
$school_id
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($success) {
|
||||||
|
$success_message = "Giorno di chiusura aggiornato con successo!";
|
||||||
|
} else {
|
||||||
|
$error = "Errore durante l'aggiornamento del giorno di chiusura.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cancellazione di un giorno di chiusura
|
||||||
|
if ($action === 'delete') {
|
||||||
|
$id = $_POST['id'] ?? 0;
|
||||||
|
$stmt = $pdo->prepare("DELETE FROM day_off WHERE id = ? AND school_id = ?");
|
||||||
|
$success = $stmt->execute([$id, $school_id]);
|
||||||
|
|
||||||
|
if ($success) {
|
||||||
|
$success_message = "Giorno di chiusura eliminato con successo!";
|
||||||
|
} else {
|
||||||
|
$error = "Errore durante l'eliminazione del giorno di chiusura.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reindirizza per evitare il doppio invio del form
|
||||||
|
header("Location: day_off.php");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recupera tutti i giorni di chiusura della scuola
|
||||||
|
$stmt = $pdo->prepare("
|
||||||
|
SELECT *
|
||||||
|
FROM day_off
|
||||||
|
WHERE school_id = ?
|
||||||
|
ORDER BY start_date
|
||||||
|
");
|
||||||
|
$stmt->execute([$school_id]);
|
||||||
|
$days_off = $stmt->fetchAll();
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<!-- Required meta tags -->
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<!--favicon-->
|
||||||
|
<link rel="icon" href="assets/images/favicon-32x32.png" type="image/png" />
|
||||||
|
<?php include('cssinclude.php'); ?>
|
||||||
|
<?php include('siteinfo.php'); ?>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<!--wrapper-->
|
||||||
|
<div class="wrapper">
|
||||||
|
<!--sidebar wrapper -->
|
||||||
|
<?php include('include/navbar.php'); ?>
|
||||||
|
<!--end sidebar wrapper -->
|
||||||
|
<!--start header -->
|
||||||
|
<?php include('include/topbar.php'); ?>
|
||||||
|
<!--end header -->
|
||||||
|
<!--start page wrapper -->
|
||||||
|
<div class="page-wrapper">
|
||||||
|
<div class="page-content">
|
||||||
|
<div class="card radius-10">
|
||||||
|
<div class="card-header">
|
||||||
|
<div class="d-flex align-items-center">
|
||||||
|
<div>
|
||||||
|
<h6 class="mb-0">Giorni di Chiusura - <?php echo htmlspecialchars($school_name); ?></h6>
|
||||||
|
</div>
|
||||||
|
<div class="ms-auto">
|
||||||
|
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addDayOffModal">
|
||||||
|
Aggiungi Giorno di Chiusura
|
||||||
|
</button>
|
||||||
|
<a href="school_dashboard.php" class="btn btn-secondary ms-2">Torna alla Dashboard</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<?php if (isset($success_message)): ?>
|
||||||
|
<div class="alert alert-success" role="alert">
|
||||||
|
<?php echo $success_message; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if (isset($error)): ?>
|
||||||
|
<div class="alert alert-danger" role="alert">
|
||||||
|
<?php echo $error; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table id="daysOffTable" class="table table-striped table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Data Inizio</th>
|
||||||
|
<th>Data Fine</th>
|
||||||
|
<th>Descrizione</th>
|
||||||
|
<th>Azioni</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($days_off as $day_off): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo htmlspecialchars($day_off['start_date']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($day_off['end_date']); ?></td>
|
||||||
|
<td><?php echo htmlspecialchars($day_off['description'] ?? ''); ?></td>
|
||||||
|
<td>
|
||||||
|
<button type="button" class="btn btn-sm btn-warning" data-bs-toggle="modal" data-bs-target="#editDayOffModal"
|
||||||
|
onclick='fillEditDayOffModal(<?php echo json_encode([
|
||||||
|
"id" => $day_off['id'],
|
||||||
|
"start_date" => $day_off['start_date'],
|
||||||
|
"end_date" => $day_off['end_date'],
|
||||||
|
"description" => htmlspecialchars($day_off['description'] ?? '', ENT_QUOTES)
|
||||||
|
]); ?>)'>
|
||||||
|
Modifica
|
||||||
|
</button>
|
||||||
|
<form action="" method="POST" style="display:inline;" onsubmit="return confirm('Sei sicuro di voler eliminare questo giorno di chiusura?');">
|
||||||
|
<input type="hidden" name="action" value="delete">
|
||||||
|
<input type="hidden" name="id" value="<?php echo $day_off['id']; ?>">
|
||||||
|
<button type="submit" class="btn btn-sm btn-danger">Elimina</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--end page wrapper -->
|
||||||
|
<!--start overlay-->
|
||||||
|
<div class="overlay toggle-icon"></div>
|
||||||
|
<!--end overlay-->
|
||||||
|
<!--Start Back To Top Button-->
|
||||||
|
<a href="javaScript:;" class="back-to-top"><i class='bx bxs-up-arrow-alt'></i></a>
|
||||||
|
<!--End Back To Top Button-->
|
||||||
|
<?php include('include/footer.php'); ?>
|
||||||
|
</div>
|
||||||
|
<!--end wrapper-->
|
||||||
|
|
||||||
|
<!-- Modale per aggiungere un giorno di chiusura -->
|
||||||
|
<div class="modal fade" id="addDayOffModal" tabindex="-1" aria-labelledby="addDayOffModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="addDayOffModalLabel">Aggiungi Giorno di Chiusura</h5>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<form action="" method="POST">
|
||||||
|
<div class="modal-body">
|
||||||
|
<input type="hidden" name="action" value="add">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="add_day_off_start_date" class="form-label">Data Inizio</label>
|
||||||
|
<input type="date" class="form-control" id="add_day_off_start_date" name="start_date" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="add_day_off_end_date" class="form-label">Data Fine</label>
|
||||||
|
<input type="date" class="form-control" id="add_day_off_end_date" name="end_date" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="add_day_off_description" class="form-label">Descrizione</label>
|
||||||
|
<input type="text" class="form-control" id="add_day_off_description" name="description" placeholder="Es. Natale">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Chiudi</button>
|
||||||
|
<button type="submit" class="btn btn-primary">Aggiungi</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Modale per modificare un giorno di chiusura -->
|
||||||
|
<div class="modal fade" id="editDayOffModal" tabindex="-1" aria-labelledby="editDayOffModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="editDayOffModalLabel">Modifica Giorno di Chiusura</h5>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<form action="" method="POST">
|
||||||
|
<div class="modal-body">
|
||||||
|
<input type="hidden" name="action" value="edit">
|
||||||
|
<input type="hidden" name="id" id="edit_day_off_id">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="edit_day_off_start_date" class="form-label">Data Inizio</label>
|
||||||
|
<input type="date" class="form-control" id="edit_day_off_start_date" name="start_date" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="edit_day_off_end_date" class="form-label">Data Fine</label>
|
||||||
|
<input type="date" class="form-control" id="edit_day_off_end_date" name="end_date" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="edit_day_off_description" class="form-label">Descrizione</label>
|
||||||
|
<input type="text" class="form-control" id="edit_day_off_description" name="description" placeholder="Es. Natale">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Chiudi</button>
|
||||||
|
<button type="submit" class="btn btn-primary">Salva Modifiche</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php include('jsinclude.php'); ?>
|
||||||
|
|
||||||
|
<!-- Script per inizializzare DataTables e gestire i modali -->
|
||||||
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#daysOffTable').DataTable({
|
||||||
|
"language": {
|
||||||
|
"url": "//cdn.datatables.net/plug-ins/1.10.25/i18n/Italian.json"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function fillEditDayOffModal(data) {
|
||||||
|
document.getElementById('edit_day_off_id').value = data.id;
|
||||||
|
document.getElementById('edit_day_off_start_date').value = data.start_date;
|
||||||
|
document.getElementById('edit_day_off_end_date').value = data.end_date;
|
||||||
|
document.getElementById('edit_day_off_description').value = data.description;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
60
public/userarea/include/headscript.php
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
require_once(__DIR__ . '/../class/db-functions.php');
|
||||||
|
|
||||||
|
$db = DBHandlerSelect::getInstance()->getConnection();
|
||||||
|
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
ini_set('display_startup_errors', 1);
|
||||||
|
error_reporting(E_ALL | E_STRICT);
|
||||||
|
// This should be equal to: PATH_TO_VANGUARD_FOLDER/extra/auth.php
|
||||||
|
include('../../extra/auth.php');
|
||||||
|
//require_once __DIR__ . '/extra/auth.php';
|
||||||
|
|
||||||
|
// Here we just check if user is not
|
||||||
|
// logged in, and in that case we redirect
|
||||||
|
// the user to vanguard login page.
|
||||||
|
|
||||||
|
if (! Auth::check()) {
|
||||||
|
|
||||||
|
redirectTo('../../public/login');
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = Auth::user();
|
||||||
|
|
||||||
|
$iduserlogin = $user->present()->id;
|
||||||
|
$nameuser = $user->present()->first_name;
|
||||||
|
$surnameuser = $user->present()->last_name;
|
||||||
|
$emailuser = $user->present()->email;
|
||||||
|
$avatar = $user->present()->avatar;
|
||||||
|
|
||||||
|
$kindofrole = $user->present()->role_id;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//$user = "1";
|
||||||
|
//$iduserlogin="1";
|
||||||
|
//$nameuser="Claudio";
|
||||||
|
//$emailuser="info@claudiosironi.com";
|
||||||
|
?>
|
||||||
|
<?php
|
||||||
|
if (session_status() == PHP_SESSION_NONE) {
|
||||||
|
session_start();
|
||||||
|
}
|
||||||
|
|
||||||
|
$_SESSION["iduserlogin"] = $iduserlogin;
|
||||||
|
$iduserlog = $_SESSION["iduserlogin"];
|
||||||
|
$_SESSION["nameuser"] = $nameuser;
|
||||||
|
$_SESSION["surnameuser"] = $surnameuser;
|
||||||
|
$_SESSION["emailuser"] = $emailuser;
|
||||||
|
$_SESSION["photouser"] = $avatar;
|
||||||
|
$photouser = $_SESSION["photouser"];
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
<?php //include files
|
||||||
|
|
||||||
|
//require_once(__DIR__ . '/../../languages/en/general.php');
|
||||||
|
|
||||||
|
//include("generalsettings.php");
|
||||||
|
|
||||||
|
?>
|
||||||
@ -4,7 +4,7 @@
|
|||||||
<img src="assets/images/logo-icon.png" class="logo-icon" alt="logo icon">
|
<img src="assets/images/logo-icon.png" class="logo-icon" alt="logo icon">
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h4 class="logo-text">Rocker</h4>
|
<h4 class="logo-text">YogiBoook</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="toggle-icon ms-auto"><i class='bx bx-arrow-back'></i>
|
<div class="toggle-icon ms-auto"><i class='bx bx-arrow-back'></i>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -65,28 +65,57 @@
|
|||||||
<div class="header-colors-indigators">
|
<div class="header-colors-indigators">
|
||||||
<div class="row row-cols-auto g-3">
|
<div class="row row-cols-auto g-3">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="indigator sidebarcolor1" id="sidebarcolor1"></div>
|
<div class="indigator headercolor1" id="headercolor1"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="indigator sidebarcolor2" id="sidebarcolor2"></div>
|
<div class="indigator headercolor2" id="headercolor2"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="indigator sidebarcolor3" id="sidebarcolor3"></div>
|
<div class="indigator headercolor3" id="headercolor3"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="indigator sidebarcolor4" id="sidebarcolor4"></div>
|
<div class="indigator headercolor4" id="headercolor4"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="indigator sidebarcolor5" id="sidebarcolor5"></div>
|
<div class="indigator headercolor5" id="headercolor5"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="indigator sidebarcolor6" id="sidebarcolor6"></div>
|
<div class="indigator headercolor6" id="headercolor6"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="indigator sidebarcolor7" id="sidebarcolor7"></div>
|
<div class="indigator headercolor7" id="headercolor7"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="indigator sidebarcolor8" id="sidebarcolor8"></div>
|
<div class="indigator headercolor8" id="headercolor8"></div>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<div class="indigator headercolor9" id="headercolor9"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr />
|
||||||
|
<h6 class="mb-0">Custom Colors</h6>
|
||||||
|
<hr />
|
||||||
|
<h6 class="mb-0">Custom Header Colors</h6>
|
||||||
|
<div class="custom-colors-indigators">
|
||||||
|
<div class="row row-cols-auto g-3">
|
||||||
|
<div class="col">
|
||||||
|
<div class="indigator customheadercolor1" id="customheadercolor1"></div>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<div class="indigator customheadercolor2" id="customheadercolor2"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr />
|
||||||
|
<h6 class="mb-0">Custom Sidebar Colors</h6>
|
||||||
|
<div class="custom-colors-indigators">
|
||||||
|
<div class="row row-cols-auto g-3">
|
||||||
|
<div class="col">
|
||||||
|
<div class="indigator customsidebarcolor1" id="customsidebarcolor1"></div>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<div class="indigator customsidebarcolor2" id="customsidebarcolor2"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -583,28 +583,22 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="user-box dropdown px-3">
|
<div class="user-box dropdown px-3">
|
||||||
<a class="d-flex align-items-center nav-link dropdown-toggle gap-3 dropdown-toggle-nocaret" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
<a class="d-flex align-items-center nav-link dropdown-toggle gap-3 dropdown-toggle-nocaret" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||||
<img src="assets/images/avatars/avatar-2.png" class="user-img" alt="user avatar">
|
<img src="<?php echo htmlspecialchars('../upload/users/' . basename($_SESSION['photouser'])); ?>" class="user-img" alt="user avatar">
|
||||||
<div class="user-info">
|
<div class="user-info">
|
||||||
<p class="user-name mb-0">Pauline Seitz</p>
|
<p class="user-name mb-0"><?php echo htmlspecialchars($_SESSION['nameuser'] . ' ' . $_SESSION['surnameuser']); ?></p>
|
||||||
<p class="designattion mb-0">Web Designer</p>
|
<p class="designattion mb-0"><?php echo htmlspecialchars($_SESSION['emailuser']); ?></p>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu dropdown-menu-end">
|
<ul class="dropdown-menu dropdown-menu-end">
|
||||||
<li><a class="dropdown-item d-flex align-items-center" href="javascript:;"><i class="bx bx-user fs-5"></i><span>Profile</span></a>
|
<li><a class="dropdown-item d-flex align-items-center" href="javascript:;"><i class="bx bx-user fs-5"></i><span>Profile</span></a></li>
|
||||||
</li>
|
<li><a class="dropdown-item d-flex align-items-center" href="javascript:;"><i class="bx bx-cog fs-5"></i><span>Settings</span></a></li>
|
||||||
<li><a class="dropdown-item d-flex align-items-center" href="javascript:;"><i class="bx bx-cog fs-5"></i><span>Settings</span></a>
|
<li><a class="dropdown-item d-flex align-items-center" href="javascript:;"><i class="bx bx-home-circle fs-5"></i><span>Dashboard</span></a></li>
|
||||||
</li>
|
<li><a class="dropdown-item d-flex align-items-center" href="javascript:;"><i class="bx bx-dollar-circle fs-5"></i><span>Earnings</span></a></li>
|
||||||
<li><a class="dropdown-item d-flex align-items-center" href="javascript:;"><i class="bx bx-home-circle fs-5"></i><span>Dashboard</span></a>
|
<li><a class="dropdown-item d-flex align-items-center" href="javascript:;"><i class="bx bx-download fs-5"></i><span>Downloads</span></a></li>
|
||||||
</li>
|
|
||||||
<li><a class="dropdown-item d-flex align-items-center" href="javascript:;"><i class="bx bx-dollar-circle fs-5"></i><span>Earnings</span></a>
|
|
||||||
</li>
|
|
||||||
<li><a class="dropdown-item d-flex align-items-center" href="javascript:;"><i class="bx bx-download fs-5"></i><span>Downloads</span></a>
|
|
||||||
</li>
|
|
||||||
<li>
|
<li>
|
||||||
<div class="dropdown-divider mb-0"></div>
|
<div class="dropdown-divider mb-0"></div>
|
||||||
</li>
|
</li>
|
||||||
<li><a class="dropdown-item d-flex align-items-center" href="javascript:;"><i class="bx bx-log-out-circle"></i><span>Logout</span></a>
|
<li><a class="dropdown-item d-flex align-items-center" href="javascript:;"><i class="bx bx-log-out-circle"></i><span>Logout</span></a></li>
|
||||||
</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
<?php include('include/headscript.php'); ?>
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
|
|||||||
2
public/userarea/info.php
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<?php
|
||||||
|
phpinfo();
|
||||||
@ -8,6 +8,8 @@
|
|||||||
<script src="assets/plugins/vectormap/jquery-jvectormap-2.0.2.min.js"></script>
|
<script src="assets/plugins/vectormap/jquery-jvectormap-2.0.2.min.js"></script>
|
||||||
<script src="assets/plugins/vectormap/jquery-jvectormap-world-mill-en.js"></script>
|
<script src="assets/plugins/vectormap/jquery-jvectormap-world-mill-en.js"></script>
|
||||||
<script src="assets/plugins/chartjs/js/chart.js"></script>
|
<script src="assets/plugins/chartjs/js/chart.js"></script>
|
||||||
|
<script src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js"></script>
|
||||||
|
<script src="https://cdn.datatables.net/1.10.25/js/dataTables.bootstrap5.min.js"></script>
|
||||||
<!-- <script src="assets/js/index.js"></script> -->
|
<!-- <script src="assets/js/index.js"></script> -->
|
||||||
<!--app JS-->
|
<!--app JS-->
|
||||||
<script src="assets/js/app.js"></script>
|
<script src="assets/js/app.js"></script>
|
||||||
|
|||||||
|
After Width: | Height: | Size: 110 KiB |
|
After Width: | Height: | Size: 35 KiB |
BIN
public/userarea/photoschool/ndphoto.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 242 KiB |
BIN
public/userarea/phototeachers/ndphoto.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
public/userarea/phototeachers/qrcodes/2-df968f3ff71def10.png
Normal file
|
After Width: | Height: | Size: 352 B |
22
public/userarea/qr.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||||
|
|
||||||
|
use Endroid\QrCode\Builder\Builder;
|
||||||
|
use Endroid\QrCode\Writer\PngWriter;
|
||||||
|
|
||||||
|
try {
|
||||||
|
$builder = new Builder();
|
||||||
|
$result = $builder->build(
|
||||||
|
writer: new PngWriter(),
|
||||||
|
data: 'Test QR Code', // Sostituisci con il testo o URL che vuoi
|
||||||
|
size: 150,
|
||||||
|
margin: 10
|
||||||
|
);
|
||||||
|
|
||||||
|
$qr_code_filename = __DIR__ . '/test-qr.png';
|
||||||
|
$result->saveToFile($qr_code_filename);
|
||||||
|
|
||||||
|
echo "QR Code generato con successo! Controlla il file: $qr_code_filename";
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo "Errore: " . $e->getMessage();
|
||||||
|
}
|
||||||
3
public/userarea/qr_debug.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
1 - Entrato nel blocco try
|
||||||
|
2 - Codice unico: df968f3ff71def10
|
||||||
|
3 - QR non esiste, lo creo
|
||||||
1008
public/userarea/school_dashboard.php
Normal file
332
public/userarea/school_profile.php
Normal file
@ -0,0 +1,332 @@
|
|||||||
|
<?php
|
||||||
|
// Forza la visualizzazione degli errori
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
ini_set('display_startup_errors', 1);
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
|
include('include/headscript.php');
|
||||||
|
|
||||||
|
// Connessione al database
|
||||||
|
$dbHandler = DBHandlerSelect::getInstance();
|
||||||
|
$pdo = $dbHandler->getConnection();
|
||||||
|
|
||||||
|
// ID dell'utente loggato (assumiamo sia definito)
|
||||||
|
if (!isset($iduserlogin)) {
|
||||||
|
die("Errore: ID utente non definito.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recupera i dati della scuola associata all'utente
|
||||||
|
$stmt = $pdo->prepare("
|
||||||
|
SELECT s.*, u.first_name, u.last_name, u.email
|
||||||
|
FROM auth_users u
|
||||||
|
LEFT JOIN schools s ON s.owner_id = u.id
|
||||||
|
WHERE u.id = ?
|
||||||
|
");
|
||||||
|
$stmt->execute([$iduserlogin]);
|
||||||
|
$school = $stmt->fetch();
|
||||||
|
|
||||||
|
if (!$school) {
|
||||||
|
die("Errore: Utente non trovato.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determina se è una nuova scuola
|
||||||
|
$is_new = !isset($school['id']);
|
||||||
|
if ($is_new) {
|
||||||
|
$school = [
|
||||||
|
'id' => null,
|
||||||
|
'owner_id' => $iduserlogin,
|
||||||
|
'name' => '',
|
||||||
|
'website' => '',
|
||||||
|
'email' => '',
|
||||||
|
'phone' => '',
|
||||||
|
'description' => '',
|
||||||
|
'address_street' => '',
|
||||||
|
'address_city' => '',
|
||||||
|
'address_postal_code' => '',
|
||||||
|
'address_province' => '',
|
||||||
|
'address_country' => '',
|
||||||
|
'latitude' => '',
|
||||||
|
'longitude' => '',
|
||||||
|
'owner_name' => '',
|
||||||
|
'vat_number' => '',
|
||||||
|
'logo' => '',
|
||||||
|
'status' => 'active',
|
||||||
|
'created_at' => '',
|
||||||
|
'updated_at' => '',
|
||||||
|
'first_name' => $school['first_name'],
|
||||||
|
'last_name' => $school['last_name'],
|
||||||
|
'email' => $school['email']
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gestione del form
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
$name = $_POST['name'] ?? '';
|
||||||
|
$website = $_POST['website'] ?? null;
|
||||||
|
$email = $_POST['email'] ?? '';
|
||||||
|
$phone = $_POST['phone'] ?? null;
|
||||||
|
$description = $_POST['description'] ?? null;
|
||||||
|
$address_street = $_POST['address_street'] ?? '';
|
||||||
|
$address_city = $_POST['address_city'] ?? '';
|
||||||
|
$address_postal_code = $_POST['address_postal_code'] ?? '';
|
||||||
|
$address_province = $_POST['address_province'] ?? null;
|
||||||
|
$address_country = $_POST['address_country'] ?? '';
|
||||||
|
$latitude = $_POST['latitude'] ? floatval($_POST['latitude']) : null;
|
||||||
|
$longitude = $_POST['longitude'] ? floatval($_POST['longitude']) : null;
|
||||||
|
$owner_name = $_POST['owner_name'] ?? '';
|
||||||
|
$vat_number = $_POST['vat_number'] ?? '';
|
||||||
|
$status = in_array($_POST['status'], ['active', 'inactive', 'suspended']) ? $_POST['status'] : 'active';
|
||||||
|
|
||||||
|
// Gestione del caricamento del logo
|
||||||
|
$logo = $school['logo'];
|
||||||
|
if (isset($_FILES['logo']) && $_FILES['logo']['error'] === UPLOAD_ERR_OK) {
|
||||||
|
$file = $_FILES['logo'];
|
||||||
|
$timestamp = time();
|
||||||
|
$original_name = basename($file['name']);
|
||||||
|
$extension = strtolower(pathinfo($original_name, PATHINFO_EXTENSION));
|
||||||
|
$allowed_extensions = ['jpg', 'jpeg', 'png', 'gif'];
|
||||||
|
|
||||||
|
if (in_array($extension, $allowed_extensions)) {
|
||||||
|
$new_filename = "photoschool/{$iduserlogin}-{$timestamp}-{$original_name}";
|
||||||
|
if (move_uploaded_file($file['tmp_name'], $new_filename)) {
|
||||||
|
$logo = $new_filename;
|
||||||
|
if ($school['logo'] && file_exists($school['logo']) && !$is_new) {
|
||||||
|
unlink($school['logo']);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$error = "Errore durante il caricamento del logo.";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$error = "Estensione del file non consentita. Usa JPG, JPEG, PNG o GIF.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggiorna auth_users (opzionale, se vuoi aggiornare first_name e last_name)
|
||||||
|
$stmt = $pdo->prepare("UPDATE auth_users SET first_name = ?, last_name = ? WHERE id = ?");
|
||||||
|
$stmt->execute([$school['first_name'], $school['last_name'], $iduserlogin]);
|
||||||
|
|
||||||
|
if ($is_new) {
|
||||||
|
$stmt = $pdo->prepare("
|
||||||
|
INSERT INTO schools (owner_id, name, website, email, phone, description, address_street, address_city, address_postal_code, address_province, address_country, latitude, longitude, owner_name, vat_number, logo, status)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
|
");
|
||||||
|
$success = $stmt->execute([
|
||||||
|
$iduserlogin,
|
||||||
|
$name,
|
||||||
|
$website,
|
||||||
|
$email,
|
||||||
|
$phone,
|
||||||
|
$description,
|
||||||
|
$address_street,
|
||||||
|
$address_city,
|
||||||
|
$address_postal_code,
|
||||||
|
$address_province,
|
||||||
|
$address_country,
|
||||||
|
$latitude,
|
||||||
|
$longitude,
|
||||||
|
$owner_name,
|
||||||
|
$vat_number,
|
||||||
|
$logo,
|
||||||
|
$status
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($success) {
|
||||||
|
$success_message = "Scuola creata con successo!";
|
||||||
|
$stmt = $pdo->prepare("
|
||||||
|
SELECT s.*, u.first_name, u.last_name, u.email
|
||||||
|
FROM auth_users u
|
||||||
|
LEFT JOIN schools s ON s.owner_id = u.id
|
||||||
|
WHERE u.id = ?
|
||||||
|
");
|
||||||
|
$stmt->execute([$iduserlogin]);
|
||||||
|
$school = $stmt->fetch();
|
||||||
|
$is_new = false;
|
||||||
|
} else {
|
||||||
|
$error = "Errore durante la creazione della scuola.";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$stmt = $pdo->prepare("
|
||||||
|
UPDATE schools
|
||||||
|
SET name = ?, website = ?, email = ?, phone = ?, description = ?, address_street = ?, address_city = ?,
|
||||||
|
address_postal_code = ?, address_province = ?, address_country = ?, latitude = ?, longitude = ?,
|
||||||
|
owner_name = ?, vat_number = ?, logo = ?, status = ?
|
||||||
|
WHERE owner_id = ?
|
||||||
|
");
|
||||||
|
$success = $stmt->execute([
|
||||||
|
$name,
|
||||||
|
$website,
|
||||||
|
$email,
|
||||||
|
$phone,
|
||||||
|
$description,
|
||||||
|
$address_street,
|
||||||
|
$address_city,
|
||||||
|
$address_postal_code,
|
||||||
|
$address_province,
|
||||||
|
$address_country,
|
||||||
|
$latitude,
|
||||||
|
$longitude,
|
||||||
|
$owner_name,
|
||||||
|
$vat_number,
|
||||||
|
$logo,
|
||||||
|
$status,
|
||||||
|
$iduserlogin
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($success) {
|
||||||
|
$success_message = "Dati aggiornati con successo!";
|
||||||
|
$stmt = $pdo->prepare("
|
||||||
|
SELECT s.*, u.first_name, u.last_name, u.email
|
||||||
|
FROM auth_users u
|
||||||
|
LEFT JOIN schools s ON s.owner_id = u.id
|
||||||
|
WHERE u.id = ?
|
||||||
|
");
|
||||||
|
$stmt->execute([$iduserlogin]);
|
||||||
|
$school = $stmt->fetch();
|
||||||
|
} else {
|
||||||
|
$error = "Errore durante l'aggiornamento dei dati.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link rel="icon" href="assets/images/favicon-32x32.png" type="image/png" />
|
||||||
|
<?php include('cssinclude.php'); ?>
|
||||||
|
<?php include('siteinfo.php'); ?>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="wrapper">
|
||||||
|
<?php include('include/navbar.php'); ?>
|
||||||
|
<?php include('include/topbar.php'); ?>
|
||||||
|
<div class="page-wrapper">
|
||||||
|
<div class="page-content">
|
||||||
|
<div class="card radius-10">
|
||||||
|
<div class="card-header">
|
||||||
|
<h6 class="mb-0"><?php echo $is_new ? 'Crea Profilo Scuola' : 'Profilo Scuola'; ?></h6>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<?php if (isset($success_message)): ?>
|
||||||
|
<div class="alert alert-success" role="alert">
|
||||||
|
<?php echo $success_message; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if (isset($error)): ?>
|
||||||
|
<div class="alert alert-danger" role="alert">
|
||||||
|
<?php echo $error; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<form method="POST" enctype="multipart/form-data">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4 text-center">
|
||||||
|
<div class="mb-3">
|
||||||
|
<img src="<?php echo $school['logo'] ? htmlspecialchars($school['logo']) : 'photoschool/ndphoto.png'; ?>"
|
||||||
|
alt="Logo Scuola" class="img-fluid rounded-circle" style="width: 150px; height: 150px; object-fit: cover;">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="logo" class="form-label">Carica nuovo logo</label>
|
||||||
|
<input type="file" class="form-control" id="logo" name="logo" accept="image/*">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-8">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="name" class="form-label">Nome Scuola</label>
|
||||||
|
<input type="text" class="form-control" id="name" name="name" value="<?php echo htmlspecialchars($school['name'] ?? ''); ?>" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="website" class="form-label">Sito Web</label>
|
||||||
|
<input type="url" class="form-control" id="website" name="website" value="<?php echo htmlspecialchars($school['website'] ?? ''); ?>">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="email" class="form-label">Email Scuola</label>
|
||||||
|
<input type="email" class="form-control" id="email" name="email" value="<?php echo htmlspecialchars($school['email'] ?? ''); ?>" required>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="phone" class="form-label">Telefono</label>
|
||||||
|
<input type="text" class="form-control" id="phone" name="phone" value="<?php echo htmlspecialchars($school['phone'] ?? ''); ?>">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="description" class="form-label">Descrizione</label>
|
||||||
|
<textarea class="form-control" id="description" name="description" rows="3"><?php echo htmlspecialchars($school['description'] ?? ''); ?></textarea>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="address_street" class="form-label">Via</label>
|
||||||
|
<input type="text" class="form-control" id="address_street" name="address_street" value="<?php echo htmlspecialchars($school['address_street'] ?? ''); ?>">
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="address_city" class="form-label">Città</label>
|
||||||
|
<input type="text" class="form-control" id="address_city" name="address_city" value="<?php echo htmlspecialchars($school['address_city'] ?? ''); ?>">
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="address_postal_code" class="form-label">CAP</label>
|
||||||
|
<input type="text" class="form-control" id="address_postal_code" name="address_postal_code" value="<?php echo htmlspecialchars($school['address_postal_code'] ?? ''); ?>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="address_province" class="form-label">Provincia</label>
|
||||||
|
<input type="text" class="form-control" id="address_province" name="address_province" value="<?php echo htmlspecialchars($school['address_province'] ?? ''); ?>">
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="address_country" class="form-label">Nazione</label>
|
||||||
|
<input type="text" class="form-control" id="address_country" name="address_country" value="<?php echo htmlspecialchars($school['address_country'] ?? ''); ?>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="latitude" class="form-label">Latitudine</label>
|
||||||
|
<input type="number" step="any" class="form-control" id="latitude" name="latitude" value="<?php echo htmlspecialchars($school['latitude'] ?? ''); ?>">
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="longitude" class="form-label">Longitudine</label>
|
||||||
|
<input type="number" step="any" class="form-control" id="longitude" name="longitude" value="<?php echo htmlspecialchars($school['longitude'] ?? ''); ?>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="owner_name" class="form-label">Nome Proprietario</label>
|
||||||
|
<input type="text" class="form-control" id="owner_name" name="owner_name" value="<?php echo htmlspecialchars($school['owner_name'] ?? ''); ?>">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="vat_number" class="form-label">Partita IVA</label>
|
||||||
|
<input type="text" class="form-control" id="vat_number" name="vat_number" value="<?php echo htmlspecialchars($school['vat_number'] ?? ''); ?>">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="status" class="form-label">Stato</label>
|
||||||
|
<select class="form-control" id="status" name="status">
|
||||||
|
<option value="active" <?php echo $school['status'] === 'active' ? 'selected' : ''; ?>>Attivo</option>
|
||||||
|
<option value="inactive" <?php echo $school['status'] === 'inactive' ? 'selected' : ''; ?>>Inattivo</option>
|
||||||
|
<option value="suspended" <?php echo $school['status'] === 'suspended' ? 'selected' : ''; ?>>Sospeso</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<?php if (!$is_new): ?>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label">Data Creazione</label>
|
||||||
|
<input type="text" class="form-control" value="<?php echo htmlspecialchars($school['created_at']); ?>" readonly>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label">Ultimo Aggiornamento</label>
|
||||||
|
<input type="text" class="form-control" value="<?php echo htmlspecialchars($school['updated_at']); ?>" readonly>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<button type="submit" class="btn btn-primary"><?php echo $is_new ? 'Crea Profilo' : 'Salva Modifiche'; ?></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="overlay toggle-icon"></div>
|
||||||
|
<a href="javaScript:;" class="back-to-top"><i class='bx bxs-up-arrow-alt'></i></a>
|
||||||
|
<?php include('include/footer.php'); ?>
|
||||||
|
</div>
|
||||||
|
<?php include('jsinclude.php'); ?>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
2
public/userarea/siteinfo.php
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<title>YogiBoook - School Management</title>
|
||||||
|
<html lang="en" class="headercolor4">
|
||||||
327
public/userarea/teacher_profile.php
Normal file
@ -0,0 +1,327 @@
|
|||||||
|
<?php
|
||||||
|
// Forza la visualizzazione degli errori
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
ini_set('display_startup_errors', 1);
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
|
include('include/headscript.php');
|
||||||
|
|
||||||
|
// Importa la libreria QR Code
|
||||||
|
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||||
|
|
||||||
|
use Endroid\QrCode\Builder\Builder;
|
||||||
|
use Endroid\QrCode\Writer\PngWriter;
|
||||||
|
|
||||||
|
// Connessione al database
|
||||||
|
$dbHandler = DBHandlerSelect::getInstance();
|
||||||
|
$pdo = $dbHandler->getConnection();
|
||||||
|
|
||||||
|
// ID dell'utente loggato (assumiamo sia definito)
|
||||||
|
if (!isset($iduserlogin)) {
|
||||||
|
die("Errore: ID utente non definito.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recupera i dati dell'insegnante
|
||||||
|
$stmt = $pdo->prepare("
|
||||||
|
SELECT t.*, u.first_name, u.last_name, u.email
|
||||||
|
FROM auth_users u
|
||||||
|
LEFT JOIN teachers t ON t.user_id = u.id
|
||||||
|
WHERE u.id = ?
|
||||||
|
");
|
||||||
|
$stmt->execute([$iduserlogin]);
|
||||||
|
$teacher = $stmt->fetch();
|
||||||
|
|
||||||
|
if (!$teacher) {
|
||||||
|
die("Errore: Utente non trovato.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determina se è un nuovo insegnante
|
||||||
|
$is_new = !isset($teacher['id']);
|
||||||
|
if ($is_new) {
|
||||||
|
$teacher = [
|
||||||
|
'id' => null,
|
||||||
|
'user_id' => $iduserlogin,
|
||||||
|
'unique_code' => '',
|
||||||
|
'phone' => '',
|
||||||
|
'description' => '',
|
||||||
|
'specializations' => '',
|
||||||
|
'profile_picture' => '',
|
||||||
|
'status' => 'active',
|
||||||
|
'created_at' => '',
|
||||||
|
'updated_at' => '',
|
||||||
|
'first_name' => $teacher['first_name'],
|
||||||
|
'last_name' => $teacher['last_name'],
|
||||||
|
'email' => $teacher['email']
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Funzione per generare un codice univoco
|
||||||
|
function generateUniqueCode($pdo, $length = 16)
|
||||||
|
{
|
||||||
|
do {
|
||||||
|
$code = bin2hex(random_bytes($length / 2));
|
||||||
|
$stmt = $pdo->prepare("SELECT COUNT(*) FROM teachers WHERE unique_code = ?");
|
||||||
|
$stmt->execute([$code]);
|
||||||
|
$count = $stmt->fetchColumn();
|
||||||
|
} while ($count > 0);
|
||||||
|
return $code;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generazione del QR Code
|
||||||
|
$qr_code_path = null;
|
||||||
|
if (!$is_new) {
|
||||||
|
try {
|
||||||
|
$unique_code = $teacher['unique_code'];
|
||||||
|
if (empty($unique_code)) {
|
||||||
|
throw new Exception("Errore: unique_code è vuoto.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$base_dir = __DIR__ . '/../../public/userarea/phototeachers/qrcodes/';
|
||||||
|
$qr_code_filename = "{$base_dir}{$iduserlogin}-{$unique_code}.png";
|
||||||
|
$qr_code_path = "phototeachers/qrcodes/{$iduserlogin}-{$unique_code}.png";
|
||||||
|
|
||||||
|
if (!file_exists($qr_code_filename)) {
|
||||||
|
if (!is_dir($base_dir)) {
|
||||||
|
mkdir($base_dir, 0755, true) or die("Errore: Impossibile creare la directory.");
|
||||||
|
}
|
||||||
|
if (!is_writable($base_dir)) {
|
||||||
|
die("Errore: La directory non è scrivibile.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$builder = new Builder();
|
||||||
|
$result = $builder->build(
|
||||||
|
writer: new PngWriter(),
|
||||||
|
data: $unique_code,
|
||||||
|
size: 150,
|
||||||
|
margin: 10
|
||||||
|
);
|
||||||
|
$result->saveToFile($qr_code_filename);
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$error = "Errore generazione QR Code: " . $e->getMessage();
|
||||||
|
error_log($error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gestione del form
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
$first_name = $_POST['first_name'];
|
||||||
|
$last_name = $_POST['last_name'];
|
||||||
|
$phone = $_POST['phone'] ?? null;
|
||||||
|
$description = $_POST['description'] ?? null;
|
||||||
|
$specializations = $_POST['specializations'] ?? null;
|
||||||
|
$status = $_POST['status'] === 'active' ? 'active' : 'inactive';
|
||||||
|
|
||||||
|
// Gestione del caricamento della foto
|
||||||
|
$profile_picture = $teacher['profile_picture'];
|
||||||
|
if (isset($_FILES['profile_picture']) && $_FILES['profile_picture']['error'] === UPLOAD_ERR_OK) {
|
||||||
|
$file = $_FILES['profile_picture'];
|
||||||
|
$timestamp = time();
|
||||||
|
$original_name = basename($file['name']);
|
||||||
|
$extension = strtolower(pathinfo($original_name, PATHINFO_EXTENSION));
|
||||||
|
$allowed_extensions = ['jpg', 'jpeg', 'png', 'gif'];
|
||||||
|
|
||||||
|
if (in_array($extension, $allowed_extensions)) {
|
||||||
|
$new_filename = "phototeachers/{$iduserlogin}-{$timestamp}-{$original_name}";
|
||||||
|
if (move_uploaded_file($file['tmp_name'], $new_filename)) {
|
||||||
|
$profile_picture = $new_filename;
|
||||||
|
if ($teacher['profile_picture'] && file_exists($teacher['profile_picture']) && !$is_new) {
|
||||||
|
unlink($teacher['profile_picture']);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$error = "Errore durante il caricamento della foto.";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$error = "Estensione del file non consentita. Usa JPG, JPEG, PNG o GIF.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggiorna auth_users
|
||||||
|
$stmt = $pdo->prepare("UPDATE auth_users SET first_name = ?, last_name = ? WHERE id = ?");
|
||||||
|
$stmt->execute([$first_name, $last_name, $iduserlogin]);
|
||||||
|
|
||||||
|
if ($is_new) {
|
||||||
|
$unique_code = generateUniqueCode($pdo);
|
||||||
|
$stmt = $pdo->prepare("
|
||||||
|
INSERT INTO teachers (user_id, unique_code, phone, description, specializations, profile_picture, status)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||||
|
");
|
||||||
|
$success = $stmt->execute([$iduserlogin, $unique_code, $phone, $description, $specializations, $profile_picture, $status]);
|
||||||
|
|
||||||
|
if ($success) {
|
||||||
|
$success_message = "Insegnante creato con successo!";
|
||||||
|
$stmt = $pdo->prepare("
|
||||||
|
SELECT t.*, u.first_name, u.last_name, u.email
|
||||||
|
FROM auth_users u
|
||||||
|
LEFT JOIN teachers t ON t.user_id = u.id
|
||||||
|
WHERE u.id = ?
|
||||||
|
");
|
||||||
|
$stmt->execute([$iduserlogin]);
|
||||||
|
$teacher = $stmt->fetch();
|
||||||
|
$is_new = false;
|
||||||
|
|
||||||
|
// Genera QR Code per il nuovo insegnante
|
||||||
|
try {
|
||||||
|
$base_dir = __DIR__ . '/../../public/phototeachers/qrcodes/';
|
||||||
|
$qr_code_filename = "{$base_dir}{$iduserlogin}-{$unique_code}.png";
|
||||||
|
$qr_code_path = "phototeachers/qrcodes/{$iduserlogin}-{$unique_code}.png";
|
||||||
|
|
||||||
|
if (!file_exists($qr_code_filename)) {
|
||||||
|
if (!is_dir($base_dir)) {
|
||||||
|
mkdir($base_dir, 0755, true) or die("Errore: Impossibile creare la directory.");
|
||||||
|
}
|
||||||
|
$builder = new Builder();
|
||||||
|
$result = $builder->build(
|
||||||
|
writer: new PngWriter(),
|
||||||
|
data: $unique_code,
|
||||||
|
size: 150,
|
||||||
|
margin: 10
|
||||||
|
);
|
||||||
|
$result->saveToFile($qr_code_filename);
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$error = "Errore generazione QR Code: " . $e->getMessage();
|
||||||
|
error_log($error);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$error = "Errore durante la creazione dell'insegnante.";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$stmt = $pdo->prepare("
|
||||||
|
UPDATE teachers
|
||||||
|
SET phone = ?, description = ?, specializations = ?, profile_picture = ?, status = ?
|
||||||
|
WHERE user_id = ?
|
||||||
|
");
|
||||||
|
$success = $stmt->execute([$phone, $description, $specializations, $profile_picture, $status, $iduserlogin]);
|
||||||
|
|
||||||
|
if ($success) {
|
||||||
|
$success_message = "Dati aggiornati con successo!";
|
||||||
|
$stmt = $pdo->prepare("
|
||||||
|
SELECT t.*, u.first_name, u.last_name, u.email
|
||||||
|
FROM auth_users u
|
||||||
|
LEFT JOIN teachers t ON t.user_id = u.id
|
||||||
|
WHERE u.id = ?
|
||||||
|
");
|
||||||
|
$stmt->execute([$iduserlogin]);
|
||||||
|
$teacher = $stmt->fetch();
|
||||||
|
} else {
|
||||||
|
$error = "Errore durante l'aggiornamento dei dati.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link rel="icon" href="assets/images/favicon-32x32.png" type="image/png" />
|
||||||
|
<?php include('cssinclude.php'); ?>
|
||||||
|
<?php include('siteinfo.php'); ?>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="wrapper">
|
||||||
|
<?php include('include/navbar.php'); ?>
|
||||||
|
<?php include('include/topbar.php'); ?>
|
||||||
|
<div class="page-wrapper">
|
||||||
|
<div class="page-content">
|
||||||
|
<div class="card radius-10">
|
||||||
|
<div class="card-header">
|
||||||
|
<h6 class="mb-0"><?php echo $is_new ? 'Crea Profilo Insegnante' : 'Profilo Insegnante'; ?></h6>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<?php if (isset($success_message)): ?>
|
||||||
|
<div class="alert alert-success" role="alert">
|
||||||
|
<?php echo $success_message; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if (isset($error)): ?>
|
||||||
|
<div class="alert alert-danger" role="alert">
|
||||||
|
<?php echo $error; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<form method="POST" enctype="multipart/form-data">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4 text-center">
|
||||||
|
<div class="mb-3">
|
||||||
|
<img src="<?php echo $teacher['profile_picture'] ? htmlspecialchars($teacher['profile_picture']) : 'phototeachers/ndphoto.png'; ?>"
|
||||||
|
alt="Foto Profilo" class="img-fluid rounded-circle" style="width: 150px; height: 150px; object-fit: cover;">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="profile_picture" class="form-label">Carica nuova foto</label>
|
||||||
|
<input type="file" class="form-control" id="profile_picture" name="profile_picture" accept="image/*">
|
||||||
|
</div>
|
||||||
|
<?php if (!$is_new && $qr_code_path): ?>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label">Codice Univoco</label>
|
||||||
|
<input type="text" class="form-control" value="<?php echo htmlspecialchars($teacher['unique_code']); ?>" readonly>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label">QR Code</label><br>
|
||||||
|
<img src="<?php echo htmlspecialchars($qr_code_path); ?>" alt="QR Code" class="img-fluid" style="width: 150px; height: 150px;">
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-8">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="first_name" class="form-label">Nome</label>
|
||||||
|
<input type="text" class="form-control" id="first_name" name="first_name" value="<?php echo htmlspecialchars($teacher['first_name']); ?>" required>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 mb-3">
|
||||||
|
<label for="last_name" class="form-label">Cognome</label>
|
||||||
|
<input type="text" class="form-control" id="last_name" name="last_name" value="<?php echo htmlspecialchars($teacher['last_name']); ?>" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="email" class="form-label">Email</label>
|
||||||
|
<input type="email" class="form-control" id="email" name="email" value="<?php echo htmlspecialchars($teacher['email']); ?>" readonly>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="phone" class="form-label">Telefono</label>
|
||||||
|
<input type="text" class="form-control" id="phone" name="phone" value="<?php echo htmlspecialchars($teacher['phone'] ?? ''); ?>">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="description" class="form-label">Descrizione</label>
|
||||||
|
<textarea class="form-control" id="description" name="description" rows="3"><?php echo htmlspecialchars($teacher['description'] ?? ''); ?></textarea>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="specializations" class="form-label">Specializzazioni</label>
|
||||||
|
<textarea class="form-control" id="specializations" name="specializations" rows="2"><?php echo htmlspecialchars($teacher['specializations'] ?? ''); ?></textarea>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="status" class="form-label">Stato</label>
|
||||||
|
<div class="form-check form-switch">
|
||||||
|
<input class="form-check-input" type="checkbox" id="status" name="status" value="active" <?php echo $teacher['status'] === 'active' ? 'checked' : ''; ?>>
|
||||||
|
<label class="form-check-label" for="status"><?php echo $teacher['status'] === 'active' ? 'Attivo' : 'Inattivo'; ?></label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php if (!$is_new): ?>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label">Data Creazione</label>
|
||||||
|
<input type="text" class="form-control" value="<?php echo htmlspecialchars($teacher['created_at']); ?>" readonly>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label">Ultimo Aggiornamento</label>
|
||||||
|
<input type="text" class="form-control" value="<?php echo htmlspecialchars($teacher['updated_at']); ?>" readonly>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<button type="submit" class="btn btn-primary"><?php echo $is_new ? 'Crea Profilo' : 'Salva Modifiche'; ?></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="overlay toggle-icon"></div>
|
||||||
|
<a href="javaScript:;" class="back-to-top"><i class='bx bxs-up-arrow-alt'></i></a>
|
||||||
|
<?php include('include/footer.php'); ?>
|
||||||
|
</div>
|
||||||
|
<?php include('jsinclude.php'); ?>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@ -1,3 +1,4 @@
|
|||||||
|
<?php include('include/headscript.php'); ?>
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
@ -8,7 +9,8 @@
|
|||||||
<!--favicon-->
|
<!--favicon-->
|
||||||
<link rel="icon" href="assets/images/favicon-32x32.png" type="image/png" />
|
<link rel="icon" href="assets/images/favicon-32x32.png" type="image/png" />
|
||||||
<?php include('cssinclude.php'); ?>
|
<?php include('cssinclude.php'); ?>
|
||||||
<title>Rocker - Bootstrap 5 Admin Dashboard Template</title>
|
<?php include('siteinfo.php'); ?>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
@ -23,68 +25,7 @@
|
|||||||
<!--start page wrapper -->
|
<!--start page wrapper -->
|
||||||
<div class="page-wrapper">
|
<div class="page-wrapper">
|
||||||
<div class="page-content">
|
<div class="page-content">
|
||||||
<div class="row row-cols-1 row-cols-md-2 row-cols-xl-4">
|
|
||||||
<div class="col">
|
|
||||||
<div class="card radius-10 border-start border-0 border-4 border-info">
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="d-flex align-items-center">
|
|
||||||
<div>
|
|
||||||
<p class="mb-0 text-secondary">Total Orders</p>
|
|
||||||
<h4 class="my-1 text-info">4805</h4>
|
|
||||||
<p class="mb-0 font-13">+2.5% from last week</p>
|
|
||||||
</div>
|
|
||||||
<div class="widgets-icons-2 rounded-circle bg-gradient-blues text-white ms-auto"><i class='bx bxs-cart'></i>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<div class="card radius-10 border-start border-0 border-4 border-danger">
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="d-flex align-items-center">
|
|
||||||
<div>
|
|
||||||
<p class="mb-0 text-secondary">Total Revenue</p>
|
|
||||||
<h4 class="my-1 text-danger">$84,245</h4>
|
|
||||||
<p class="mb-0 font-13">+5.4% from last week</p>
|
|
||||||
</div>
|
|
||||||
<div class="widgets-icons-2 rounded-circle bg-gradient-burning text-white ms-auto"><i class='bx bxs-wallet'></i>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<div class="card radius-10 border-start border-0 border-4 border-success">
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="d-flex align-items-center">
|
|
||||||
<div>
|
|
||||||
<p class="mb-0 text-secondary">Bounce Rate</p>
|
|
||||||
<h4 class="my-1 text-success">34.6%</h4>
|
|
||||||
<p class="mb-0 font-13">-4.5% from last week</p>
|
|
||||||
</div>
|
|
||||||
<div class="widgets-icons-2 rounded-circle bg-gradient-ohhappiness text-white ms-auto"><i class='bx bxs-bar-chart-alt-2'></i>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<div class="card radius-10 border-start border-0 border-4 border-warning">
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="d-flex align-items-center">
|
|
||||||
<div>
|
|
||||||
<p class="mb-0 text-secondary">Total Customers</p>
|
|
||||||
<h4 class="my-1 text-warning">8.4K</h4>
|
|
||||||
<p class="mb-0 font-13">+8.4% from last week</p>
|
|
||||||
</div>
|
|
||||||
<div class="widgets-icons-2 rounded-circle bg-gradient-orange text-white ms-auto"><i class='bx bxs-group'></i>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div><!--end row-->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
BIN
public/userarea/test-qr.png
Normal file
|
After Width: | Height: | Size: 315 B |
@ -1 +1 @@
|
|||||||
{"remember_me":"1","notifications_signup_email":"0","forgot_password":"1","login_reset_token_lifetime":"30","throttle_enabled":"1","throttle_attempts":"3","throttle_lockout_time":"2","reg_enabled":"1","reg_email_confirmation":"1","2fa":{"enabled":true},"app_name":"YogiBoook","registration":{"captcha":{"enabled":false}},"tos":"1","captcha":{"enabled":false},"max_active_sessions":"0"}
|
{"remember_me":"1","notifications_signup_email":"1","forgot_password":"1","login_reset_token_lifetime":"30","throttle_enabled":"1","throttle_attempts":"3","throttle_lockout_time":"2","reg_enabled":"1","reg_email_confirmation":"1","2fa":{"enabled":true},"app_name":"YogiBoook","registration":{"captcha":{"enabled":false}},"tos":"1","captcha":{"enabled":false},"max_active_sessions":"0"}
|
||||||