2018-07-09 12:57:55 +02:00
< ? php
include_once __DIR__ . '/../../core.php' ;
2018-09-18 15:57:55 +02:00
include_once __DIR__ . '/init.php' ;
2018-07-09 12:57:55 +02:00
2018-09-18 15:57:55 +02:00
if ( ! empty ( $fattura )) {
2018-07-09 15:01:11 +02:00
$disabled = false ;
2018-09-18 15:57:55 +02:00
$generated = file_exists ( $upload_dir . '/' . $fattura -> getFilename ());
} else {
2018-07-09 15:01:11 +02:00
$disabled = true ;
2018-09-18 15:57:55 +02:00
$generated = false ;
2018-07-09 15:01:11 +02:00
}
// Campi obbligatori per l'anagrafica Azienda
$azienda = Plugins\Fatturazione\FatturaElettronica :: getAzienda ();
$fields = [
'piva' => 'Partita IVA' ,
// 'codice_fiscale' => 'Codice Fiscale',
'citta' => 'Città' ,
'indirizzo' => 'Indirizzo' ,
'cap' => 'C.A.P.' ,
2018-09-06 17:10:23 +02:00
'nazione' => 'Nazione' ,
2018-07-09 15:01:11 +02:00
];
$missing = [];
foreach ( $fields as $key => $name ) {
if ( empty ( $azienda [ $key ])) {
$missing [] = $name ;
}
}
if ( ! empty ( $missing )) {
echo '
< div class = " alert alert-warning " >
< p >< i class = " fa fa-warning " ></ i > '.tr("Prima di procedere alla generazione della fattura elettronica completa i seguenti campi dell' anagrafica Azienda : _FIELDS_ " , [
'_FIELDS_' => '<b>' . implode ( ', ' , $missing ) . '</b>' ,
]) . ' </ p >
< p > '.Modules::link(' Anagrafiche ', $azienda[' idanagrafica '], tr(' Vai alla scheda anagrafica '), null).' </ p >
</ div > ' ;
}
// Campi obbligatori per l'anagrafica Cliente
2018-09-06 17:10:23 +02:00
$cliente = $dbo -> fetchOne ( 'SELECT *, (SELECT `iso2` FROM `an_nazioni` WHERE `an_nazioni`.`id` = `an_anagrafiche`.`id_nazione`) AS nazione FROM `an_anagrafiche` WHERE `idanagrafica` = ' . prepare ( $record [ 'idanagrafica' ]));
2018-07-09 15:01:11 +02:00
$fields = [
// 'piva' => 'Partita IVA',
// 'codice_fiscale' => 'Codice Fiscale',
'citta' => 'Città' ,
'indirizzo' => 'Indirizzo' ,
'cap' => 'C.A.P.' ,
2018-09-06 17:10:23 +02:00
'nazione' => 'Nazione' ,
'pec' => 'PEC' ,
2018-07-09 15:01:11 +02:00
];
$missing = [];
foreach ( $fields as $key => $name ) {
2018-07-10 17:25:28 +02:00
if ( empty ( $cliente [ $key ])) {
2018-07-09 15:01:11 +02:00
$missing [] = $name ;
}
}
if ( ! empty ( $missing )) {
echo '
< div class = " alert alert-warning " >
< p >< i class = " fa fa-warning " ></ i > '.tr("Prima di procedere alla generazione della fattura elettronica completa i seguenti campi dell' anagrafica Cliente : _FIELDS_ " , [
'_FIELDS_' => '<b>' . implode ( ', ' , $missing ) . '</b>' ,
]) . ' </ p >
2018-07-18 15:20:10 +02:00
< p > '.Modules::link(' Anagrafiche ', $record[' idanagrafica '], tr(' Vai alla scheda anagrafica '), null).' </ p >
2018-07-09 15:01:11 +02:00
</ div > ' ;
}
2018-09-18 15:57:55 +02:00
if ( $generated ) {
2018-07-09 15:11:19 +02:00
echo '
< div class = " row " >
< div class = " col-md-6 " > ' ;
}
2018-07-09 12:57:55 +02:00
echo '
< form action = " " method = " post " role = " form " >
< input type = " hidden " name = " id_plugin " value = " '. $id_plugin .' " >
< input type = " hidden " name = " id_record " value = " '. $id_record .' " >
< input type = " hidden " name = " backto " value = " record-edit " >
< input type = " hidden " name = " op " value = " generate " >
< button type = " submit " class = " btn btn-primary btn-lg btn-block'.( $disabled ? ' disabled' : null).' " '.($disabled ? ' disabled ' : null).' >
2018-09-18 15:57:55 +02:00
< i class = " fa fa-file " ></ i > '.tr(' Genera ').'
2018-07-09 12:57:55 +02:00
</ button >
</ form > ' ;
2018-09-18 15:57:55 +02:00
if ( $generated ) {
2018-07-09 12:57:55 +02:00
echo '
</ div >
< div class = " col-md-6 " >
< a href = " '.ROOTDIR.'/editor.php?id_module='. $id_module .'&id_plugin='. $id_plugin .'&id_record='. $id_record .'&op=download " class = " btn btn-success btn-lg btn-block " target = " _blank " >
2018-09-18 15:57:55 +02:00
< i class = " fa fa-download " ></ i > '.tr(' Scarica ').'
</ a >
</ div >
</ div > ' ;
echo '
< hr >
< div class = " row " >
< div class = " col-md-12 " >
< a href = " '.ROOTDIR.'/plugins/fatturazione/view.php?id_record='. $id_record .' " class = " btn btn-info btn-lg btn-block " target = " _blank " >
< i class = " fa fa-eye " ></ i > '.tr(' Visualizza ').'
2018-07-09 12:57:55 +02:00
</ a >
</ div >
</ div > ' ;
}