200 lines
8.5 KiB
PHP
200 lines
8.5 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Carbon\Carbon;
|
|
|
|
class InstallStampeRateModule extends Command
|
|
{
|
|
protected $signature = 'module:install-stampe-rate';
|
|
protected $description = 'Installa il modulo StampeRate nel sistema';
|
|
|
|
public function handle()
|
|
{
|
|
$this->info('🚀 Installazione modulo StampeRate...');
|
|
|
|
try {
|
|
// Verifica se il modulo è già installato
|
|
$esistente = DB::table('modules')->where('name', 'StampeRate')->first();
|
|
|
|
if ($esistente) {
|
|
$this->warn('⚠️ Modulo StampeRate già installato. Aggiorno la configurazione...');
|
|
|
|
DB::table('modules')->where('name', 'StampeRate')->update([
|
|
'version' => '1.0.0',
|
|
'description' => 'Modulo avanzato per la gestione e stampa delle rate condominiali con template personalizzabili',
|
|
'config' => json_encode([
|
|
'prezzo_annuale' => 99.00,
|
|
'categoria' => 'Stampe e Comunicazioni',
|
|
'features' => [
|
|
'Generazione PDF multipli',
|
|
'Template personalizzabili',
|
|
'Invio email automatico',
|
|
'Tracking aperture email',
|
|
'Cronologia e statistiche',
|
|
'Export in vari formati'
|
|
],
|
|
'permessi' => [
|
|
'stampe_rate_view' => 'Visualizzare stampe rate',
|
|
'stampe_rate_create' => 'Creare nuove stampe',
|
|
'stampe_rate_edit' => 'Modificare stampe esistenti',
|
|
'stampe_rate_delete' => 'Eliminare stampe',
|
|
'stampe_rate_templates_manage' => 'Gestire template',
|
|
'stampe_rate_admin' => 'Amministrazione completa modulo'
|
|
],
|
|
'menu_items' => [
|
|
[
|
|
'title' => 'Stampe Rate',
|
|
'route' => 'stampeRate.index',
|
|
'icon' => 'fa-file-pdf',
|
|
'permission' => 'stampe_rate_view'
|
|
],
|
|
[
|
|
'title' => 'Template',
|
|
'route' => 'stampeRate.templates.index',
|
|
'icon' => 'fa-template',
|
|
'permission' => 'stampe_rate_templates_manage'
|
|
],
|
|
[
|
|
'title' => 'Cronologia',
|
|
'route' => 'stampeRate.history.index',
|
|
'icon' => 'fa-history',
|
|
'permission' => 'stampe_rate_view'
|
|
]
|
|
]
|
|
]),
|
|
'status' => 'active',
|
|
'updated_at' => now()
|
|
]);
|
|
|
|
$this->info('✅ Modulo aggiornato con successo!');
|
|
} else {
|
|
|
|
DB::table('modules')->insert([
|
|
'name' => 'StampeRate',
|
|
'display_name' => 'Stampe Rate Avanzate',
|
|
'version' => '1.0.0',
|
|
'description' => 'Modulo avanzato per la gestione e stampa delle rate condominiali con template personalizzabili',
|
|
'author' => 'NetGescon Team',
|
|
'status' => 'active',
|
|
'license' => 'commercial',
|
|
'price' => 99.00,
|
|
'currency' => 'EUR',
|
|
'billing' => 'yearly',
|
|
'config' => json_encode([
|
|
'path' => 'app/Modules/StampeRate',
|
|
'namespace' => 'App\\Modules\\StampeRate',
|
|
'prezzo_annuale' => 99.00,
|
|
'categoria' => 'Stampe e Comunicazioni',
|
|
'features' => [
|
|
'Generazione PDF multipli',
|
|
'Template personalizzabili',
|
|
'Invio email automatico',
|
|
'Tracking aperture email',
|
|
'Cronologia e statistiche',
|
|
'Export in vari formati'
|
|
],
|
|
'menu_items' => [
|
|
[
|
|
'title' => 'Stampe Rate',
|
|
'route' => 'stampeRate.index',
|
|
'icon' => 'fa-file-pdf',
|
|
'permission' => 'stampe_rate_view'
|
|
],
|
|
[
|
|
'title' => 'Template',
|
|
'route' => 'stampeRate.templates.index',
|
|
'icon' => 'fa-template',
|
|
'permission' => 'stampe_rate_templates_manage'
|
|
],
|
|
[
|
|
'title' => 'Cronologia',
|
|
'route' => 'stampeRate.history.index',
|
|
'icon' => 'fa-history',
|
|
'permission' => 'stampe_rate_view'
|
|
]
|
|
]
|
|
]),
|
|
'dependencies' => json_encode([]),
|
|
'permissions' => json_encode([
|
|
'stampe_rate_view' => 'Visualizzare stampe rate',
|
|
'stampe_rate_create' => 'Creare nuove stampe',
|
|
'stampe_rate_edit' => 'Modificare stampe esistenti',
|
|
'stampe_rate_delete' => 'Eliminare stampe',
|
|
'stampe_rate_templates_manage' => 'Gestire template',
|
|
'stampe_rate_admin' => 'Amministrazione completa modulo'
|
|
]),
|
|
'license_key' => null,
|
|
'license_expires_at' => now()->addYear(),
|
|
'installed_at' => now(),
|
|
'installed_by' => 'system',
|
|
'created_at' => now(),
|
|
'updated_at' => now()
|
|
]);
|
|
|
|
$this->info('✅ Modulo StampeRate installato con successo!');
|
|
}
|
|
|
|
// Mostra statistiche installazione
|
|
$this->showInstallationStats();
|
|
|
|
$this->info('🎉 Installazione completata! Il modulo è ora attivo e pronto all\'uso.');
|
|
$this->info('💰 Prezzo: €99/anno - Categoria: Stampe e Comunicazioni');
|
|
$this->line('');
|
|
$this->info('📍 Route disponibili:');
|
|
$this->line(' • /stampe-rate - Dashboard principale');
|
|
$this->line(' • /stampe-rate/templates - Gestione template');
|
|
$this->line(' • /stampe-rate/history - Cronologia e tracking');
|
|
$this->line('');
|
|
} catch (\Exception $e) {
|
|
$this->error('❌ Errore durante l\'installazione: ' . $e->getMessage());
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
private function showInstallationStats()
|
|
{
|
|
$this->line('');
|
|
$this->info('📊 STATISTICHE INSTALLAZIONE:');
|
|
|
|
// Conta template installati
|
|
$templateCount = DB::table('stampe_templates')->where('module', 'stampe_rate')->count();
|
|
$this->line(" • Template installati: {$templateCount}");
|
|
|
|
// Conta configurazioni
|
|
$configCount = DB::table('stampe_rate_config')->count();
|
|
$this->line(" • Configurazioni create: {$configCount}");
|
|
|
|
// Verifica tabelle create
|
|
$tabelle = [
|
|
'stampe_rate',
|
|
'stampe_templates',
|
|
'stampe_rate_history',
|
|
'stampe_rate_email_log',
|
|
'stampe_rate_config'
|
|
];
|
|
|
|
$tabelleOk = 0;
|
|
foreach ($tabelle as $tabella) {
|
|
try {
|
|
DB::table($tabella)->count();
|
|
$tabelleOk++;
|
|
} catch (\Exception $e) {
|
|
// Tabella non esiste
|
|
}
|
|
}
|
|
|
|
$this->line(" • Tabelle database: {$tabelleOk}/" . count($tabelle));
|
|
|
|
if ($tabelleOk === count($tabelle)) {
|
|
$this->info(' ✅ Tutte le tabelle sono state create correttamente');
|
|
} else {
|
|
$this->warn(' ⚠️ Alcune tabelle potrebbero non essere state create');
|
|
}
|
|
}
|
|
}
|