2017-08-04 16:28:16 +02:00
< ? php
2020-09-07 15:04:06 +02:00
/*
* OpenSTAManager : il software gestionale open source per l ' assistenza tecnica e la fatturazione
2021-01-20 15:08:51 +01:00
* Copyright ( C ) DevCode s . r . l .
2020-09-07 15:04:06 +02:00
*
* This program is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < https :// www . gnu . org / licenses />.
*/
2017-08-04 16:28:16 +02:00
include_once __DIR__ . '/../../core.php' ;
2019-09-28 11:12:11 +02:00
$dir = $documento -> direzione ;
$numero = $documento -> numero_esterno ? : $documento -> numero ;
2017-08-04 16:28:16 +02:00
echo '
< form action = " " method = " post " id = " edit-form " >
< input type = " hidden " name = " op " value = " update " >
< input type = " hidden " name = " backto " value = " record-edit " >
< input type = " hidden " name = " id_record " value = " '. $id_record .' " >
2020-02-23 14:42:25 +01:00
2019-07-25 18:05:47 +02:00
< input type = " hidden " name = " tipo " value = " '. $record['tipo'] .' " >
< input type = " hidden " name = " descrizione " value = " '. $record['descrizione'] .' " >
< input type = " hidden " name = " iddocumento " value = " '. $record['iddocumento'] .' " >
2022-10-10 11:23:17 +02:00
< input type = " hidden " name = " idanagrafica " value = " '. $record['idanagrafica'] .' " >
2017-08-04 16:28:16 +02:00
< div class = " panel panel-primary " >
< div class = " panel-heading " >
2019-07-25 18:05:47 +02:00
< h3 class = " panel-title " >
'.tr(' Dettagli scadenza ').'
</ button >
</ h3 >
2017-08-04 16:28:16 +02:00
</ div >
< div class = " panel-body " >
< div class = " row " >
<!-- Info scadenza -->
2022-09-01 12:52:33 +02:00
< div class = " col-md-6 " >
2019-09-28 11:12:11 +02:00
< table class = " table table-striped table-hover table-condensed table-bordered " >
2017-08-04 16:28:16 +02:00
< tr >
2022-09-01 12:52:33 +02:00
< th width = " 125 " > '.($dir == ' entrata ' ? tr(' Cliente ') : ($dir == ' uscita ' ? tr(' Fornitore ') : tr(' Anagrafica '))).' :</ th >
2017-08-04 16:28:16 +02:00
< td >
2022-09-01 12:52:33 +02:00
'.Modules::link(' Anagrafiche ', $record[' idanagrafica '], $record[' ragione_sociale ']).'
2017-08-04 16:28:16 +02:00
</ td >
2022-09-01 12:52:33 +02:00
</ tr > ' ;
if ( ! empty ( $documento )) {
echo '
2019-04-19 17:29:54 +02:00
< tr >
< th > '.tr(' Documento ').' :</ th >
2019-09-28 11:12:11 +02:00
< td > '.$documento->tipo->descrizione.' </ td >
2020-01-14 22:18:52 +01:00
</ tr >
2019-04-19 17:29:54 +02:00
< tr >
< th > '.tr(' Numero ').' :</ th >
< td > '.$numero.' </ td >
2020-01-14 22:18:52 +01:00
</ tr >
2023-11-24 13:20:00 +01:00
</ table >
2020-01-14 22:18:52 +01:00
2023-11-24 13:20:00 +01:00
< table class = " table table-striped table-hover table-condensed table-bordered " >
2019-04-19 17:29:54 +02:00
< tr >
< th > '.tr(' Data ').' :</ th >
2019-09-28 11:12:11 +02:00
< td > '.Translator::dateToLocale($documento->data).' </ td >
</ tr >
2020-01-14 22:18:52 +01:00
< tr >
2020-02-05 12:45:15 +01:00
< th > '.tr(' Netto a pagare ').' :</ th >
< td > '.moneyFormat($documento->netto).' </ td >
2023-11-24 13:20:00 +01:00
</ tr >
2022-09-01 12:52:33 +02:00
< tr >
2023-11-24 13:20:00 +01:00
< th > '.tr(' Info distinta ').' < span class = " tip " title = " '.tr('Informazioni/Note sulla distinta associata alla scadenza (es. numero)').' " >< i class = " fa fa-question-circle-o " ></ i ></ span >:</ th >
2022-09-01 12:52:33 +02:00
< td >
2023-11-24 13:20:00 +01:00
{[ " type " : " text " , " name " : " distinta " , " value " : " '. $record['distinta'] .' " ]}
2022-09-01 12:52:33 +02:00
</ td >
2023-11-24 13:20:00 +01:00
</ tr >
</ table >
2020-01-14 22:18:52 +01:00
2023-11-24 13:20:00 +01:00
'.Modules::link($documento->module, $record[' iddocumento '], ' < i class = " fa fa-folder-open " ></ i > '.tr(' Apri documento '), null, ' class = " btn btn-primary " ').'
</ div > ' ;
} else {
$scadenza = $dbo -> fetchOne ( 'SELECT * FROM co_scadenziario WHERE id = ' . prepare ( $id_record ));
echo '
< table class = " table table-striped table-hover table-condensed table-bordered " >
2020-01-28 14:20:14 +01:00
< tr >
2023-11-24 13:20:00 +01:00
< td > ' ;
2023-11-24 18:24:13 +01:00
echo input ([
2023-11-24 13:20:00 +01:00
'type' => 'ckeditor' ,
'label' => tr ( 'descrizione' ),
'name' => 'descrizione' ,
'required' => 1 ,
'extra' => 'rows="2"' ,
'value' => $record [ 'descrizione' ],
]);
2023-11-24 18:24:13 +01:00
echo '
2020-01-28 14:20:14 +01:00
</ td >
</ tr >
2023-11-24 13:20:00 +01:00
</ table >
</ div > ' ;
}
2020-01-28 14:20:14 +01:00
2023-11-24 13:20:00 +01:00
echo '
< div class = " col-md-6 " >
< table class = " table table-striped table-hover table-condensed table-bordered " >
2021-12-07 13:05:41 +01:00
< tr >
2023-11-24 13:20:00 +01:00
< td > ' ;
echo input ([
'type' => 'ckeditor' ,
'label' => tr ( 'Note' ),
'name' => 'note' ,
'extra' => 'rows="2"' ,
2023-11-24 18:24:13 +01:00
'value' => $record [ 'note' ],
2023-11-24 13:20:00 +01:00
]);
echo '
2021-12-07 13:05:41 +01:00
</ td >
2022-01-20 16:34:42 +01:00
</ tr > ' ;
2023-08-04 14:54:28 +02:00
if ( ! empty ( $record [ 'presentazioni_exported_at' ])) {
$export_riba = '<i class="fa fa-check text-success"></i> ' . tr ( 'Esportata il _DATA_' , [
2022-01-20 16:34:42 +01:00
'_DATA_' => Translator :: timestampToLocale ( $record [ 'presentazioni_exported_at' ]),
]) . '' ;
2023-08-04 14:54:28 +02:00
} else {
2022-01-20 16:34:42 +01:00
$export_riba = '<i class="fa fa-clock-o text-warning"></i> ' . tr ( 'Non ancora esportata' );
}
2022-09-01 12:52:33 +02:00
echo '
</ table > ' ;
2023-08-04 14:54:28 +02:00
2017-08-04 16:28:16 +02:00
echo '
</ div >
2023-11-24 13:20:00 +01:00
</ div >
</ div >
</ div >
< div class = " panel panel-primary " >
< div class = " panel-heading " >
< h3 class = " panel-title " >
'.tr(' Rate scadenza ').'
< button type = " button " class = " btn btn-xs btn-info pull-right tip " id = " add-scadenza " '.(empty($documento) ? ' disabled ' : ' ').' title = " '.tr('È possibile aggiungere scadenze solo se è presente il collegamento a un documento, in caso contrario è consigliato creare più scadenze con la stessa descrizione').' " >
< i class = " fa fa-plus " ></ i > '.tr(' Aggiungi scadenza ').'
</ button >
</ h3 >
</ div >
2023-11-24 18:24:13 +01:00
< div class = " panel-body " >
< div class = " row " >
< div class = " col-md-12 " >
< table class = " table table-hover table-condensed table-bordered text-center " >
< thead >
< tr >
< th style = " width:20%; " > '.tr(' Banca accredito ').' </ th >
< th style = " width:20%; " > '.tr(' Banca addebito ').' </ th >
< th style = " width:20%; " > '.tr(' Tipologia ').' </ th >
2023-11-27 10:06:30 +01:00
< th style = " width:10%; " > '.tr(' Data ').' </ th >
< th style = " width:10%; " > '.tr(' Data concordata ').' </ th >
< th style = " width:10%; " > '.tr(' Importo ').' </ th >
< th style = " width:10%; " > '.tr(' Pagato ').' </ th >
< th style = " width:3%; " > '.tr(' Rata ').' </ th >
2023-11-24 18:24:13 +01:00
</ tr >
</ thead >
< tbody id = " scadenze " > ' ;
2017-08-04 16:28:16 +02:00
2020-09-07 14:52:46 +02:00
foreach ( $scadenze as $i => $scadenza ) {
2019-09-28 11:12:11 +02:00
if ( $scadenza [ 'da_pagare' ] == $scadenza [ 'pagato' ]) {
2017-08-04 16:28:16 +02:00
$class = 'success' ;
2019-09-28 11:12:11 +02:00
} elseif ( abs ( $scadenza [ 'pagato' ]) == 0 ) {
2017-08-04 16:28:16 +02:00
$class = 'danger' ;
2019-09-28 11:12:11 +02:00
} elseif ( abs ( $scadenza [ 'pagato' ]) <= abs ( $scadenza [ 'da_pagare' ])) {
2017-08-04 16:28:16 +02:00
$class = 'warning' ;
} else {
$class = 'danger' ;
}
echo '
2023-11-24 13:20:00 +01:00
< tr class = " '. $class .' " >
< input type = " hidden " name = " id_scadenza['. $i .'] " value = " '. $scadenza['id'] .' " >
< td align = " center " >
'.($scadenza[' da_pagare ' ] > 0 ?
2023-11-24 18:24:13 +01:00
'{[ "type": "select", "name": "id_banca_azienda[' . $i . ']", "ajax-source": "banche", "select-options": ' . json_encode ([ 'id_anagrafica' => $anagrafica_azienda -> id ]) . ', "value": "' . $scadenza [ 'id_banca_azienda' ] . '", "icon-after": "add|' . Modules :: get ( 'Banche' )[ 'id' ] . '|id_anagrafica=' . $anagrafica_azienda -> id . '" ]}'
2023-11-24 13:20:00 +01:00
:
2023-11-24 18:24:13 +01:00
'{[ "type": "select", "name": "id_banca_controparte[' . $i . ']", "ajax-source": "banche", "select-options":' . json_encode ([ 'id_anagrafica' => $scadenza [ 'idanagrafica' ]]) . ', "value": "' . $scadenza [ 'id_banca_controparte' ] . '", "icon-after": "add|' . Modules :: get ( 'Banche' )[ 'id' ] . '|idanagrafica=' . $record [ 'idanagrafica' ] . ' " ]}
2023-11-24 13:20:00 +01:00
').'
</ td >
< td align = " center " >
'.($scadenza[' da_pagare ' ] > 0 ?
2023-11-24 18:24:13 +01:00
'{[ "type": "select", "name": "id_banca_controparte[' . $i . ']", "ajax-source": "banche", "select-options":' . json_encode ([ 'id_anagrafica' => $scadenza [ 'idanagrafica' ]]) . ', "value": "' . $scadenza [ 'id_banca_controparte' ] . '", "icon-after": "add|' . Modules :: get ( 'Banche' )[ 'id' ] . '|idanagrafica=' . $record [ 'idanagrafica' ] . '"]}'
2023-11-24 13:20:00 +01:00
:
2023-11-24 18:24:13 +01:00
'{[ "type": "select", "name": "id_banca_azienda[' . $i . ']", "ajax-source": "banche", "select-options": ' . json_encode ([ 'id_anagrafica' => $anagrafica_azienda -> id ]) . ', "value": "' . $scadenza [ 'id_banca_azienda' ] . '", "icon-after": "add|' . Modules :: get ( 'Banche' )[ 'id' ] . '|id_anagrafica=' . $anagrafica_azienda -> id . '" ]}'
2023-11-24 13:20:00 +01:00
) . '
</ td >
< td >
2023-11-27 11:18:54 +01:00
{[ " type " : " select " , " name " : " id_pagamento['. $i .'] " , " ajax-source " : " pagamenti " , " select-options " : '.json_encode([' id_anagrafica ' => $anagrafica_azienda->id]).' , " value " : " '. $scadenza['id_pagamento'] .' " ]}
2023-11-24 13:20:00 +01:00
</ td >
2023-11-27 10:06:30 +01:00
< td align = " center " >
{[ " type " : " date " , " name " : " scadenza['. $i .'] " , " value " : " '. $scadenza['scadenza'] .' " ]}
</ td >
< td align = " center " >
{[ " type " : " date " , " name " : " data_concordata['. $i .'] " , " value " : " '. $scadenza['data_concordata'] .' " ]}
</ td >
< td class = " text-right " >
{[ " type " : " number " , " name " : " da_pagare['. $i .'] " , " decimals " : 2 , " value " : " '.numberFormat( $scadenza['da_pagare'] , 2).' " , " onchange " : " controlloTotale() " ]}
</ td >
< td class = " text-right " >
{[ " type " : " number " , " name " : " pagato['. $i .'] " , " decimals " : 2 , " value " : " '.numberFormat( $scadenza['pagato'] ).' " ]}
</ td >
< td align = " center " >
< a onclick = " launch_modal( \ ''.tr('Registra contabile pagamento').' \ ', \ ''.base_path().'/add.php?id_module='.Modules::get('Prima nota')['id'].'&id_scadenze='. $scadenza['id'] .' \ '); " class = " btn btn-sm btn-primary " >
< i class = " fa fa-euro " ></ i > '.($scadenza[' da_pagare '] > 0 ? tr(' Incassa ') : tr(' Paga ')).'
</ a >
</ td >
2023-11-24 13:20:00 +01:00
</ tr > ' ;
2023-11-24 18:24:13 +01:00
}
2023-11-24 13:20:00 +01:00
echo '
2019-07-25 18:05:47 +02:00
</ tbody >
< tfoot >
< tr >
2023-11-24 13:20:00 +01:00
< td class = " text-right " ></ td >
2020-07-06 13:19:20 +02:00
< td class = " text-right " >< b > '.tr(' Totale ').' </ b ></ td >
2020-10-06 12:29:14 +02:00
< td class = " text-right " id = " totale_utente " > '.numberFormat($totale_da_pagare).' </ td >
2020-07-06 13:19:20 +02:00
< td class = " text-right " ></ td >
2020-11-13 16:12:29 +01:00
< td class = " text-right " ></ td >
2023-11-24 13:20:00 +01:00
< td class = " text-right " ></ td >
< td class = " text-right " ></ td >
2019-07-25 18:05:47 +02:00
</ tr >
2020-11-13 16:12:29 +01:00
</ tfoot >
2023-11-24 18:24:13 +01:00
</ table >
</ div > ' ;
2020-11-13 16:12:29 +01:00
?>
2020-02-23 14:42:25 +01:00
2023-11-24 18:24:13 +01:00
< div class = " alert alert-warning hide " id = " totale " >< ? php echo tr ( 'Il totale da pagare non corrisponde con il totale della fattura che è pari a _MONEY_' , [
'_MONEY_' => '<b>' . moneyFormat ( $totale_da_pagare ) . '</b>' ,
]); ?> .<br><?php echo tr('Differenza di _TOT_ _CURRENCY_', [
'_TOT_' => '<span id="diff"></span>' ,
'_CURRENCY_' => currency (),
]); ?> .
</ div >
2017-08-04 16:28:16 +02:00
2023-11-24 18:24:13 +01:00
< input type = " hidden " id = " totale_da_pagare " value = " <?php echo round( $totale_da_pagare , 2); ?> " >
</ div >
</ div >
</ div >
2017-08-04 16:28:16 +02:00
</ form >
2022-06-10 15:54:50 +02:00
{( " name " : " filelist_and_upload " , " id_module " : " $id_module $ " , " id_record " : " <?php echo $id_record ; ?> " )}
2020-05-26 11:31:53 +02:00
2019-02-21 12:24:57 +01:00
{( " name " : " log_email " , " id_module " : " $id_module $ " , " id_record " : " $id_record $ " )}
2017-08-04 16:28:16 +02:00
2019-04-19 17:29:54 +02:00
< ? php
2020-02-23 14:42:25 +01:00
if ( empty ( $documento )) {
2023-11-24 18:24:13 +01:00
echo '
2019-04-19 17:29:54 +02:00
< a class = " btn btn-danger ask " data - backto = " record-list " >
2020-02-23 14:42:25 +01:00
< i class = " fa fa-trash " ></ i > '.tr(' Elimina ').'
</ a > ' ;
2023-11-24 18:24:13 +01:00
}
2019-07-25 18:05:47 +02:00
echo '
< table class = " hide " >
< tbody id = " scadenza-template " >
< tr class = " danger " >
2019-09-28 11:12:11 +02:00
< input type = " hidden " name = " id_scadenza[-id-] " value = " " >
2020-02-23 14:42:25 +01:00
2019-07-25 18:05:47 +02:00
< td align = " center " >
{[ " type " : " date " , " name " : " scadenza[-id-] " ]}
</ td >
2020-02-23 14:42:25 +01:00
2020-07-06 13:19:20 +02:00
< td class = " text-right " >
2019-07-25 18:05:47 +02:00
{[ " type " : " number " , " name " : " da_pagare[-id-] " , " decimals " : 2 , " onchange " : " controlloTotale() " ]}
</ td >
2020-02-23 14:42:25 +01:00
2020-07-06 13:19:20 +02:00
< td class = " text-right " >
2019-07-25 18:05:47 +02:00
{[ " type " : " number " , " name " : " pagato[-id-] " , " decimals " : 2 ]}
</ td >
2020-02-23 14:42:25 +01:00
2019-07-25 18:05:47 +02:00
< td align = " center " >
{[ " type " : " date " , " name " : " data_concordata[-id-] " ]}
</ td >
</ tr >
</ tbody >
</ table >
< script >
var i = '.$i.' ;
2020-07-31 14:25:50 +02:00
$ ( document ) . on ( " click " , " #add-scadenza " , function () {
2019-07-26 17:40:52 +02:00
cleanup_inputs ();
2020-02-23 14:42:25 +01:00
2019-07-26 17:40:52 +02:00
i ++ ;
2019-07-25 18:05:47 +02:00
var text = replaceAll ( $ ( " #scadenza-template " ) . html (), " -id- " , " " + i );
2020-02-23 14:42:25 +01:00
2019-07-25 18:05:47 +02:00
$ ( " #scadenze " ) . append ( text );
2019-07-26 17:40:52 +02:00
restart_inputs ();
2019-07-25 18:05:47 +02:00
});
</ script > ' ;
2020-02-23 14:42:25 +01:00
// Abilitazione dei controlli solo per Scadenze collegate a documenti
if ( ! empty ( $documento )) {
echo '
2017-08-04 16:28:16 +02:00
< script >
2019-05-02 10:03:57 +02:00
globals . cifre_decimali = 2 ;
2019-07-26 17:40:52 +02:00
2020-07-31 14:25:50 +02:00
$ ( document ) . ready ( function () {
2020-02-23 14:42:25 +01:00
controlloTotale (); ' ;
2019-07-26 17:40:52 +02:00
2020-02-23 14:42:25 +01:00
if ( $dir == 'uscita' ) {
echo '
2022-06-10 15:54:50 +02:00
$ ( " #email-button " ) . remove ();
$ ( " #allega-fattura " ) . remove (); ' ;
2020-02-23 14:42:25 +01:00
}
echo '
2017-08-04 16:28:16 +02:00
});
2019-07-25 18:05:47 +02:00
function controlloTotale () {
2020-10-06 12:29:14 +02:00
let totale_da_pagare = parseFloat ( $ ( " #totale_da_pagare " ) . val ());
let totale_utente = 0 ;
2017-08-04 16:28:16 +02:00
2020-02-23 14:42:25 +01:00
$ ( " input[name*=da_pagare] " ) . each ( function () {
2020-10-06 12:29:14 +02:00
totale_utente += input ( this ) . get ();
2019-07-25 18:05:47 +02:00
});
2017-08-04 16:28:16 +02:00
2019-07-25 18:05:47 +02:00
if ( isNaN ( totale_utente )) {
totale_utente = 0 ;
}
2017-08-04 16:28:16 +02:00
2019-07-25 18:05:47 +02:00
totale_utente = Math . round ( totale_utente * 100 ) / 100 ;
totale_da_pagare = Math . round ( totale_da_pagare * 100 ) / 100 ;
2017-08-04 16:28:16 +02:00
2020-10-06 12:29:14 +02:00
let diff = Math . abs ( totale_da_pagare ) - Math . abs ( totale_utente );
2017-08-04 16:28:16 +02:00
2019-07-25 18:05:47 +02:00
if ( diff == 0 ) {
2020-02-23 14:42:25 +01:00
$ ( " #totale " ) . addClass ( " hide " );
2019-07-25 18:05:47 +02:00
} else {
2020-02-23 14:42:25 +01:00
$ ( " #totale " ) . removeClass ( " hide " );
2019-07-25 18:05:47 +02:00
}
2017-08-04 16:28:16 +02:00
2020-02-23 14:42:25 +01:00
$ ( " #diff " ) . html ( diff . toLocale ());
$ ( " #totale_utente " ) . html ( totale_utente . toLocale ());
2019-07-25 18:05:47 +02:00
}
2020-02-23 14:42:25 +01:00
</ script > ' ;
}