2017-08-04 16:28:16 +02:00
< ? php
include_once __DIR__ . '/../../core.php' ;
2018-07-18 15:20:10 +02:00
$_SESSION [ 'superselect' ][ 'id_categoria' ] = $record [ 'id_categoria' ];
2017-08-04 16:28:16 +02:00
2018-02-23 16:04:50 +01:00
?> <form action="" method="post" id="edit-form" enctype="multipart/form-data">
2017-08-04 16:28:16 +02:00
< 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 = " row " >
< div class = " col-md-3 " >
2019-07-12 12:40:13 +02:00
{[ " type " : " image " , " label " : " <?php echo tr('Immagine'); ?> " , " name " : " immagine " , " class " : " img-thumbnail " , " value " : " <?php echo $articolo->image ; ?> " ]}
2017-08-04 16:28:16 +02:00
</ div >
2019-11-08 14:58:49 +01:00
< div class = " col-md-9 " >
< div class = " row " >
< div class = " col-md-6 " >
{[ " type " : " text " , " label " : " <?php echo tr('Codice'); ?> " , " name " : " codice " , " required " : 1 , " value " : " $codice $ " , " validation " : " codice " ]}
</ div >
2019-11-19 18:06:10 +01:00
< div class = " col-md-6 " >
2019-11-08 14:58:49 +01:00
{[ " type " : " text " , " label " : " <?php echo tr('Barcode'); ?> " , " name " : " barcode " , " value " : " $barcode $ " ]}
2019-11-19 18:06:10 +01:00
</ div >
2019-11-08 14:58:49 +01:00
</ div >
< div class = " row " >
< div class = " col-md-6 " >
{[ " type " : " select " , " label " : " <?php echo tr('Categoria'); ?> " , " name " : " categoria " , " required " : 1 , " value " : " $id_categoria $ " , " ajax-source " : " categorie " ]}
</ div >
< div class = " col-md-6 " >
{[ " type " : " select " , " label " : " <?php echo tr('Sottocategoria'); ?> " , " name " : " subcategoria " , " value " : " $id_sottocategoria $ " , " ajax-source " : " sottocategorie " ]}
</ div >
</ div >
2018-04-04 00:13:26 +02:00
</ div >
2017-08-04 16:28:16 +02:00
</ 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 " >
2018-04-03 23:31:44 +02:00
< div class = " col-md-3 " >
2018-01-12 16:23:26 +01:00
{[ " type " : " number " , " label " : " <?php echo tr('Quantità'); ?> " , " name " : " qta " , " required " : 1 , " value " : " $qta $ " , " readonly " : 1 , " decimals " : " qta " , " min-value " : " undefined " ]}
2018-07-18 15:20:10 +02:00
< input type = " hidden " id = " old_qta " value = " <?php echo $record['qta'] ; ?> " >
2017-08-04 16:28:16 +02:00
</ div >
2019-11-19 18:06:10 +01:00
< div class = " col-md-2 " >
{[ " type " : " checkbox " , " label " : " <?php echo tr('Modifica quantità'); ?> " , " name " : " qta_manuale " , " value " : 0 , " help " : " <?php echo tr('Seleziona per modificare manualmente la quantità'); ?> " , " placeholder " : " <?php echo tr('Quantità manuale'); ?> " , " extra " : " <?php echo ( $record['servizio'] ) ? 'disabled' : ''; ?> " ]}
2017-08-04 16:28:16 +02:00
< script type = " text/javascript " >
2018-05-05 09:29:09 +02:00
$ ( document ) . ready ( function () {
2018-04-24 00:35:18 +02:00
$ ( '#servizio' ) . click ( function (){
$ ( " #qta_manuale " ) . attr ( " disabled " , $ ( '#servizio' ) . is ( " :checked " ));
});
$ ( '#qta_manuale' ) . click ( function (){
$ ( " #qta " ) . attr ( " readonly " , ! $ ( '#qta_manuale' ) . is ( " :checked " ));
2018-05-11 15:11:01 +02:00
if ( $ ( '#qta_manuale' ) . is ( " :checked " )){
$ ( " #div_modifica_manuale " ) . show ();
$ ( " #div_modifica_manuale " ) . show ();
$ ( " #descrizione_movimento " ) . attr ( 'required' , true );
$ ( " #data_movimento " ) . attr ( 'required' , true );
} else {
$ ( " #div_modifica_manuale " ) . hide ();
$ ( '#qta' ) . val ( $ ( '#old_qta' ) . val ());
$ ( " #descrizione_movimento " ) . attr ( 'required' , false );
$ ( " #data_movimento " ) . attr ( 'required' , false );
}
2018-04-24 00:35:18 +02:00
});
});
2017-08-04 16:28:16 +02:00
</ script >
</ div >
2018-04-04 00:13:26 +02:00
< div class = " col-md-2 " >
2017-09-22 15:19:59 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Unità di misura'); ?> " , " name " : " um " , " value " : " $um $ " , " ajax-source " : " misure " , " icon-after " : " add|<?php echo Modules::get('Unità di misura')['id']; ?> " ]}
2017-08-04 16:28:16 +02:00
</ div >
2018-01-12 16:23:26 +01:00
2019-11-19 18:06:10 +01:00
< div class = " col-md-2 " >
2018-07-18 15:20:10 +02:00
{[ " type " : " checkbox " , " label " : " <?php echo tr('Abilita serial number'); ?> " , " name " : " abilita_serial " , " value " : " $abilita_serial $ " , " help " : " <?php echo tr('Abilita serial number in fase di aggiunta articolo in fattura o ddt'); ?> " , " placeholder " : " <?php echo tr('Serial number'); ?> " , " extra " : " <?php echo ( $record['serial'] > 0) ? 'readonly' : ''; ?> " ]}
2017-08-04 16:28:16 +02:00
</ div >
2019-11-19 18:06:10 +01:00
< div class = " col-md-3 " >
2019-11-22 16:28:03 +01:00
{[ " type " : " checkbox " , " label " : " <?php echo tr('Attivo'); ?> " , " name " : " attivo " , " help " : " <?php echo tr('Seleziona per rendere attivo l \ 'articolo'); ?> " , " value " : " $attivo $ " , " placeholder " : " <?php echo tr('Articolo attivo'); ?> " ]}
2019-11-19 18:06:10 +01:00
</ div >
2017-08-04 16:28:16 +02:00
</ div >
2018-06-23 18:35:08 +02:00
2018-05-11 15:11:01 +02:00
< div class = 'row' id = " div_modifica_manuale " style = " display:none; " >
< div class = 'col-md-3' >
2018-07-03 12:28:38 +02:00
{[ " type " : " text " , " label " : " <?php echo tr('Descrizione movimento'); ?> " , " name " : " descrizione_movimento " ]}
2018-05-11 15:11:01 +02:00
</ div >
< div class = 'col-md-3' >
{[ " type " : " date " , " label " : " <?php echo tr('Data movimento'); ?> " , " name " : " data_movimento " , " value " : " -now- " ]}
</ 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 >
2018-04-03 23:31:44 +02:00
<!-- informazioni Acquisto / Vendita -->
< div class = " row " >
< div class = " col-md-6 " >
< div class = " panel panel-primary " >
< div class = " panel-heading " >
< h3 class = " panel-title " >< ? php echo tr ( 'Acquisto' ); ?> </h3>
</ div >
< div class = " panel-body " >
< div class = " row " >
< div class = " col-md-6 " >
2019-04-13 00:09:48 +02:00
{[ " type " : " number " , " label " : " <?php echo tr('Prezzo di acquisto'); ?> " , " name " : " prezzo_acquisto " , " value " : " $prezzo_acquisto $ " , " icon-after " : " <?php echo currency(); ?> " ]}
2018-04-03 23:31:44 +02:00
</ div >
< div class = " col-md-6 " >
{[ " type " : " number " , " label " : " <?php echo tr('Soglia minima quantità'); ?> " , " name " : " threshold_qta " , " value " : " $threshold_qta $ " , " decimals " : " qta " , " min-value " : " undefined " ]}
</ div >
</ div >
2018-07-09 17:21:25 +02:00
2019-11-12 18:45:52 +01:00
< div class = " row " >
< div class = " col-md-12 " >
{[ " type " : " select " , " label " : " <?php echo tr('Fornitore predefinito'); ?> " , " name " : " id_fornitore " , " value " : " $id_fornitore $ " , " ajax-source " : " fornitori " ]}
</ div >
</ div >
2018-07-09 17:21:25 +02:00
< div class = " row " >
< div class = " col-md-12 " >
{[ " type " : " select " , " label " : " <?php echo tr('Conto predefinito di acquisto'); ?> " , " name " : " idconto_acquisto " , " value " : " $idconto_acquisto $ " , " ajax-source " : " conti-acquisti " ]}
</ div >
</ div >
2018-04-03 23:31:44 +02:00
</ div >
</ div >
</ div >
< div class = " col-md-6 " >
< div class = " panel panel-primary " >
< div class = " panel-heading " >
2019-03-01 16:41:24 +01:00
< h3 class = " panel-title " >
< ? php echo tr ( 'Vendita' ); ?>
</ h3 >
2018-04-03 23:31:44 +02:00
</ div >
< div class = " panel-body " >
2019-03-01 16:41:24 +01:00
2019-10-01 18:01:00 +02:00
2019-03-01 16:41:24 +01:00
< div class = " clearfix " ></ div >
2018-04-03 23:31:44 +02:00
< div class = " row " >
< div class = " col-md-6 " >
2019-03-01 18:04:07 +01:00
< button type = " button " class = " btn btn-info btn-xs pull-right tip pull-right " title = " <?php echo tr('Scorpora iva dal prezzo di vendita.'); ?> " id = " scorpora_iva " >< i class = " fa fa-calculator " aria - hidden = " true " ></ i ></ button >
2019-04-13 00:09:48 +02:00
{[ " type " : " number " , " label " : " <?php echo tr('Prezzo di vendita'); ?> " , " name " : " prezzo_vendita " , " value " : " $prezzo_vendita $ " , " icon-after " : " <?php echo currency(); ?> " ]}
2018-04-03 23:31:44 +02:00
</ div >
< div class = " col-md-6 " >
2018-09-21 18:08:47 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Iva di vendita'); ?> " , " name " : " idiva_vendita " , " ajax-source " : " iva " , " value " : " $idiva_vendita $ " , " valore_predefinito " : " Iva predefinita " ]}
2018-04-03 23:31:44 +02:00
</ div >
</ div >
2018-04-04 00:13:26 +02:00
< div class = " row " >
< div class = " col-md-6 " >
{[ " type " : " number " , " label " : " <?php echo tr('Garanzia'); ?> " , " name " : " gg_garanzia " , " decimals " : 0 , " value " : " $gg_garanzia $ " , " icon-after " : " GG " ]}
</ div >
< div class = " col-md-6 " >
2018-04-24 00:35:18 +02:00
{[ " type " : " checkbox " , " label " : " <?php echo tr('Questo articolo è un servizio'); ?> " , " name " : " servizio " , " value " : " $servizio $ " , " help " : " <?php echo tr('Le quantità non saranno considerate'); ?> " , " placeholder " : " <?php echo tr('Servizio'); ?> " ]}
2018-04-04 00:13:26 +02:00
</ div >
</ div >
2018-05-05 09:29:09 +02:00
2018-04-04 00:13:26 +02:00
< div class = " row " >
< div class = " col-md-6 " >
{[ " type " : " number " , " label " : " <?php echo tr('Peso lordo'); ?> " , " name " : " peso_lordo " , " value " : " $peso_lordo $ " , " icon-after " : " KG " ]}
</ div >
< div class = " col-md-6 " >
{[ " type " : " number " , " label " : " <?php echo tr('Volume'); ?> " , " name " : " volume " , " value " : " $volume $ " , " icon-after " : " M<sup>3</sup> " ]}
</ div >
</ div >
2018-07-09 17:21:25 +02:00
< div class = " row " >
< div class = " col-md-12 " >
{[ " type " : " select " , " label " : " <?php echo tr('Conto predefinito di vendita'); ?> " , " name " : " idconto_vendita " , " value " : " $idconto_vendita $ " , " ajax-source " : " conti-vendite " ]}
</ div >
</ div >
2018-04-03 23:31:44 +02:00
</ div >
</ div >
</ div >
</ div >
2017-08-04 16:28:16 +02:00
< 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 " >
< ? 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 "
2018-07-23 16:50:07 +02:00
< 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 ); start_superselect(); $ ('.datepicker').datetimepicker( { locale: globals.locale, format: 'L' } ); } ); \" > \n " ;
2017-08-04 16:28:16 +02:00
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 ) {
2018-07-18 15:20:10 +02:00
( $record [ 'componente_filename' ] == $cmp [ $c ][ 0 ]) ? $attr = 'selected="selected"' : $attr = '' ;
2017-08-04 16:28:16 +02:00
echo '
< option value = " '. $cmp[$c] [0]. " \ " $attr > " . $cmp [ $c ][ 1 ] . " </option> \n " ;
}
}
echo '
</ select >
</ div >
</ div >
</ div > ' ;
echo '
< div id = " info_componente " > ' ;
2018-07-18 15:20:10 +02:00
genera_form_componente ( $record [ 'contenuto' ]);
2017-08-04 16:28:16 +02:00
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 >
2019-04-13 02:56:39 +02:00
< td > '.moneyFormat($rsart[0][' prezzo_vendita ']).' </ td >
2017-08-04 16:28:16 +02:00
</ tr > ' ;
for ( $i = 0 ; $i < count ( $rsl ); ++ $i ) {
echo '
< tr >
< td > '.$rsl[$i][' nome '].' </ td >
2019-04-13 02:56:39 +02:00
< td > '.moneyFormat($rsart[0][' prezzo_vendita '] - $rsart[0][' prezzo_vendita '] / 100 * $rsl[$i][' prc_guadagno ']).' </ td >
2017-08-04 16:28:16 +02:00
</ tr > ' ;
}
echo '
</ table >
</ div >
</ div > ' ;
2017-09-18 17:24:25 +02:00
} else {
echo '
< div class = " alert alert-info " >
2019-07-01 16:46:05 +02:00
'.tr(' Non ci sono listini caricati ').' ... '.Modules::link(' Listini ', null, tr(' Crea il primo listino ')).'
2017-09-18 17:24:25 +02:00
</ div > ' ;
2017-08-04 16:28:16 +02:00
}
echo '
</ div >
2019-05-29 19:17:57 +02:00
</ div > ' ;
2017-08-04 16:28:16 +02:00
?>
</ form >
2018-09-28 16:17:10 +02:00
{( " name " : " filelist_and_upload " , " id_module " : " $id_module $ " , " id_record " : " $id_record $ " )}
2018-05-17 14:33:40 +02:00
2017-08-04 16:28:16 +02:00
< script >
$ ( " #categoria " ) . change ( function (){
session_set ( " superselect,id_categoria " , $ ( this ) . val (), 0 );
$ ( " #subcategoria " ) . val ( null ) . trigger ( " change " );
});
2019-03-01 16:41:24 +01:00
function scorpora_iva () {
2019-03-01 18:04:07 +01:00
if ( $ ( " #idiva_vendita " ) . val () != '' ){
var percentuale = parseFloat ( $ ( " #idiva_vendita " ) . selectData () . percentuale );
if ( ! percentuale ) return ;
2019-03-01 16:41:24 +01:00
2019-03-01 18:04:07 +01:00
var input = $ ( " #prezzo_vendita " );
var prezzo = input . val () . toEnglish ();
2019-03-01 16:41:24 +01:00
2019-03-01 18:04:07 +01:00
var scorporato = prezzo * 100 / ( 100 + percentuale );
2019-03-01 16:41:24 +01:00
2019-03-01 18:04:07 +01:00
input . val ( scorporato );
} else {
swal ( " <?php echo tr('Attenzione'); ?> " , " <?php echo tr('Seleziona Iva di vendita.'); ?> " , " warning " );
}
2019-03-01 16:41:24 +01:00
}
2019-03-01 18:04:07 +01:00
$ ( " #scorpora_iva " ) . click ( function (){
scorpora_iva ();
2019-10-01 18:01:00 +02:00
});
2019-03-01 18:04:07 +01:00
2017-08-04 16:28:16 +02:00
</ script >
2017-09-06 11:59:47 +02:00
< ? php
2018-09-05 10:05:23 +02:00
// Collegamenti diretti
// Fatture, ddt, preventivi collegati a questo articolo
$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 `idarticolo` = ' . 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 `idarticolo` = '.prepare($id_record).' )
UNION SELECT `co_preventivi` . `id` , `co_preventivi` . `data_bozza` , `co_preventivi` . `numero` , 0 AS numero_esterno , " Preventivo " AS tipo_documento , 0 AS dir FROM `co_preventivi` WHERE `co_preventivi` . `id` IN ( SELECT `idpreventivo` FROM `co_righe_preventivi` WHERE `idarticolo` = '.prepare($id_record).' ) ORDER BY `data` ' );
2017-11-16 14:27:43 +01: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-11-16 14:27:43 +01: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' ]),
]);
2018-01-12 16:23:26 +01:00
//se non è un preventivo è un ddt o una fattura
//se non è un ddt è una fattura.
if ( in_array ( $elemento [ 'tipo_documento' ], [ 'Preventivo' ])) {
$modulo = 'Preventivi' ;
} elseif ( ! 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' ;
}
2017-11-16 14:27:43 +01:00
$id = $elemento [ 'id' ];
echo '
2018-09-05 10:05:23 +02:00
< li > '.Modules::link($modulo, $id, $descrizione).' </ li > ' ;
2017-11-16 14:27:43 +01:00
}
2017-09-06 11:59:47 +02:00
echo '
2017-11-16 14:27:43 +01:00
</ 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 > ' ;
2019-07-05 09:53:53 +02:00
} else {
?>
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' ); ?>
2018-01-12 16:23:26 +01:00
</ a >
2019-06-17 16:06:40 +02:00
< ? php
}
2019-07-05 12:28:19 +02:00
?>