2017-08-04 16:28:16 +02:00
< ? php
include_once __DIR__ . '/../../core.php' ;
$_SESSION [ 'superselect' ][ 'id_categoria' ] = $records [ 0 ][ 'id_categoria' ];
?> <form action="" method="post" role="form" enctype="multipart/form-data">
< input type = " hidden " name = " backto " value = " record-edit " >
< input type = " hidden " name = " op " value = " update " >
<!-- DATI ANAGRAFICI -->
< div class = " panel panel-primary " >
< div class = " panel-heading " >
2017-09-04 12:02:29 +02:00
< h3 class = " panel-title " >< ? php echo tr ( 'Articolo' ); ?> </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 " >
< div class = " col-md-3 " >
< ? php
$immagine01 = ( $records [ 0 ][ 'immagine01' ] == '' ) ? '' : $rootdir . '/files/articoli/' . $records [ 0 ][ 'immagine01' ];
?>
2017-09-04 12:02:29 +02:00
{[ " type " : " image " , " label " : " <?php echo tr('Immagine'); ?> " , " name " : " immagine01 " , " class " : " img-thumbnail " , " value " : " <?php echo $immagine01 ?> " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-4 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " text " , " label " : " <?php echo tr('Codice'); ?> " , " name " : " codice " , " required " : 1 , " value " : " $codice $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-5 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Categoria'); ?> " , " name " : " categoria " , " required " : 1 , " value " : " $id_categoria $ " , " ajax-source " : " categorie " ]}
2017-08-04 16:28:16 +02:00
< br >
2017-09-04 12:02:29 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Subcategoria'); ?> " , " name " : " subcategoria " , " value " : " $id_sottocategoria $ " , " ajax-source " : " sottocategorie " ]}
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('Descrizione'); ?> " , " name " : " descrizione " , " required " : 1 , " value " : " $descrizione $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
< div class = " row " >
< div class = " col-md-4 " >
2017-09-05 18:20:02 +02:00
{[ " type " : " number " , " label " : " <?php echo tr('Quantità'); ?> " , " name " : " qta " , " required " : 1 , " value " : " $qta $ " , " readonly " : 1 , " decimals " : " qta|undefined " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-4 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " checkbox " , " label " : " <?php echo tr('Modifica manualmente quantità'); ?> " , " name " : " qta_manuale " , " value " : 0 , " help " : " <?php echo tr('Seleziona per modificare manualmente la quantità'); ?> " , " placeholder " : " <?php echo tr('Quantità manuale'); ?> " ]}
2017-08-04 16:28:16 +02:00
< script type = " text/javascript " >
$ ( '#qta_manuale' ) . click ( function (){
$ ( " #qta " ) . attr ( " readonly " , ! $ ( '#qta_manuale' ) . is ( " :checked " ));
});
</ script >
</ div >
< div class = " col-md-4 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Unità di misura'); ?> " , " name " : " um " , " value " : " $um $ " , " ajax-source " : " misure " , " icon-after " : " add|<?php echo Modules::getModule('Unità di misura')['id'] ?> " ]}
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 " : " number " , " label " : " <?php echo tr('Prezzo di vendita base'); ?> " , " name " : " prezzo_vendita " , " value " : " $prezzo_vendita $ " , " icon-after " : " € " ]}
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('Iva di vendita'); ?> " , " name " : " idiva_vendita " , " values " : " query=SELECT * FROM co_iva ORDER BY descrizione ASC " , " value " : " $idiva_vendita $ " , " valore_predefinito " : " Iva predefinita " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-3 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " checkbox " , " label " : " <?php echo tr( " Seleziona per rendere visibile l 'articolo"); ?>", "name": "attivo", "value": "$attivo$", "help": "", "placeholder": "<?php echo tr(' ATTIVO ' ); ?> " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-3 " >
2017-09-06 11:59:47 +02:00
{[ " type " : " checkbox " , " label " : " <?php echo tr('Abilita serial number'); ?> " , " name " : " abilita_serial " , " value " : " $abilita_serial $ " , " help " : " " , " placeholder " : " <?php echo tr('Abilita serial number in fase di aggiunta articolo in fattura o ddt'); ?> " ]}
2017-08-04 16:28:16 +02:00
</ div >
< ? php
2017-09-06 11:59:47 +02:00
if ( empty ( $records [ 0 ][ 'abilita_serial' ])) {
$plugin = $dbo -> fetchArray ( " SELECT id FROM zz_plugins WHERE name='Serial' " );
2017-08-04 16:28:16 +02:00
2017-09-06 11:59:47 +02:00
echo '
2017-08-04 16:28:16 +02:00
< script >
$ ( " #link-tab_'. $plugin[0] ['id'].' " ) . addClass ( " disabled " );
</ script > ' ;
2017-09-06 11:59:47 +02:00
}
2017-08-04 16:28:16 +02:00
?>
</ div >
< div class = " row " >
< div class = " col-md-4 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " number " , " label " : " <?php echo tr('Prezzo di acquisto'); ?> " , " name " : " prezzo_acquisto " , " value " : " $prezzo_acquisto $ " , " icon-after " : " € " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-4 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " number " , " label " : " <?php echo tr('Soglia minima quantità'); ?> " , " name " : " threshold_qta " , " value " : " $threshold_qta $ " , " decimals " : " qta " ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-4 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " number " , " label " : " <?php echo tr('Giorni di garanzia'); ?> " , " name " : " gg_garanzia " , " decimals " : 0 , " value " : " $gg_garanzia $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
2017-08-31 16:23:26 +02:00
< div class = " row " >
< div class = " col-md-4 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " number " , " label " : " <?php echo tr('Peso lordo'); ?> " , " name " : " peso_lordo " , " value " : " $peso_lordo $ " , " icon-after " : " KG " ]}
2017-08-31 16:23:26 +02:00
</ div >
< div class = " col-md-4 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " number " , " label " : " <?php echo tr('Volume'); ?> " , " name " : " volume " , " value " : " $volume $ " , " icon-after " : " M<sup>3</sup> " ]}
2017-08-31 16:23:26 +02:00
</ div >
</ div >
2017-08-04 16:28:16 +02:00
< 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 >
</ div >
< div class = " panel panel-primary " >
< div class = " panel-heading " >
2017-09-04 12:02:29 +02:00
< h3 class = " panel-title " >< ? php echo tr ( 'Aggiungi informazioni componente personalizzato' ); ?> </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 >
< ? php
/* necesario per funzione \Util\Ini::getList */
include $docroot . '/modules/my_impianti/modutil.php' ;
echo '
< div class = " row " >
< div class = " col-md-4 " >
< div class = " form-group " >
2017-09-04 12:02:29 +02:00
< label for = " componente_filename " > '.tr(' Seleziona un componente ').' :</ label > ' ;
2017-08-04 16:28:16 +02:00
echo "
< select class = \ " form-control superselect \" id= \" componente_filename \" name= \" componente_filename \" onchange= \" $ .post(' " . $rootdir . " /modules/my_impianti/actions.php', { op: 'load_componente', idarticolo: ' " . $id_record . " ', filename: $ (this).find('option:selected').val() }, function(response) { $ ('#info_componente').html( response ); } ); \" > \n " ;
echo '
< option value = " 0 " >- Collega ad un componente -</ option > ' ;
$cmp = \Util\Ini :: getList ( $docroot . '/files/my_impianti/' );
if ( count ( $cmp ) > 0 ) {
for ( $c = 0 ; $c < count ( $cmp ); ++ $c ) {
( $records [ 0 ][ 'componente_filename' ] == $cmp [ $c ][ 0 ]) ? $attr = 'selected="selected"' : $attr = '' ;
echo '
< option value = " '. $cmp[$c] [0]. " \ " $attr > " . $cmp [ $c ][ 1 ] . " </option> \n " ;
}
}
echo '
</ select >
</ div >
</ div >
</ div > ' ;
echo '
< div id = " info_componente " > ' ;
genera_form_componente ( $records [ 0 ][ 'contenuto' ]);
2017-09-06 11:59:47 +02:00
echo '
</ div > ' ;
2017-08-04 16:28:16 +02:00
echo '
</ div >
</ div >
< div class = " panel panel-primary " >
< div class = " panel-heading " >
2017-09-04 12:02:29 +02:00
< h3 class = " panel-title " > '.tr(' Prezzo articolo per listino ').' </ h3 >
2017-08-04 16:28:16 +02:00
</ div >
< div class = " panel-body " > ' ;
$rsl = $dbo -> fetchArray ( 'SELECT * FROM mg_listini ORDER BY id ASC' );
2017-09-06 11:59:47 +02:00
$rsart = $dbo -> fetchArray ( 'SELECT id, prezzo_vendita FROM mg_articoli WHERE id=' . prepare ( $id_record ));
2017-08-04 16:28:16 +02:00
if ( count ( $rsl ) > 0 ) {
echo '
< div class = " row " >
< div class = " col-md-12 col-lg-6 " >
< table class = " table table-striped table-condensed table-bordered " >
< tr >
2017-09-04 12:02:29 +02:00
< th > '.tr(' Listino ').' </ th >
< th > '.tr(' Prezzo di vendita finale ').' </ th >
2017-08-04 16:28:16 +02:00
</ tr > ' ;
// listino base
echo '
< tr >
2017-09-04 12:02:29 +02:00
< td > '.tr(' Base ').' </ td >
2017-08-04 16:28:16 +02:00
< td > '.Translator::numberToLocale($rsart[0][' prezzo_vendita ']).' & euro ; </ td >
</ tr > ' ;
for ( $i = 0 ; $i < count ( $rsl ); ++ $i ) {
echo '
< tr >
< td > '.$rsl[$i][' nome '].' </ td >
< td > '.Translator::numberToLocale($rsart[0][' prezzo_vendita '] + $rsart[0][' prezzo_vendita '] / 100 * $rsl[$i][' prc_guadagno ']).' & euro ; </ td >
</ tr > ' ;
}
echo '
</ table >
</ div >
</ div > ' ;
}
echo '
</ div >
</ div >
< div class = " panel panel-primary " >
< div class = " panel-heading " >
2017-09-04 12:02:29 +02:00
< h3 class = " panel-title " > '.tr(' Questo articolo è presente nei seguenti automezzi ').' :</ h3 >
2017-08-04 16:28:16 +02:00
</ div >
< div class = " panel-body " > ' ;
// Quantità nell'automezzo
2017-09-06 11:59:47 +02:00
$rsa = $dbo -> fetchArray ( 'SELECT qta, (SELECT nome FROM dt_automezzi WHERE id=idautomezzo) AS nome, (SELECT targa FROM dt_automezzi WHERE id=idautomezzo) AS targa FROM mg_articoli_automezzi WHERE idarticolo=' . prepare ( $id_record ));
2017-08-04 16:28:16 +02:00
if ( count ( $rsa ) > 0 ) {
echo '
< div class = " row " >
< div class = " col-md-12 col-lg-6 " >
< table class = " table table-striped table-condensed table-bordered " >
< tr >
2017-09-04 12:02:29 +02:00
< th > '.tr(' Nome automezzo ').' </ th >
< th > '.tr(' Targa ').' </ th >
< th > '.tr(' Q . tà ').' </ th >
2017-08-04 16:28:16 +02:00
</ tr > ' ;
for ( $i = 0 ; $i < count ( $rsa ); ++ $i ) {
echo '
< tr >
< td > '.$rsa[$i][' nome '].' </ td >
< td > '.$rsa[$i][' targa '].' </ td >
< td > '.$rsa[$i][' qta '].' '.$rs[0][' unita_misura '].' </ td >
</ tr > ' ;
}
echo '
</ table >
</ div >
</ div > ' ;
}
?>
</ div >
</ div >
</ form >
< script >
$ ( " #categoria " ) . change ( function (){
session_set ( " superselect,id_categoria " , $ ( this ) . val (), 0 );
$ ( " #subcategoria " ) . val ( null ) . trigger ( " change " );
});
</ 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-06 11:59:47 +02:00
< ? php
$count = $dbo -> fetchArray ( ' SELECT COUNT ( * ) AS tot FROM (
SELECT `idarticolo` FROM `co_righe_documenti` WHERE `idarticolo` = '.prepare($id_record).' UNION
SELECT `idarticolo` FROM `dt_righe_ddt` WHERE `idarticolo` = '.prepare($id_record).' UNION
SELECT `idarticolo` FROM `or_righe_ordini` WHERE `idarticolo` = '.prepare($id_record).' UNION
SELECT `idarticolo` FROM `mg_articoli_interventi` WHERE `idarticolo` = '.prepare($id_record).'
) AS count ' );
$tot = $count [ 0 ][ 'tot' ];
if ( $tot > 0 ) {
echo '
< div class = " alert alert-danger " >
2017-09-10 14:35:41 +02:00
'.tr(' Ci sono _NUM_ righe di documenti collegate ' , [
'_NUM_' => $tot ,
]) . ' .
2017-09-06 11:59:47 +02:00
'.tr(' Eliminando questo articolo si potrebbero verificare problemi nelle altre sezioni del gestionale ! ').'
</ div > ' ;
}