2018-08-30 18:20:30 +02:00
< ? php
include_once __DIR__ . '/../../core.php' ;
$plugin = Plugins :: get ( $id_plugin );
$idriga = filter ( 'idriga' );
if ( empty ( $idriga )) {
$op = 'addriga' ;
$button = '<i class="fa fa-plus"></i> ' . tr ( 'Aggiungi' );
// valori default
$descrizione = '' ;
$qta = 1 ;
$um = '' ;
$prezzo_vendita = '0' ;
$prezzo_acquisto = '0' ;
2019-05-15 19:34:32 +02:00
$idiva = setting ( 'Iva predefinita' );
2018-08-30 18:20:30 +02:00
if ( ! empty ( $rs [ 0 ][ 'prc_guadagno' ])) {
$sconto_unitario = $rs [ 0 ][ 'prc_guadagno' ];
$tipo_sconto = 'PRC' ;
}
} else {
$op = 'editriga' ;
$button = '<i class="fa fa-edit"></i> ' . tr ( 'Modifica' );
// carico record da modificare
2018-08-31 11:39:38 +02:00
$q = 'SELECT * FROM co_promemoria_righe WHERE id=' . prepare ( $idriga );
2018-08-30 18:20:30 +02:00
$rsr = $dbo -> fetchArray ( $q );
$descrizione = $rsr [ 0 ][ 'descrizione' ];
$qta = $rsr [ 0 ][ 'qta' ];
$um = $rsr [ 0 ][ 'um' ];
$idiva = $rsr [ 0 ][ 'idiva' ];
$prezzo_vendita = $rsr [ 0 ][ 'prezzo_vendita' ];
$prezzo_acquisto = $rsr [ 0 ][ 'prezzo_acquisto' ];
$sconto_unitario = $rsr [ 0 ][ 'sconto_unitario' ];
$tipo_sconto = $rsr [ 0 ][ 'tipo_sconto' ];
}
echo '
< form id = " add-righe " action = " '. $rootdir .'/actions.php " method = " post " >
< input type = " hidden " name = " id_plugin " value = " '. $id_plugin .' " >
< input type = " hidden " name = " id_record " value = " '. $id_record .' " >
< input type = " hidden " name = " op " value = " '. $op .' " >
< input type = " hidden " name = " idriga " value = " '. $idriga .' " > ' ;
// Descrizione
echo '
< div class = " row " >
< div class = " col-md-12 " >
{[ " type " : " textarea " , " label " : " '.tr('Descrizione').' " , " id " : " descrizione_riga " , " name " : " descrizione " , " required " : 1 , " value " : '.json_encode($descrizione).' ]}
</ div >
</ div >
< br > ' ;
// Quantità
echo '
< div class = " row " >
< div class = " col-md-4 " >
{[ " type " : " number " , " label " : " '.tr('Q.tà').' " , " name " : " qta " , " required " : 1 , " value " : " '. $qta .' " , " decimals " : " qta " ]}
</ div > ' ;
// Unità di misura
echo '
< div class = " col-md-4 " >
{[ " type " : " select " , " label " : " '.tr('Unità di misura').' " , " name " : " um " , " value " : " '. $um .' " , " ajax-source " : " misure " ]}
</ div > ' ;
// Iva
echo '
< div class = " col-md-4 " >
2018-09-21 18:08:47 +02:00
{[ " type " : " select " , " label " : " '.tr('Iva').' " , " name " : " idiva " , " required " : 1 , " value " : " '. $idiva .' " , " ajax-source " : " iva " ]}
2018-08-30 18:20:30 +02:00
</ div >
</ div > ' ;
// Prezzo di acquisto
echo '
< div class = " row " >
< div class = " col-md-4 " >
2019-04-13 00:09:48 +02:00
{[ " type " : " number " , " label " : " '.tr('Prezzo di acquisto (un.)').' " , " name " : " prezzo_acquisto " , " required " : 1 , " value " : " '. $prezzo_acquisto .' " , " icon-after " : " '.currency().' " ]}
2018-08-30 18:20:30 +02:00
</ div > ' ;
// Prezzo di vendita
echo '
< div class = " col-md-4 " >
2019-04-13 00:09:48 +02:00
{[ " type " : " number " , " label " : " '.tr('Prezzo di vendita (un.)').' " , " name " : " prezzo_vendita " , " required " : 1 , " value " : " '. $prezzo_vendita .' " , " icon-after " : " '.currency().' " ]}
2018-08-30 18:20:30 +02:00
</ div > ' ;
// Sconto unitario
echo '
< div class = " col-md-4 " >
{[ " type " : " number " , " label " : " '.tr('Sconto unitario').' " , " name " : " sconto " , " icon-after " : " choice|untprc|'. $tipo_sconto .' " , " value " : " '. $sconto_unitario .' " ]}
</ div >
</ div > ' ;
echo '
<!-- PULSANTI -->
< div class = " row " >
< div class = " col-md-12 text-right " >
< button type = " submit " class = " btn btn-primary pull-right " > '.$button.' </ button >
</ div >
</ div >
</ form > ' ;
echo '
2019-07-26 18:05:19 +02:00
< script > $ ( document ) . ready ( init ) </ script > ' ;
2018-08-30 18:20:30 +02:00
echo '
< script type = " text/javascript " >
$ ( document ) . ready ( function () {
$ ( " #add-righe " ) . ajaxForm ({
success : function (){
2020-02-05 12:40:44 +01:00
$ ( " #modals > div " ) . modal ( " hide " );
2018-08-30 18:20:30 +02:00
refreshRighe ( '.$id_record.' );
}
});
});
</ script > ' ;