1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-29 01:00:00 +01:00
openstamanager/modules/listini/actions.php

42 lines
1.2 KiB
PHP
Raw Normal View History

<?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;
}
$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!'));
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;
}
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!'));
}
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!'));
break;
}