2018-02-22 11:07:52 +01:00
< ? php
include_once __DIR__ . '/../../core.php' ;
echo '
< form action = " " class = " text-right " method = " post " id = " form-copy " >
< input type = " hidden " name = " backto " value = " record-edit " >
< input type = " hidden " name = " op " value = " copy " >
</ form >
2019-04-04 16:34:06 +02:00
< button type = " button " class = " btn btn-primary " '.((empty($record[' ref_documento ']) and empty($record[' reversed '])) ? ' ' : ' disabled ').' onclick = " if( confirm( \ 'Duplicare questa fattura? \ ') ) { $ ( \ '#form-copy \ ').submit(); } " >
2018-02-22 11:07:52 +01:00
< i class = " fa fa-copy " ></ i > '.tr(' Duplica fattura ').'
</ button > ' ;
2018-07-03 17:28:02 +02:00
2019-02-14 17:49:58 +01:00
if ( $dir == 'entrata' ) {
2018-07-03 17:28:02 +02:00
echo '
< div class = " btn-group " >
2019-04-04 17:30:58 +02:00
< button type = " button " class = " btn btn-primary unblockable dropdown-toggle '.(((!empty( $record['ref_documento'] ) || $record['stato'] != 'Bozza') and empty( $record['reversed'] )) ? '' : 'disabled').' " data - toggle = " dropdown " aria - haspopup = " true " aria - expanded = " false " >
2018-07-03 17:28:02 +02:00
< i class = " fa fa-magic " ></ i > '.tr(' Crea ').' < span class = " caret " ></ span >
< span class = " sr-only " > Toggle Dropdown </ span >
</ button >
< ul class = " dropdown-menu dropdown-menu-right " >
< li >< a href = " '. $rootdir .'/editor.php?id_module='. $id_module .'&id_record='. $id_record .'&op=nota_addebito&backto=record-edit " >
2018-07-05 17:56:38 +02:00
'.tr(' Nota di debito ').'
2018-07-03 17:28:02 +02:00
</ a ></ li >
2018-10-25 17:11:02 +02:00
< li >< a data - href = " '. $rootdir .'/modules/fatture/crea_documento.php?id_module='. $id_module .'&id_record='. $id_record .'&iddocumento='. $id_record .' " data - title = " Aggiungi nota di credito " >
2018-07-05 17:56:38 +02:00
'.tr(' Nota di credito ').'
2018-07-03 17:28:02 +02:00
</ a ></ li >
</ ul >
</ div > ' ;
}
2018-09-28 09:30:46 +02:00
if ( empty ( $record [ 'is_fiscale' ])) {
$msg = '{[ "type": "select", "label": "' . tr ( 'Sezionale' ) . '", "name": "id_segment", "required": 1, "values": "query=SELECT id, name AS descrizione FROM zz_segments WHERE id_module=\'' . $id_module . '\' AND is_fiscale = 1 ORDER BY name" ]}' ;
echo '
< button type = " button " class = " btn btn-warning ask " data - msg = " '.tr('Vuoi trasformare questa fattura pro-forma in una di tipo fiscale?').'<br>'.prepareToField( \ HTMLBuilder \ HTMLBuilder::replace( $msg )).' " data - op = " transform " data - button = " '.tr('Trasforma').' " data - class = " btn btn-lg btn-warning " data - backto = " record-edit " >
< i class = " fa fa-upload " ></ i > '.tr(' Trasforma in fattura fiscale ').'
</ button > ' ;
}
2019-02-26 11:01:35 +01:00
?>
< ? php
if ( ! empty ( $record [ 'is_fiscale' ])) {
2019-04-11 16:04:08 +02:00
//Aggiunta insoluto
if ( ! empty ( $record [ 'riba' ]) && ( $record [ 'stato' ] == 'Emessa' || $record [ 'stato' ] == 'Parzialmente pagato' || $record [ 'stato' ] == 'Pagato' ) && $dir == 'entrata' ) {
2019-04-12 01:11:32 +02:00
?>
2019-04-11 16:04:08 +02:00
< button type = " button " class = " btn btn-primary " onclick = " launch_modal( '<?php echo tr('Registra insoluto'); ?>', '<?php echo $rootdir ; ?>/add.php?id_module=<?php echo Modules::get('Prima nota')['id']; ?>&iddocumento=<?php echo $id_record ; ?>&dir=<?php echo $dir ; ?>&insoluto=1', 1 ); " >< i class = " fa fa-euro " ></ i > < ? php echo tr ( 'Registra insoluto' ); ?> ...</button>
< ? php
}
2019-02-26 11:01:35 +01:00
// Aggiunta prima nota solo se non c'è già, se non si è in bozza o se il pagamento non è completo
$n2 = $dbo -> fetchNum ( 'SELECT id FROM co_movimenti WHERE iddocumento=' . prepare ( $id_record ) . ' AND primanota=1' );
$rs3 = $dbo -> fetchArray ( 'SELECT SUM(da_pagare-pagato) AS differenza, SUM(da_pagare) FROM co_scadenziario GROUP BY iddocumento HAVING iddocumento=' . prepare ( $id_record ));
$differenza = isset ( $rs3 [ 0 ]) ? $rs3 [ 0 ][ 'differenza' ] : null ;
$da_pagare = isset ( $rs3 [ 0 ]) ? $rs3 [ 0 ][ 'da_pagare' ] : null ;
if (( $n2 <= 0 && $record [ 'stato' ] == 'Emessa' ) || $differenza != 0 ) {
2019-03-08 15:18:52 +01:00
?>
2019-04-18 11:11:02 +02:00
< button type = " button " class = " btn btn-primary <?php echo (!empty(Modules::get('Prima nota'))) ? '' : 'disabled'; ?> " onclick = " launch_modal( '<?php echo tr('Aggiungi prima nota'); ?>', '<?php echo $rootdir ; ?>/add.php?id_module=<?php echo Modules::get('Prima nota')['id']; ?>&iddocumento=<?php echo $id_record ; ?>&dir=<?php echo $dir ; ?>', 1 ); " >< small >< i class = " fa fa-euro " ></ i > < ? php echo tr ( 'Registra contabile pagamento' ); ?> ...</small></button>
2019-02-26 11:01:35 +01:00
< ? php
}
if ( $record [ 'stato' ] == 'Pagato' ) {
2019-03-08 15:18:52 +01:00
?>
2019-02-26 11:01:35 +01:00
< button type = " button " class = " btn btn-primary tip " onclick = " if( confirm('<?php echo tr('Se riapri questa fattura verrà azzerato lo scadenzario e la prima nota. Continuare?'); ?>') ) { $ .post( '<?php echo $rootdir ; ?>/editor.php?id_module=<?php echo $id_module ; ?>&id_record=<?php echo $id_record ; ?>', { id_module: '<?php echo $id_module ; ?>', id_record: '<?php echo $id_record ; ?>', op: 'reopen' }, function() { location.href='<?php echo $rootdir ; ?>/editor.php?id_module=<?php echo $id_module ; ?>&id_record=<?php echo $id_record ; ?>'; } ); } " title = " <?php echo tr('Riporta la fattura in stato bozza e ne elimina i movimenti contabili.'); ?> " >< i class = " fa fa-folder-open " ></ i > < ? php echo tr ( 'Riapri fattura' ); ?> ...</button>
< ? php
}
}
?>