1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-27 00:06:14 +01:00

Aggiunto bulk per eliminazione aliq. iva non utilizzate

This commit is contained in:
Luca 2019-05-08 15:29:52 +02:00
parent 607a5f6e4c
commit c58adc2e9e
3 changed files with 69 additions and 18 deletions

View File

@ -53,7 +53,7 @@ switch (post('op')) {
case 'delete-bulk':
if (App::debug()) {
foreach ($id_records as $id) {
$dbo->query('DELETE FROM co_documenti WHERE id = '.prepare($id).Modules::getAdditionalsQuery($id_module));
$dbo->query('DELETE FROM co_documenti WHERE id = '.prepare($id).Modules::getAdditionalsQuery($id_module));
$dbo->query('DELETE FROM co_righe_documenti WHERE iddocumento='.prepare($id).Modules::getAdditionalsQuery($id_module));
$dbo->query('DELETE FROM co_scadenziario WHERE iddocumento='.prepare($id).Modules::getAdditionalsQuery($id_module));
$dbo->query('DELETE FROM mg_movimenti WHERE iddocumento='.prepare($id).Modules::getAdditionalsQuery($id_module));

44
modules/iva/bulk.php Normal file
View File

@ -0,0 +1,44 @@
<?php
include_once __DIR__.'/../../core.php';
switch (post('op')) {
case 'delete-bulk':
$count_iva = $dbo->fetchNum('SELECT id FROM `co_iva` WHERE deleted_at IS NOT NULL');
foreach ($id_records as $id) {
$res = $dbo->fetchNum('SELECT `co_righe_documenti`.`id` FROM `co_righe_documenti` WHERE `co_righe_documenti`.`idiva`='.prepare($id).
' UNION SELECT `co_righe_preventivi`.`id` FROM `co_righe_preventivi` WHERE `co_righe_preventivi`.`idiva` = '.prepare($id).
' UNION SELECT `co_righe_contratti`.`id` FROM `co_righe_contratti` WHERE `co_righe_contratti`.`idiva` = '.prepare($id).
' UNION SELECT `dt_righe_ddt`.`id` FROM `dt_righe_ddt` WHERE `dt_righe_ddt`.`idiva` = '.prepare($id).
' UNION SELECT `or_righe_ordini`.`id` FROM `or_righe_ordini` WHERE `or_righe_ordini`.`idiva` = '.prepare($id).
' UNION SELECT `mg_articoli`.`id` FROM `mg_articoli` WHERE `mg_articoli`.`idiva_vendita` = '.prepare($id).
' UNION SELECT `an_anagrafiche`.`idanagrafica` AS `id` FROM `an_anagrafiche` WHERE `an_anagrafiche`.`idiva_vendite` = '.prepare($id).' OR `an_anagrafiche`.`idiva_acquisti` = '.prepare($id) );
if (empty($res)) {
$dbo->query('UPDATE `co_iva` SET deleted_at = NOW() WHERE id = '.prepare($id).Modules::getAdditionalsQuery($id_module));
}
}
$count_iva = $dbo->fetchNum('SELECT id FROM `co_iva` WHERE deleted_at IS NOT NULL') - $count_iva;
if ($count_iva>0){
$msg = tr('_NUM_ tipologi_A_ iva eliminat_A_.', [
'_NUM_' => $count_iva,
'_A_' => ($count_iva==1) ? 'a' : 'e']);
flash()->info($msg);
}
else{
flash()->warning(tr('Nessuna tipologia iva eliminata!'));
}
break;
}
$bulk = [
'delete-bulk' => tr('Elimina selezionati'),
];
return $bulk;

View File

@ -2,13 +2,6 @@
include_once __DIR__.'/../../core.php';
if (!$record['default']) {
$attr = '';
} else {
$attr = 'readonly';
echo '<div class="alert alert-warning">'.tr('Alcune impostazioni non possono essere modificate.').'</div>';
}
$esigibilita = [
[
'id' => 'I',
@ -79,16 +72,6 @@ $esigibilita = [
</form>
<?php
// Record eliminabile solo se permesso
if (!$record['default']) {
?>
<a class="btn btn-danger ask" data-backto="record-list">
<i class="fa fa-trash"></i> <?php echo tr('Elimina'); ?>
</a>
<?php
}
?>
<script>
$(document).ready(function(){
@ -108,3 +91,27 @@ $(document).ready(function(){
});
});
</script>
<?php
$res = $dbo->fetchNum('SELECT `co_righe_documenti`.`id` FROM `co_righe_documenti` WHERE `co_righe_documenti`.`idiva`='.prepare($id_record).
' UNION SELECT `co_righe_preventivi`.`id` FROM `co_righe_preventivi` WHERE `co_righe_preventivi`.`idiva` = '.prepare($id_record).
' UNION SELECT `co_righe_contratti`.`id` FROM `co_righe_contratti` WHERE `co_righe_contratti`.`idiva` = '.prepare($id_record).
' UNION SELECT `dt_righe_ddt`.`id` FROM `dt_righe_ddt` WHERE `dt_righe_ddt`.`idiva` = '.prepare($id_record).
' UNION SELECT `or_righe_ordini`.`id` FROM `or_righe_ordini` WHERE `or_righe_ordini`.`idiva` = '.prepare($id_record).
' UNION SELECT `mg_articoli`.`id` FROM `mg_articoli` WHERE `mg_articoli`.`idiva_vendita` = '.prepare($id_record).
' UNION SELECT `an_anagrafiche`.`idanagrafica` AS `id` FROM `an_anagrafiche` WHERE `an_anagrafiche`.`idiva_vendite` = '.prepare($id_record).' OR `an_anagrafiche`.`idiva_acquisti` = '.prepare($id_record) );
if ($res) {
echo '
<div class="alert alert-danger">
<p>'.tr('Ci sono '.count($res).' documenti collegati a questa aliquota IVA. Non è possibile eliminarla.').'</p>
</div>';
} else {
echo '
<a class="btn btn-danger ask" data-backto="record-list">
<i class="fa fa-trash"></i> '.tr('Elimina').'
</a>';
}