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' ;
}
2018-02-23 16:04:50 +01:00
?> <form action="" method="post" id="edit-form">
2017-08-04 16:28:16 +02:00
< input type = " hidden " name = " backto " value = " record-edit " >
< input type = " hidden " name = " op " value = " update " >
2018-02-18 19:53:23 +01:00
< input type = " hidden " name = " id_record " value = " <?php echo $id_record ; ?> " >
2017-08-04 16:28:16 +02:00
<!-- 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 " >
2018-07-18 15:20:10 +02:00
{[ " type " : " text " , " label " : " <?php echo tr('Numero ordine'); ?> " , " name " : " numero " , " required " : 1 , " class " : " text-center " , " value " : " $numero $ " , " readonly " : " <?php echo $record['flag_completato'] ; ?> " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-3 " >
2018-07-18 15:20:10 +02:00
{[ " type " : " text " , " label " : " <?php echo tr('Numero secondario'); ?> " , " name " : " numero_esterno " , " class " : " text-center " , " value " : " $numero_esterno $ " , " readonly " : " <?php echo $record['flag_completato'] ; ?> " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-3 " >
2018-11-09 11:34:27 +01:00
{[ " type " : " date " , " label " : " <?php echo tr('Data'); ?> " , " name " : " data " , " required " : 1 , " value " : " $data $ " , " readonly " : " <?php echo $record['flag_completato'] ; ?> " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-3 " >
2018-05-22 14:41:42 +02:00
< ? php
2018-07-08 18:11:17 +02:00
if ( setting ( 'Cambia automaticamente stato ordini fatturati' )) {
2018-07-18 15:20:10 +02:00
if ( $record [ 'stato' ] == 'Evaso' || $record [ 'stato' ] == 'Parzialmente evaso' || $record [ 'stato' ] == 'Fatturato' || $record [ 'stato' ] == 'Parzialmente fatturato' ) {
2018-06-26 14:30:26 +02:00
?>
2018-05-22 14:41:42 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Stato'); ?> " , " name " : " idstatoordine " , " required " : 1 , " values " : " query=SELECT * FROM or_statiordine " , " value " : " $idstatoordine $ " , " extra " : " readonly " ]}
2018-06-26 14:30:26 +02:00
< ? php
} else {
?>
2018-05-22 14:41:42 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Stato'); ?> " , " name " : " idstatoordine " , " required " : 1 , " values " : " query=SELECT * FROM or_statiordine WHERE descrizione IN('Bozza') " , " value " : " $idstatoordine $ " ]}
< ? php
}
2018-06-26 14:30:26 +02:00
} else {
?>
2018-05-22 14:41:42 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Stato'); ?> " , " name " : " idstatoordine " , " required " : 1 , " values " : " query=SELECT * FROM or_statiordine " , " value " : " $idstatoordine $ " ]}
< ? php
}
?>
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
2018-07-18 15:20:10 +02:00
echo Modules :: link ( 'Anagrafiche' , $record [ 'idanagrafica' ], null , null , 'class="pull-right"' );
2018-01-15 20:28:36 +01:00
2017-09-14 10:27:49 +02:00
if ( $dir == 'entrata' ) {
2018-02-04 17:26:25 +01:00
?>
2018-07-18 15:20:10 +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_at IS NULL ORDER BY ragione_sociale " , " value " : " $idanagrafica $ " , " ajax-source " : " clienti " , " readonly " : " <?php echo $record['flag_completato'] ; ?> " ]}
2017-08-04 16:28:16 +02:00
< ? php
2017-09-14 10:27:49 +02:00
} else {
?>
2018-07-18 15:20:10 +02:00
{[ " 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_at IS NULL ORDER BY ragione_sociale " , " value " : " $idanagrafica $ " , " readonly " : " <?php echo $record['flag_completato'] ; ?> " ]}
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 >
2019-01-29 13:13:24 +01:00
< div class = " col-md-3 " >
{[ " type " : " select " , " label " : " <?php echo tr('Sede'); ?> " , " name " : " idsede " , " required " : 1 , " ajax-source " : " sedi " , " value " : " <?php echo $record['idsede'] ; ?> " , " readonly " : " <?php echo $record['flag_completato'] ; ?> " ]}
</ div >
2017-08-04 16:28:16 +02:00
< div class = " col-md-3 " >
2018-07-18 15:20:10 +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 $ " , " readonly " : " <?php echo $record['flag_completato'] ; ?> " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
< div class = " row " >
< div class = " col-md-3 " >
2018-07-18 15:20:10 +02:00
{[ " type " : " number " , " label " : " <?php echo tr('Sconto incondizionato'); ?> " , " name " : " sconto_generico " , " value " : " $sconto_globale $ " , " icon-after " : " choice|untprc| $tipo_sconto_globale $ " , " readonly " : " <?php echo $record['flag_completato'] ; ?> " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
< div class = " row " >
< div class = " col-md-12 " >
2018-07-18 15:20:10 +02:00
{[ " type " : " textarea " , " label " : " <?php echo tr('Note'); ?> " , " name " : " note " , " value " : " $note $ " , " readonly " : " <?php echo $record['flag_completato'] ; ?> " ]}
2018-05-22 14:41:42 +02:00
</ div >
</ div >
2018-07-08 18:11:17 +02:00
2018-05-22 14:41:42 +02:00
< div class = " row " >
< div class = " col-md-12 " >
2018-11-23 12:43:45 +01:00
{[ " type " : " textarea " , " label " : " <?php echo tr('Note aggiuntive'); ?> " , " name " : " note_aggiuntive " , " help " : " <?php echo tr('Note interne'); ?> " , " value " : " $note_aggiuntive $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
</ div >
</ div >
2018-11-23 12:43:45 +01:00
<!-- Fatturazione Elettronica PA -->
2019-01-22 17:16:17 +01:00
< div class = " panel panel-primary <?php echo ( $dir == 'entrata' && $record['tipo_anagrafica'] == 'Ente pubblico' or ( $record['tipo_anagrafica'] ) == 'Azienda') ? 'show' : 'hide'; ?> " >
2018-11-23 12:43:45 +01:00
< div class = " panel-heading " >
< h3 class = " panel-title " >< ? php echo tr ( 'Dati appalto' ); ?> </h3>
</ div >
2017-08-04 16:28:16 +02:00
2018-11-23 12:43:45 +01:00
< div class = " panel-body " >
< div class = " row " >
< div class = " col-md-4 " >
{[ " type " : " text " , " label " : " <?php echo tr('Identificatore Documento'); ?> " , " name " : " id_documento_fe " , " required " : 0 , " value " : " $id_documento_fe $ " , " maxlength " : 20 , " readonly " : " <?php echo $record['flag_completato'] ; ?> " ]}
</ div >
< div class = " col-md-4 " >
{[ " type " : " text " , " label " : " <?php echo tr('Codice CIG'); ?> " , " name " : " codice_cig " , " required " : 0 , " value " : " $codice_cig $ " , " maxlength " : 15 , " readonly " : " <?php echo $record['flag_completato'] ; ?> " ]}
</ div >
< div class = " col-md-4 " >
{[ " type " : " text " , " label " : " <?php echo tr('Codice CUP'); ?> " , " name " : " codice_cup " , " required " : 0 , " value " : " $codice_cup $ " , " maxlength " : 15 , " readonly " : " <?php echo $record['flag_completato'] ; ?> " ]}
</ div >
</ div >
</ div >
</ div >
</ form >
2017-08-04 16:28:16 +02:00
<!-- 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 " >
2018-07-08 18:11:17 +02:00
< ? php
2018-05-19 00:50:06 +02:00
2018-07-18 15:20:10 +02:00
if ( $record [ 'flag_completato' ] == 0 ) {
2018-06-26 14:30:26 +02:00
?>
2018-10-25 17:11:02 +02:00
< a class = " btn btn-primary " data - href = " <?php echo $rootdir ; ?>/modules/ordini/row-add.php?id_module=<?php echo $id_module ; ?>&id_record=<?php echo $id_record ; ?>&is_articolo " data - toggle = " modal " data - title = " Aggiungi articolo " >< i class = " fa fa-plus " ></ i > < ? php echo tr ( 'Articolo' ); ?> </a>
2018-02-19 11:50:42 +01:00
2018-10-25 17:11:02 +02:00
< a class = " btn btn-primary " data - href = " <?php echo $rootdir ; ?>/modules/ordini/row-add.php?id_module=<?php echo $id_module ; ?>&id_record=<?php echo $id_record ; ?>&is_riga " data - toggle = " modal " data - title = " Aggiungi riga " >< i class = " fa fa-plus " ></ i > < ? php echo tr ( 'Riga' ); ?> </a>
2018-02-19 11:50:42 +01:00
2018-10-25 17:11:02 +02:00
< a class = " btn btn-primary " data - href = " <?php echo $rootdir ; ?>/modules/ordini/row-add.php?id_module=<?php echo $id_module ; ?>&id_record=<?php echo $id_record ; ?>&is_descrizione " data - toggle = " modal " data - title = " Aggiungi descrizione " >< i class = " fa fa-plus " ></ i > < ? php echo tr ( 'Descrizione' ); ?> </a>
2017-09-14 10:27:49 +02:00
< ? php
2018-06-26 14:30:26 +02:00
}
2017-08-04 16:28:16 +02:00
2018-02-04 17:26:25 +01: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 >
2018-09-28 16:17:10 +02:00
{( " name " : " filelist_and_upload " , " id_module " : " $id_module $ " , " id_record " : " $id_record $ " )}
{( " name " : " log_email " , " id_module " : " $id_module $ " , " id_record " : " $id_record $ " )}
2017-09-14 10:27:49 +02:00
< ? php
2018-09-05 10:05:23 +02:00
// Collegamenti diretti
// Fatture o ddt collegati a questo ordine
$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 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 '
2018-09-05 10:05:23 +02:00
< div class = " box box-warning collapsable collapsed-box " >
< div class = " box-header with-border " >
< h3 class = " box-title " >< i class = " fa fa-warning " ></ i > '.tr(' Documenti collegati : _NUM_ ' , [
2018-09-19 09:57:30 +02:00
'_NUM_' => count ( $elementi ),
2018-09-05 10:05:23 +02:00
]) . ' </ h3 >
< div class = " box-tools pull-right " >
< button type = " button " class = " btn btn-box-tool " data - widget = " collapse " >< i class = " fa fa-plus " ></ i ></ button >
</ div >
</ div >
< div class = " box-body " >
< ul > ' ;
2017-09-14 10:27:49 +02:00
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' ]),
]);
2019-02-11 19:18:17 +01:00
if ( ! in_array ( $elemento [ 'tipo_documento' ], [ 'Ddt in uscita' , 'Ddt in entrata' ])) {
2017-09-14 10:27:49 +02:00
$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 '
2018-09-05 10:05:23 +02:00
< li > '.Modules::link($modulo, $id, $descrizione).' </ li > ' ;
2017-09-14 10:27:49 +02:00
}
echo '
</ ul >
2018-09-05 10:05:23 +02:00
</ div >
</ div > ' ;
}
if ( ! empty ( $elementi )) {
echo '
< div class = " alert alert-error " >
'.tr(' Eliminando questo documento si potrebbero verificare problemi nelle altre sezioni del gestionale ').' .
</ div > ' ;
2017-09-14 10:27:49 +02:00
}
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 >
2018-05-22 14:41:42 +02:00
< script >
< ? php
2018-07-18 15:20:10 +02:00
if ( $record [ 'flag_completato' ]) {
2018-06-26 14:30:26 +02:00
?>
2018-05-22 14:41:42 +02:00
$ ( '#tipo_sconto_generico' ) . prop ( 'disabled' , true );
< ? php
}
?>
2019-01-29 13:13:24 +01:00
$ ( '#idanagrafica' ) . change ( function (){
session_set ( 'superselect,idanagrafica' , $ ( this ) . val (), 0 );
$ ( " #idsede " ) . selectReset ();
});
2018-05-22 14:41:42 +02:00
</ script >