2017-08-04 16:28:16 +02:00
< ? php
2019-11-08 15:09:05 +01:00
include_once __DIR__ . '/../../core.php' ;
2017-08-04 16:28:16 +02:00
$idriga = filter ( 'idriga' );
//Lettura idanagrafica cliente e percentuale di sconto/rincaro in base al listino
2018-11-23 16:08:23 +01:00
$rs = $dbo -> fetchArray ( 'SELECT idanagrafica FROM in_interventi WHERE id=' . prepare ( $id_record ));
2017-08-04 16:28:16 +02:00
$idanagrafica = $rs [ 0 ][ 'idanagrafica' ];
if ( empty ( $idriga )) {
$op = 'addriga' ;
2017-09-04 12:02:29 +02:00
$button = '<i class="fa fa-plus"></i> ' . tr ( 'Aggiungi' );
2017-08-04 16:28:16 +02:00
// valori default
$descrizione = '' ;
$qta = 1 ;
$um = '' ;
$prezzo_vendita = '0' ;
$prezzo_acquisto = '0' ;
2019-04-19 01:39:58 +02:00
$idiva = setting ( 'Iva predefinita' );
2017-08-04 16:28:16 +02:00
} else {
$op = 'editriga' ;
2017-09-04 12:02:29 +02:00
$button = '<i class="fa fa-edit"></i> ' . tr ( 'Modifica' );
2017-08-04 16:28:16 +02:00
// carico record da modificare
$q = 'SELECT * FROM in_righe_interventi WHERE id=' . prepare ( $idriga );
$rsr = $dbo -> fetchArray ( $q );
$descrizione = $rsr [ 0 ][ 'descrizione' ];
$qta = $rsr [ 0 ][ 'qta' ];
$um = $rsr [ 0 ][ 'um' ];
2018-03-19 18:11:51 +01:00
$idiva = $rsr [ 0 ][ 'idiva' ];
2017-08-04 16:28:16 +02:00
$prezzo_vendita = $rsr [ 0 ][ 'prezzo_vendita' ];
$prezzo_acquisto = $rsr [ 0 ][ 'prezzo_acquisto' ];
2018-06-26 14:30:26 +02:00
2017-08-04 16:28:16 +02:00
$sconto_unitario = $rsr [ 0 ][ 'sconto_unitario' ];
$tipo_sconto = $rsr [ 0 ][ 'tipo_sconto' ];
}
/*
Form di inserimento
*/
echo '
< form id = " add-righe " action = " '. $rootdir .'/editor.php?id_module='. $id_module .'&id_record='. $id_record .' " method = " post " >
< input type = " hidden " name = " op " value = " '. $op .' " >
< input type = " hidden " name = " idriga " value = " '. $idriga .' " > ' ;
// Descrizione
echo '
< div class = " row " >
< div class = " col-md-12 " >
2017-09-28 10:16:18 +02:00
{[ " type " : " textarea " , " label " : " '.tr('Descrizione').' " , " id " : " descrizione_riga " , " name " : " descrizione " , " required " : 1 , " value " : '.json_encode($descrizione).' ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
< br > ' ;
// Quantità
echo '
< div class = " row " >
< div class = " col-md-4 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " number " , " label " : " '.tr('Q.tà').' " , " name " : " qta " , " required " : 1 , " value " : " '. $qta .' " , " decimals " : " qta " ]}
2017-08-04 16:28:16 +02:00
</ div > ' ;
// Unità di misura
echo '
< div class = " col-md-4 " >
2017-09-22 15:19:59 +02:00
{[ " type " : " select " , " label " : " '.tr('Unità di misura').' " , " icon-after " : " add|'.Modules::get('Unità di misura')['id'].' " , " name " : " um " , " value " : " '. $um .' " , " ajax-source " : " misure " ]}
2018-03-19 18:11:51 +01:00
</ div > ' ;
2018-06-26 14:30:26 +02:00
2018-03-19 18:11:51 +01:00
// 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 " ]}
2017-08-04 16:28:16 +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().' " ]}
2017-08-04 16:28:16 +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().' " ]}
2017-08-04 16:28:16 +02:00
</ div > ' ;
// Sconto unitario
echo '
< div class = " col-md-4 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " number " , " label " : " '.tr('Sconto unitario').' " , " name " : " sconto " , " icon-after " : " choice|untprc|'. $tipo_sconto .' " , " value " : " '. $sconto_unitario .' " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div > ' ;
echo '
2017-09-11 13:08:50 +02:00
<!-- PULSANTI -->
< div class = " row " >
< div class = " col-md-12 text-right " >
< button type = " submit " class = " btn btn-primary pull-right " > '.$button.' </ button >
</ div >
</ div >
2017-09-11 11:28:39 +02:00
</ form > ' ;
echo '
2019-07-26 18:05:19 +02:00
< script > $ ( document ) . ready ( init ) </ script > ' ;
2017-08-04 16:28:16 +02:00
?>
< script type = " text/javascript " >
$ ( document ) . ready ( function () {
2017-09-13 17:08:27 +02:00
$ ( '#add-righe' ) . ajaxForm ({
success : function (){
$ ( '#bs-popup' ) . modal ( 'hide' );
2017-08-04 16:28:16 +02:00
2017-09-13 17:08:27 +02:00
// Ricarico le righe
2019-11-22 16:28:03 +01:00
$ ( '#righe' ) . load ( '<?php echo $module->fileurl(' ajax_righe . php '); ?>?id_module=<?php echo $id_module; ?>&id_record=<?php echo $id_record; ?>' );
2017-08-04 16:28:16 +02:00
2017-09-13 17:08:27 +02:00
// Ricarico la tabella dei costi
2019-11-22 16:28:03 +01:00
$ ( '#costi' ) . load ( '<?php echo $module->fileurl(' ajax_costi . php '); ?>?id_module=<?php echo $id_module; ?>&id_record=<?php echo $id_record; ?>' );
2017-09-13 17:08:27 +02:00
}
});
2017-08-04 16:28:16 +02:00
});
</ script >