2017-08-04 16:28:16 +02:00
< ? php
include_once __DIR__ . '/../../core.php' ;
$module = Modules :: getModule ( $id_module );
if ( $module [ 'name' ] == 'Ddt di vendita' ) {
$dir = 'entrata' ;
} else {
$dir = 'uscita' ;
}
?>
< form action = " " method = " post " role = " form " >
< input type = " hidden " name = " backto " value = " record-edit " >
< input type = " hidden " name = " op " value = " update " >
< input type = " hidden " name = " id_record " value = " <?php echo $id_record ?> " >
<!-- INTESTAZIONE -->
< div class = " panel panel-primary " >
< div class = " panel-heading " >
2017-09-04 12:02:29 +02:00
< h3 class = " panel-title " >< ? php echo tr ( 'Intestazione' ); ?> </h3>
2017-08-04 16:28:16 +02:00
</ div >
< div class = " panel-body " >
< div class = " pull-right " >
2017-09-04 12:02:29 +02:00
< button type = " submit " class = " btn btn-success " >< i class = " fa fa-check " ></ i > < ? php echo tr ( 'Salva modifiche' ); ?> </button>
2017-08-04 16:28:16 +02:00
</ div >
< div class = " clearfix " ></ div >
< div class = " row " >
< ? php
if ( $dir == 'uscita' ) {
echo '
< div class = " col-md-3 " >
2017-09-14 10:27:49 +02:00
{[ " type " : " span " , " label " : " '.tr('Numero ddt').' " , " class " : " text-center " , " value " : " $numero $ " ]}
2017-08-04 16:28:16 +02:00
</ div > ' ;
}
?>
< div class = " col-md-3 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " text " , " label " : " <?php echo tr('Numero secondario'); ?> " , " name " : " numero_esterno " , " class " : " text-center " , " value " : " $numero_esterno $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-3 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " date " , " label " : " <?php echo tr('Data'); ?> " , " maxlength " : 10 , " name " : " data " , " required " : 1 , " value " : " $data $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-3 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Stato'); ?> " , " name " : " idstatoddt " , " required " : 1 , " values " : " query=SELECT * FROM dt_statiddt " , " value " : " $idstatoddt $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
< div class = " row " >
< div class = " col-md-3 " >
< ? php
if ( $dir == 'entrata' ) {
?>
2017-09-04 12:02:29 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Cliente'); ?> " , " name " : " idanagrafica " , " required " : 1 , " value " : " $idanagrafica $ " , " ajax-source " : " clienti " ]}
2017-08-04 16:28:16 +02:00
< ? php
} else {
?>
2017-09-04 12:02:29 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Fornitore'); ?> " , " name " : " idanagrafica " , " required " : 1 , " value " : " $idanagrafica $ " , " ajax-source " : " fornitori " ]}
2017-08-04 16:28:16 +02:00
< ? php
}
?>
</ div >
< div class = " col-md-3 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Destinazione merce'); ?> " , " name " : " idsede " , " values " : " query=SELECT id, CONCAT_WS(', ', nomesede, citta) AS descrizione FROM an_sedi WHERE (idanagrafica='<php echo $idanagrafica ; ?>' OR idanagrafica=(SELECT valore FROM zz_settings WHERE nome='Azienda predefinita')) UNION SELECT '0' AS id, 'Sede legale' AS descrizione ORDER BY descrizione " , " value " : " $idsede $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
< hr >
< div class = " row " >
< div class = " col-md-3 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Aspetto beni'); ?> " , " name " : " idaspettobeni " , " placeholder " : " - " , " values " : " query=SELECT id, descrizione FROM dt_aspettobeni ORDER BY descrizione ASC " , " value " : " $idaspettobeni $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-3 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Causale trasporto'); ?> " , " name " : " idcausalet " , " placeholder " : " - " , " values " : " query=SELECT id, descrizione FROM dt_causalet ORDER BY descrizione ASC " , " value " : " $idcausalet $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-3 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Porto'); ?> " , " name " : " idporto " , " placeholder " : " - " , " values " : " query=SELECT id, descrizione FROM dt_porto ORDER BY descrizione ASC " , " value " : " $idporto $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-3 " >
2017-09-14 10:27:49 +02:00
{[ " type " : " text " , " label " : " <?php echo tr('Num. colli'); ?> " , " name " : " n_colli " , " value " : " $n_colli $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
< div class = " row " >
< div class = " col-md-3 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Pagamento'); ?> " , " name " : " idpagamento " , " values " : " query=SELECT id, descrizione FROM co_pagamenti GROUP BY descrizione ORDER BY descrizione ASC " , " value " : " $idpagamento $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-3 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Tipo di spedizione'); ?> " , " name " : " idspedizione " , " placeholder " : " - " , " values " : " query=SELECT id, descrizione FROM dt_spedizione ORDER BY descrizione ASC " , " value " : " $idspedizione $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-3 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Vettore'); ?> " , " name " : " idvettore " , " values " : " query=SELECT DISTINCT an_anagrafiche.idanagrafica AS id, an_anagrafiche.ragione_sociale AS descrizione FROM an_anagrafiche INNER JOIN an_tipianagrafiche_anagrafiche ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica WHERE an_tipianagrafiche_anagrafiche.idtipoanagrafica=(SELECT idtipoanagrafica FROM an_tipianagrafiche WHERE descrizione='Vettore') ORDER BY descrizione ASC " , " value " : " $idvettore $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
< div class = " row " >
< div class = " col-md-3 " >
2017-09-19 16:20:44 +02:00
{[ " type " : " number " , " label " : " <?php echo tr('Sconto incondizionato') ?> " , " name " : " sconto_generico " , " value " : " $sconto_globale $ " , " icon-after " : " choice|untprc| $tipo_sconto_globale $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
< div class = " row " >
< div class = " col-md-12 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " textarea " , " label " : " <?php echo tr('Note'); ?> " , " name " : " note " , " value " : " $note $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
< div class = " pull-right " >
2017-09-04 12:02:29 +02:00
< button type = " submit " class = " btn btn-success " >< i class = " fa fa-check " ></ i > < ? php echo tr ( 'Salva modifiche' ); ?> </button>
2017-08-04 16:28:16 +02:00
</ div >
</ div >
</ div >
</ form >
<!-- RIGHE -->
< div class = " panel panel-primary " >
< div class = " panel-heading " >
2017-09-04 12:02:29 +02:00
< h3 class = " panel-title " >< ? php echo tr ( 'Righe' ); ?> </h3>
2017-08-04 16:28:16 +02:00
</ div >
< div class = " panel-body " >
< div class = " pull-left " >
< ? php
if ( $records [ 0 ][ 'stato' ] != 'Evaso' ) {
?>
< a class = " btn btn-sm btn-primary " data - href = " <?php echo $rootdir ?>/modules/ddt/add_articolo.php?id_module=<?php echo $id_module ?>&id_record=<?php echo $id_record ?>&dir=<?php echo $dir ?> " data - toggle = " modal " data - title = " Aggiungi articolo " data - target = " #bs-popup " >
2017-09-04 12:02:29 +02:00
< i class = " fa fa-plus " ></ i > < ? php echo tr ( 'Articolo' ); ?>
2017-08-04 16:28:16 +02:00
</ a >
< a class = " btn btn-sm btn-primary " data - href = " <?php echo $rootdir ?>/modules/ddt/add_riga.php?id_module=<?php echo $id_module ?>&id_record=<?php echo $id_record ?>&dir=<?php echo $dir ?> " data - toggle = " modal " data - title = " Aggiungi riga " data - target = " #bs-popup " >
2017-09-04 12:02:29 +02:00
< i class = " fa fa-plus " ></ i > < ? php echo tr ( 'Riga generica' ); ?>
2017-08-04 16:28:16 +02:00
</ a >
< ? php
}
?>
</ div >
< div class = " pull-right " >
<!-- Stampe -->
< ? php
if ( $records [ 0 ][ 'stato' ] != 'Evaso' ) {
?>
2017-09-05 17:31:58 +02:00
< a class = " btn btn-sm btn-info " data - href = " <?php echo $rootdir ?>/modules/fatture/crea_documento.php?id_module=<?php echo $id_module ?>&id_record=<?php echo $id_record ?>&documento=fattura " data - toggle = " modal " data - title = " Crea fattura " data - target = " #bs-popup " >
2017-09-04 12:02:29 +02:00
< i class = " fa fa-magic " ></ i > < ? php echo tr ( 'Crea fattura da ddt' ); ?> ...</i>
2017-08-04 16:28:16 +02:00
</ a >
< ? php
}
2017-09-21 17:48:41 +02:00
echo Prints :: getDropdown ( $id_module , $id_record );
?>
2017-08-04 16:28:16 +02:00
</ div >
< div class = " clearfix " ></ div >
< br >
< div class = " row " >
< div class = " col-md-12 " >
< ? php
include $docroot . '/modules/ddt/row-list.php' ;
?>
</ div >
</ div >
</ div >
</ div >
< script >
$ ( '#idanagrafica' ) . change ( function (){
session_set ( 'superselect,idanagrafica' , $ ( this ) . val (), 0 );
$ ( " #idsede " ) . selectReset ();
});
</ script >
< a class = " btn btn-danger ask " data - backto = " record-list " >
2017-09-04 12:02:29 +02:00
< i class = " fa fa-trash " ></ i > < ? php echo tr ( 'Elimina' ); ?>
2017-08-04 16:28:16 +02:00
</ a >
2017-09-14 10:27:49 +02:00
< ? php
2017-09-15 09:48:56 +02:00
$fatture = $dbo -> fetchArray ( 'SELECT `co_documenti`.*, `co_tipidocumento`.`descrizione` AS tipo_documento, `co_tipidocumento`.`dir` FROM `co_documenti` JOIN `co_tipidocumento` ON `co_tipidocumento`.`id` = `co_documenti`.`idtipodocumento` WHERE `co_documenti`.`id` IN (SELECT `iddocumento` FROM `co_righe_documenti` WHERE `idddt` = ' . prepare ( $id_record ) . ') ORDER BY `data`' );
2017-09-14 10:27:49 +02:00
if ( ! empty ( $fatture )) {
echo '
< div class = " alert alert-danger " >
< p > '.tr(' Ci sono _NUM_ documenti collegate a questo elemento ' , [
'_NUM_' => count ( $fatture ),
]) . ' .</ p >
< ul > ' ;
foreach ( $fatture as $fattura ) {
$descrizione = tr ( '_DOC_ num. _NUM_ del _DATE_' , [
'_DOC_' => $fattura [ 'tipo_documento' ],
'_NUM_' => ! empty ( $fattura [ 'numero_esterno' ]) ? $fattura [ 'numero_esterno' ] : $fattura [ 'numero' ],
'_DATE_' => Translator :: dateToLocale ( $fattura [ 'data' ]),
]);
$modulo = ( $fattura [ 'dir' ] == 'entrata' ) ? 'Fatture di vendita' : 'Fatture di acquisto' ;
$id = $fattura [ 'id' ];
echo '
< li > '.Modules::link($modulo, $id, $descrizione).' </ li > ' ;
}
echo '
</ ul >
< p > '.tr(' Eliminando questo elemento si potrebbero verificare problemi nelle altre sezioni del gestionale ! ').' </ p >
</ div > ' ;
}