📋 AGGIUNTE PRINCIPALI: - Sistema contabile partita doppia con gestioni multiple - Documentazione implementazione completa - Models Laravel: GestioneContabile, MovimentoPartitaDoppia - Controller ContabilitaAvanzataController - Migration sistema contabile completo - Scripts automazione e trasferimento - Manuali utente e checklist implementazione 📊 FILES PRINCIPALI: - docs/10-IMPLEMENTAZIONE-CONTABILITA-PARTITA-DOPPIA-GESTIONI.md - SPECIFICHE-SISTEMA-CONTABILE-COMPLETO.md - netgescon-laravel/database/migrations/2025_07_20_100000_create_complete_accounting_system.php - netgescon-laravel/app/Models/GestioneContabile.php ✅ CHECKPOINT SICURO PER ROLLBACK
310 lines
11 KiB
PowerShell
310 lines
11 KiB
PowerShell
# 🔧 SCRIPT POWERSHELL: GESTIONE SISTEMA CONTABILE NETGESCON
|
|
# File: scripts/NetGescon-Contabilita.ps1
|
|
|
|
param(
|
|
[Parameter(Mandatory=$false)]
|
|
[ValidateSet("diagnosi", "setup", "sync", "verifica", "backup", "help")]
|
|
[string]$Azione = "help",
|
|
|
|
[Parameter(Mandatory=$false)]
|
|
[string]$CondominioId = "",
|
|
|
|
[Parameter(Mandatory=$false)]
|
|
[string]$Anno = ""
|
|
)
|
|
|
|
# 🎨 Colori per output
|
|
$RED = "Red"
|
|
$GREEN = "Green"
|
|
$YELLOW = "Yellow"
|
|
$BLUE = "Blue"
|
|
$CYAN = "Cyan"
|
|
$MAGENTA = "Magenta"
|
|
|
|
# 📋 Configurazione
|
|
$NETGESCON_WIN = "U:\home\michele\netgescon"
|
|
$NETGESCON_VM = "/var/www/netgescon"
|
|
$VM_IP = "192.168.0.200"
|
|
$VM_USER = "michele"
|
|
|
|
Write-Host "🏢 ===== NETGESCON SISTEMA CONTABILE MANAGER =====" -ForegroundColor Blue
|
|
Write-Host "📅 $(Get-Date)" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
function Show-Help {
|
|
Write-Host "📋 COMANDI DISPONIBILI:" -ForegroundColor Yellow
|
|
Write-Host ""
|
|
Write-Host " diagnosi 🔍 Diagnosi completa sistema contabile" -ForegroundColor Cyan
|
|
Write-Host " setup 🔧 Setup automatico sistema contabile" -ForegroundColor Cyan
|
|
Write-Host " sync 🔄 Sincronizzazione Git con VM" -ForegroundColor Cyan
|
|
Write-Host " verifica ⚖️ Verifica partita doppia" -ForegroundColor Cyan
|
|
Write-Host " backup 💾 Backup database" -ForegroundColor Cyan
|
|
Write-Host " help ❓ Mostra questo aiuto" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
Write-Host "📋 ESEMPI D'USO:" -ForegroundColor Yellow
|
|
Write-Host ""
|
|
Write-Host " .\NetGescon-Contabilita.ps1 diagnosi" -ForegroundColor Green
|
|
Write-Host " .\NetGescon-Contabilita.ps1 setup" -ForegroundColor Green
|
|
Write-Host " .\NetGescon-Contabilita.ps1 sync" -ForegroundColor Green
|
|
Write-Host ""
|
|
}
|
|
|
|
function Test-Prerequisites {
|
|
Write-Host "✅ Verifica prerequisiti..." -ForegroundColor Yellow
|
|
|
|
# Verifica directory NetGescon
|
|
if (!(Test-Path $NETGESCON_WIN)) {
|
|
Write-Host "❌ Directory NetGescon non trovata: $NETGESCON_WIN" -ForegroundColor Red
|
|
return $false
|
|
}
|
|
|
|
# Verifica Git
|
|
try {
|
|
git --version | Out-Null
|
|
Write-Host " ✅ Git disponibile" -ForegroundColor Green
|
|
}
|
|
catch {
|
|
Write-Host " ❌ Git non trovato" -ForegroundColor Red
|
|
return $false
|
|
}
|
|
|
|
# Verifica SSH per VM
|
|
try {
|
|
ssh -o ConnectTimeout=5 "$VM_USER@$VM_IP" "echo 'VM raggiungibile'" 2>$null | Out-Null
|
|
Write-Host " ✅ VM raggiungibile" -ForegroundColor Green
|
|
}
|
|
catch {
|
|
Write-Host " ⚠️ VM non raggiungibile - alcune funzioni potrebbero non funzionare" -ForegroundColor Yellow
|
|
}
|
|
|
|
return $true
|
|
}
|
|
|
|
function Invoke-Diagnosi {
|
|
Write-Host "🔍 Esecuzione diagnosi sistema contabile..." -ForegroundColor Yellow
|
|
|
|
if (!(Test-Prerequisites)) {
|
|
return
|
|
}
|
|
|
|
try {
|
|
# Esegue diagnosi su VM
|
|
Write-Host "📊 Diagnosi su VM Linux..." -ForegroundColor Cyan
|
|
ssh "$VM_USER@$VM_IP" "cd /home/michele/netgescon && chmod +x scripts/diagnosi-contabilita.sh && ./scripts/diagnosi-contabilita.sh"
|
|
|
|
Write-Host ""
|
|
Write-Host "✅ Diagnosi completata!" -ForegroundColor Green
|
|
}
|
|
catch {
|
|
Write-Host "❌ Errore durante la diagnosi: $($_.Exception.Message)" -ForegroundColor Red
|
|
}
|
|
}
|
|
|
|
function Invoke-Setup {
|
|
Write-Host "🔧 Setup sistema contabile..." -ForegroundColor Yellow
|
|
|
|
if (!(Test-Prerequisites)) {
|
|
return
|
|
}
|
|
|
|
$confirm = Read-Host "⚠️ ATTENZIONE: Questo comando modificherà il database. Continuare? (y/N)"
|
|
if ($confirm -ne "y" -and $confirm -ne "Y") {
|
|
Write-Host "⏸️ Setup annullato" -ForegroundColor Yellow
|
|
return
|
|
}
|
|
|
|
try {
|
|
# Prima sincronizza gli script più recenti
|
|
Write-Host "🔄 Sincronizzazione script..." -ForegroundColor Cyan
|
|
Invoke-Sync
|
|
|
|
# Esegue setup su VM
|
|
Write-Host "🚀 Avvio setup su VM Linux..." -ForegroundColor Cyan
|
|
ssh "$VM_USER@$VM_IP" "cd /home/michele/netgescon && chmod +x scripts/setup-contabilita-condominiale.sh && ./scripts/setup-contabilita-condominiale.sh"
|
|
|
|
Write-Host ""
|
|
Write-Host "✅ Setup completato!" -ForegroundColor Green
|
|
}
|
|
catch {
|
|
Write-Host "❌ Errore durante il setup: $($_.Exception.Message)" -ForegroundColor Red
|
|
}
|
|
}
|
|
|
|
function Invoke-Sync {
|
|
Write-Host "🔄 Sincronizzazione Git..." -ForegroundColor Yellow
|
|
|
|
if (!(Test-Prerequisites)) {
|
|
return
|
|
}
|
|
|
|
try {
|
|
# Naviga alla directory NetGescon
|
|
Set-Location $NETGESCON_WIN
|
|
|
|
# Verifica stato Git
|
|
Write-Host "📊 Verifica stato Git..." -ForegroundColor Cyan
|
|
$gitStatus = git status --porcelain
|
|
|
|
if ($gitStatus) {
|
|
Write-Host "📝 Modifiche locali rilevate:" -ForegroundColor Yellow
|
|
git status --short
|
|
|
|
$commitConfirm = Read-Host "💾 Fare commit delle modifiche? (y/N)"
|
|
if ($commitConfirm -eq "y" -or $commitConfirm -eq "Y") {
|
|
$commitMessage = Read-Host "💬 Messaggio commit (default: 'Update sistema contabile')"
|
|
if ([string]::IsNullOrWhiteSpace($commitMessage)) {
|
|
$commitMessage = "Update sistema contabile"
|
|
}
|
|
|
|
git add .
|
|
git commit -m $commitMessage
|
|
Write-Host "✅ Commit locale creato" -ForegroundColor Green
|
|
}
|
|
}
|
|
|
|
# Push su Gitea
|
|
Write-Host "📤 Push su Gitea..." -ForegroundColor Cyan
|
|
git push origin master
|
|
Write-Host "✅ Push completato" -ForegroundColor Green
|
|
|
|
# Pull su VM
|
|
Write-Host "📥 Pull su VM..." -ForegroundColor Cyan
|
|
ssh "$VM_USER@$VM_IP" "cd /home/michele/netgescon && git pull origin master"
|
|
|
|
# Sync su directory produzione VM
|
|
Write-Host "🔄 Sync directory produzione VM..." -ForegroundColor Cyan
|
|
ssh "$VM_USER@$VM_IP" "rsync -av --exclude='.git' --exclude='node_modules' --exclude='vendor' /home/michele/netgescon/ /var/www/netgescon/"
|
|
|
|
Write-Host "✅ Sincronizzazione completata!" -ForegroundColor Green
|
|
}
|
|
catch {
|
|
Write-Host "❌ Errore durante la sincronizzazione: $($_.Exception.Message)" -ForegroundColor Red
|
|
}
|
|
}
|
|
|
|
function Invoke-Verifica {
|
|
Write-Host "⚖️ Verifica partita doppia..." -ForegroundColor Yellow
|
|
|
|
if (!(Test-Prerequisites)) {
|
|
return
|
|
}
|
|
|
|
try {
|
|
# Esegue verifica su VM
|
|
Write-Host "🔍 Verifica su VM Linux..." -ForegroundColor Cyan
|
|
ssh "$VM_USER@$VM_IP" "cd /var/www/netgescon && php artisan contabilita:verifica"
|
|
|
|
Write-Host "✅ Verifica completata!" -ForegroundColor Green
|
|
}
|
|
catch {
|
|
Write-Host "❌ Errore durante la verifica: $($_.Exception.Message)" -ForegroundColor Red
|
|
}
|
|
}
|
|
|
|
function Invoke-Backup {
|
|
Write-Host "💾 Backup database..." -ForegroundColor Yellow
|
|
|
|
if (!(Test-Prerequisites)) {
|
|
return
|
|
}
|
|
|
|
try {
|
|
$timestamp = Get-Date -Format "yyyyMMdd_HHmmss"
|
|
|
|
# Esegue backup su VM
|
|
Write-Host "📦 Creazione backup su VM..." -ForegroundColor Cyan
|
|
ssh "$VM_USER@$VM_IP" "cd /var/www/netgescon && php artisan tinker --execute='echo config(\"database.connections.mysql.database\");' | tail -1 | xargs -I {} mysqldump -u netgescon_user -p netgescon {} > /home/michele/netgescon/backup/database/netgescon_manual_backup_$timestamp.sql"
|
|
|
|
# Scarica backup su Windows (opzionale)
|
|
$downloadConfirm = Read-Host "📥 Scaricare backup su Windows? (y/N)"
|
|
if ($downloadConfirm -eq "y" -or $downloadConfirm -eq "Y") {
|
|
$backupLocal = "$NETGESCON_WIN\backup\database"
|
|
if (!(Test-Path $backupLocal)) {
|
|
New-Item -ItemType Directory -Force -Path $backupLocal | Out-Null
|
|
}
|
|
|
|
scp "$VM_USER@${VM_IP}:/home/michele/netgescon/backup/database/netgescon_manual_backup_$timestamp.sql" "$backupLocal\"
|
|
Write-Host "✅ Backup scaricato: $backupLocal\netgescon_manual_backup_$timestamp.sql" -ForegroundColor Green
|
|
}
|
|
|
|
Write-Host "✅ Backup completato!" -ForegroundColor Green
|
|
}
|
|
catch {
|
|
Write-Host "❌ Errore durante il backup: $($_.Exception.Message)" -ForegroundColor Red
|
|
}
|
|
}
|
|
|
|
function Show-Status {
|
|
Write-Host "📊 STATO SISTEMA NETGESCON" -ForegroundColor Blue
|
|
Write-Host ""
|
|
|
|
try {
|
|
# Stato Git locale
|
|
Write-Host "📁 Repository locale:" -ForegroundColor Yellow
|
|
Set-Location $NETGESCON_WIN
|
|
$lastCommit = git log -1 --format="%h %s (%cr)"
|
|
Write-Host " Ultimo commit: $lastCommit" -ForegroundColor Cyan
|
|
|
|
# Stato VM
|
|
Write-Host ""
|
|
Write-Host "🖥️ Virtual Machine:" -ForegroundColor Yellow
|
|
try {
|
|
$vmStatus = ssh -o ConnectTimeout=5 "$VM_USER@$VM_IP" "uptime" 2>$null
|
|
Write-Host " ✅ VM Online: $vmStatus" -ForegroundColor Green
|
|
|
|
# Stato Laravel
|
|
$laravelStatus = ssh "$VM_USER@$VM_IP" "cd /var/www/netgescon && php artisan --version" 2>$null
|
|
Write-Host " ✅ Laravel: $laravelStatus" -ForegroundColor Green
|
|
}
|
|
catch {
|
|
Write-Host " ❌ VM non raggiungibile" -ForegroundColor Red
|
|
}
|
|
|
|
# Stato servizi
|
|
Write-Host ""
|
|
Write-Host "🌐 Servizi:" -ForegroundColor Yellow
|
|
Write-Host " 🚀 NetGescon: http://$VM_IP:8000" -ForegroundColor Cyan
|
|
Write-Host " 🗄️ phpMyAdmin: http://$VM_IP/phpmyadmin" -ForegroundColor Cyan
|
|
Write-Host " 🔧 Gitea: http://$VM_IP:3000" -ForegroundColor Cyan
|
|
}
|
|
catch {
|
|
Write-Host "❌ Errore nel recupero stato: $($_.Exception.Message)" -ForegroundColor Red
|
|
}
|
|
}
|
|
|
|
# 🚀 ESECUZIONE PRINCIPALE
|
|
switch ($Azione) {
|
|
"diagnosi" {
|
|
Invoke-Diagnosi
|
|
}
|
|
"setup" {
|
|
Invoke-Setup
|
|
}
|
|
"sync" {
|
|
Invoke-Sync
|
|
}
|
|
"verifica" {
|
|
Invoke-Verifica
|
|
}
|
|
"backup" {
|
|
Invoke-Backup
|
|
}
|
|
"status" {
|
|
Show-Status
|
|
}
|
|
"help" {
|
|
Show-Help
|
|
}
|
|
default {
|
|
Show-Help
|
|
}
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "🔗 LINK UTILI:" -ForegroundColor Blue
|
|
Write-Host " 📖 Manuale: docs/07-SISTEMA-CONTABILE-CONDOMINIALE.md" -ForegroundColor Cyan
|
|
Write-Host " 🔧 Implementazione: docs/08-IMPLEMENTAZIONE-SISTEMA-CONTABILE-PRATICO.md" -ForegroundColor Cyan
|
|
Write-Host " 🌐 NetGescon: http://$VM_IP:8000/admin" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
Write-Host "💎 Sistema contabile condominiale NetGescon - Controllo totale di ogni centesimo!" -ForegroundColor Green
|