2017-08-04 16:28:16 +02:00
< ? php
include_once __DIR__ . '/../../core.php' ;
2017-09-22 15:19:59 +02:00
$module = Modules :: get ( $id_module );
2017-08-04 16:28:16 +02:00
if ( $module [ 'name' ] == 'Ordini cliente' ) {
$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 " >
< h3 class = " panel-title " > Intestazione </ h3 >
</ div >
< div class = " panel-body " >
< div class = " row " >
< div class = " col-md-3 " >
2017-09-14 10:27:49 +02:00
{[ " type " : " text " , " label " : " <?php echo tr('Numero ordine'); ?> " , " name " : " numero " , " required " : 1 , " class " : " text-center " , " value " : " $numero $ " ]}
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('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-14 10:27:49 +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-14 10:27:49 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Stato'); ?> " , " name " : " idstatoordine " , " required " : 1 , " values " : " query=SELECT * FROM or_statiordine " , " value " : " $idstatoordine $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
< div class = " row " >
< div class = " col-md-3 " >
2018-01-15 20:28:36 +01:00
< ? php
echo Modules :: link ( 'Anagrafiche' , $records [ 0 ][ 'idanagrafica' ], null , null , 'class="pull-right"' );
2017-09-14 10:27:49 +02:00
if ( $dir == 'entrata' ) {
2018-01-15 20:28:36 +01:00
?>
2017-09-14 10:27:49 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Cliente'); ?> " , " name " : " idanagrafica " , " required " : 1 , " values " : " query=SELECT an_anagrafiche.idanagrafica AS id, ragione_sociale AS descrizione FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica WHERE descrizione='Cliente' AND deleted=0 ORDER BY ragione_sociale " , " value " : " $idanagrafica $ " , " ajax-source " : " clienti " ]}
2017-08-04 16:28:16 +02:00
< ? php
2017-09-14 10:27:49 +02:00
} else {
?>
{[ " type " : " select " , " label " : " <?php echo tr('Fornitore'); ?> " , " name " : " idanagrafica " , " required " : 1 , " values " : " query=SELECT an_anagrafiche.idanagrafica AS id, ragione_sociale AS descrizione FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica WHERE descrizione='Fornitore' AND deleted=0 ORDER BY ragione_sociale " , " value " : " $idanagrafica $ " ]}
2017-08-04 16:28:16 +02:00
< ? php
2017-09-14 10:27:49 +02:00
}
?>
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-3 " >
2017-09-14 10:27:49 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Pagamento'); ?> " , " name " : " idpagamento " , " required " : 1 , " 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 >
< 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-14 10:27:49 +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 " >
< h3 class = " panel-title " > Righe </ h3 >
</ div >
< div class = " panel-body " >
< div class = " pull-left " >
2017-09-14 10:27:49 +02:00
< ? php if ( $records [ 0 ][ 'stato' ] != 'Evaso' ) {
?>
2017-08-04 16:28:16 +02:00
< a class = " btn btn-sm btn-primary " data - href = " <?php echo $rootdir ?>/modules/ordini/add_articolo.php?id_module=<?php echo $id_module ?>&id_record=<?php echo $id_record ?> " data - toggle = " modal " data - title = " Aggiungi articolo " data - target = " #bs-popup " >< i class = " fa fa-plus " ></ i > Articolo </ a >
< a class = " btn btn-sm btn-primary " data - href = " <?php echo $rootdir ?>/modules/ordini/add_riga.php?id_module=<?php echo $id_module ?>&id_record=<?php echo $id_record ?> " data - toggle = " modal " data - title = " Aggiungi riga " data - target = " #bs-popup " >< i class = " fa fa-plus " ></ i > Riga generica </ a >
2018-01-18 19:03:06 +01:00
< a class = " btn btn-sm btn-primary " data - href = " <?php echo $rootdir ?>/modules/ordini/add_descrizione.php?id_module=<?php echo $id_module ?>&id_record=<?php echo $id_record ?> " data - toggle = " modal " data - title = " Aggiungi descrizione " data - target = " #bs-popup " >< i class = " fa fa-plus " ></ i > Descrizione </ a >
2017-09-14 10:27:49 +02:00
< ? php
} ?>
2017-08-04 16:28:16 +02:00
</ div >
< div class = " pull-right " >
<!-- Stampe -->
2017-09-14 10:27:49 +02:00
< ? 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=ddt " data - toggle = " modal " data - title = " Crea ddt " data - target = " #bs-popup " >< i class = " fa fa-magic " ></ i > Crea ddt da ordine ...</ i ></ a >
< 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 " >< i class = " fa fa-magic " ></ i > Crea fattura da ordine ...</ i ></ a >
2017-09-14 10:27:49 +02:00
< ? php
2017-09-21 17:48:41 +02:00
}
echo Prints :: getDropdown ( $id_module , $id_record );
2017-08-04 16:28:16 +02:00
2017-09-21 17:48:41 +02:00
?>
2017-08-04 16:28:16 +02:00
</ div >
< div class = " clearfix " ></ div >
< br >
< div class = " row " >
< div class = " col-md-12 " >
2017-09-14 10:27:49 +02:00
< ? php include $docroot . '/modules/ordini/row-list.php' ; ?>
2017-08-04 16:28:16 +02:00
</ div >
</ div >
</ div >
</ div >
2017-11-15 19:32:23 +01:00
{( " name " : " filelist_and_upload " , " id_module " : " <?php echo $id_module ?> " , " id_record " : " <?php echo $id_record ?> " )}
2017-09-14 10:27:49 +02:00
< ? php
2017-11-16 14:27:43 +01:00
//fatture o ddt collegati a questo ordine
2017-09-18 18:11:19 +02:00
$elementi = $dbo -> fetchArray ( 'SELECT `co_documenti`.`id`, `co_documenti`.`data`, `co_documenti`.`numero`, `co_documenti`.`numero_esterno`, `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 `idordine` = ' . prepare ( $id_record ) . ' ) UNION
2017-09-15 09:48:56 +02:00
SELECT `dt_ddt` . `id` , `dt_ddt` . `data` , `dt_ddt` . `numero` , `dt_ddt` . `numero_esterno` , `dt_tipiddt` . `descrizione` AS tipo_documento , `dt_tipiddt` . `dir` FROM `dt_ddt` JOIN `dt_tipiddt` ON `dt_tipiddt` . `id` = `dt_ddt` . `idtipoddt` WHERE `dt_ddt` . `id` IN ( SELECT `idddt` FROM `dt_righe_ddt` WHERE `idordine` = '.prepare($id_record).' ) ORDER BY `data` ' );
2017-09-14 10:27:49 +02:00
if ( ! empty ( $elementi )) {
echo '
2017-11-16 14:27:43 +01:00
< div class = " alert alert-warning " >
< p > '.tr(' _NUM_ altr_I_ document_I_ collegat_I_ ' , [
2017-09-14 10:27:49 +02:00
'_NUM_' => count ( $elementi ),
2017-11-16 14:27:43 +01:00
'_I_' => ( count ( $elementi ) > 1 ) ? tr ( 'i' ) : tr ( 'o' )
]) . ' :</ p >
2017-09-14 10:27:49 +02:00
< ul > ' ;
foreach ( $elementi as $elemento ) {
$descrizione = tr ( '_DOC_ num. _NUM_ del _DATE_' , [
'_DOC_' => $elemento [ 'tipo_documento' ],
'_NUM_' => ! empty ( $elemento [ 'numero_esterno' ]) ? $elemento [ 'numero_esterno' ] : $elemento [ 'numero' ],
'_DATE_' => Translator :: dateToLocale ( $elemento [ 'data' ]),
]);
if ( ! in_array ( $elemento [ 'tipo_documento' ], [ 'Ddt di vendita' , 'Ddt di acquisto' ])) {
$modulo = ( $elemento [ 'dir' ] == 'entrata' ) ? 'Fatture di vendita' : 'Fatture di acquisto' ;
} else {
$modulo = ( $elemento [ 'dir' ] == 'entrata' ) ? 'Ddt di vendita' : 'Ddt di acquisto' ;
}
$id = $elemento [ 'id' ];
echo '
< li > '.Modules::link($modulo, $id, $descrizione).' </ li > ' ;
}
echo '
</ ul >
2017-11-16 14:27:43 +01:00
< p > '.tr(' Eliminando questo documento si potrebbero verificare problemi nelle altre sezioni del gestionale . ').' </ p >
2017-09-14 10:27:49 +02:00
</ div > ' ;
}
2017-11-16 14:27:43 +01:00
?>
< a class = " btn btn-danger ask " data - backto = " record-list " >
< i class = " fa fa-trash " ></ i > < ? php echo tr ( 'Elimina' ); ?>
</ a >