openstamanager/modules/iva/ajax/select.php

30 lines
1.0 KiB
PHP
Raw Normal View History

2018-09-21 18:08:47 +02:00
<?php
include_once __DIR__.'/../../../core.php';
switch ($resource) {
case 'iva':
2019-03-01 16:41:24 +01:00
$query = 'SELECT id, IF(codice IS NULL, descrizione, CONCAT(codice, " - ", descrizione)) AS descrizione, percentuale FROM co_iva |where| ORDER BY descrizione ASC';
2018-12-29 12:03:22 +01:00
2018-09-21 18:08:47 +02:00
foreach ($elements as $element) {
$filter[] = 'id='.prepare($element);
}
if (!empty($search)) {
$search_fields[] = 'descrizione LIKE '.prepare('%'.$search.'%');
$search_fields[] = 'codice LIKE '.prepare('%'.$search.'%');
}
if (empty($filter)) {
$where[] = 'deleted_at IS NULL';
2018-12-29 12:03:22 +01:00
//se sto valorizzando un documento con lo split payment impedisco la selezione delle aliquote iva con natura N6 (reverse charge)
if (isset($superselect['split_payment']) and !empty($superselect['split_payment'])) {
$where[] = '(codice_natura_fe IS NULL OR codice_natura_fe != "N6")';
}
2018-09-21 18:08:47 +02:00
}
2019-03-01 16:41:24 +01:00
$custom['percentuale'] = 'percentuale';
2018-09-21 18:08:47 +02:00
break;
}