Fix - Eliminazione porti

This commit is contained in:
Luca 2018-03-27 23:52:07 +02:00
parent d4620a6a9c
commit 6c6576bcf7
2 changed files with 12 additions and 8 deletions

View File

@ -44,17 +44,20 @@ switch (filter('op')) {
break;
case 'delete':
$documenti = $dbo->fetchArray('SELECT id FROM dt_ddt WHERE idporto='.prepare($id_record).'
UNION SELECT id FROM co_documenti WHERE idporto='.prepare($id_record).'
UNION SELECT id FROM co_preventivi WHERE idporto='.prepare($id_record));
$documenti = $dbo->fetchNum('SELECT id FROM dt_ddt WHERE idporto='.prepare($id_record).'
UNION SELECT id FROM co_documenti WHERE idporto='.prepare($id_record).'
UNION SELECT id FROM co_preventivi WHERE idporto='.prepare($id_record));
if (isset($id_record) && !empty($documenti)) {
if (isset($id_record) && empty($documenti)) {
$dbo->query('DELETE FROM `dt_porto` WHERE `id`='.prepare($id_record));
$_SESSION['infos'][] = tr('Tipologia di _TYPE_ eliminata con successo!', [
'_TYPE_' => 'porto',
]);
} else {
$_SESSION['errors'][] = tr('Sono presenti dei documenti collegati a questo porto!');
}
break;

View File

@ -23,17 +23,18 @@ include_once __DIR__.'/../../core.php';
</form>
<?php
$documenti = $dbo->fetchArray('SELECT id FROM dt_ddt WHERE idporto='.prepare($id_record).'
UNION SELECT id FROM co_documenti WHERE idporto='.prepare($id_record).'
UNION SELECT id FROM co_preventivi WHERE idporto='.prepare($id_record));
$documenti = $dbo->fetchNum('SELECT id FROM dt_ddt WHERE idporto='.prepare($id_record).'
UNION SELECT id FROM co_documenti WHERE idporto='.prepare($id_record).'
UNION SELECT id FROM co_preventivi WHERE idporto='.prepare($id_record));
if (!empty($documenti)){
echo '
<div class="alert alert-danger">
'.tr('Ci sono _NUM_ documenti collegati', [
'_NUM_' => count($documenti),
]).'.
</div>';
}
?>
<a class="btn btn-danger ask" data-backto="record-list">