2017-08-04 16:28:16 +02:00
< ? php
include_once __DIR__ . '/../../core.php' ;
switch ( post ( 'op' )) {
case 'update' :
$nome = post ( 'nome' );
$prc_guadagno = post ( 'prc_guadagno' );
$note = post ( 'note' );
2018-02-18 19:53:23 +01:00
if ( abs ( $prc_guadagno ) > 100 ) {
2017-09-12 12:49:05 +02:00
$prc_guadagno = ( $prc_guadagno > 0 ) ? 100 : - 100 ;
}
2017-08-04 16:28:16 +02:00
$query = 'UPDATE mg_listini SET nome=' . prepare ( $nome ) . ', prc_guadagno=' . prepare ( $prc_guadagno ) . ', note=' . prepare ( $note ) . ' WHERE id=' . prepare ( $id_record );
$dbo -> query ( $query );
2018-07-19 17:29:21 +02:00
flash () -> info ( tr ( 'Informazioni salvate correttamente!' ));
2017-08-04 16:28:16 +02:00
break ;
case 'add' :
$nome = post ( 'nome' );
$prc_guadagno = post ( 'prc_guadagno' );
2018-02-18 19:53:23 +01:00
if ( abs ( $prc_guadagno ) > 100 ) {
2017-09-12 12:49:05 +02:00
$prc_guadagno = ( $prc_guadagno > 0 ) ? 100 : - 100 ;
}
2017-08-04 16:28:16 +02:00
if ( isset ( $nome )) {
$dbo -> query ( 'INSERT INTO mg_listini( nome, prc_guadagno ) VALUES (' . prepare ( $nome ) . ', ' . prepare ( $prc_guadagno ) . ')' );
$id_record = $dbo -> lastInsertedID ();
2018-07-19 17:29:21 +02:00
flash () -> info ( tr ( 'Nuovo listino aggiunto!' ));
2017-08-04 16:28:16 +02:00
}
break ;
case 'delete' :
$dbo -> query ( 'DELETE FROM mg_listini WHERE id=' . prepare ( $id_record ));
2018-07-19 17:29:21 +02:00
flash () -> info ( tr ( 'Listino eliminato!' ));
2017-08-04 16:28:16 +02:00
break ;
}