1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-25 15:22:24 +01:00
openstamanager/modules/viste/filters.php

145 lines
5.2 KiB
PHP
Raw Normal View History

2019-05-10 23:47:45 +02:00
<?php
echo '
<form action="" method="post" role="form">
<input type="hidden" name="backto" value="record-edit">
<input type="hidden" name="op" value="filters">
<div class="data">';
$num = 0;
$additionals = $dbo->fetchArray('SELECT * FROM zz_group_module WHERE idmodule='.prepare($record['id']).' ORDER BY `id` ASC');
2019-11-13 19:27:25 +01:00
2019-11-15 15:11:20 +01:00
if (!empty($additionals)) {
foreach ($additionals as $num => $additional) {
$editable = !($additional['default'] && $enable_readonly);
2019-11-13 19:27:25 +01:00
2019-11-15 15:11:20 +01:00
echo '
2019-11-23 08:23:34 +01:00
<div class="box collapsed-box box-'.($additional['enabled'] ? 'success' : 'danger').'">
2019-05-10 23:47:45 +02:00
<div class="box-header with-border">
2019-11-23 08:23:34 +01:00
<h3 class="box-title">'.
tr('Filtro: _NAME_', [
2019-05-10 23:47:45 +02:00
'_NAME_' => $additional['name'],
2019-11-23 08:23:34 +01:00
]).'
</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse">
<i class="fa fa-plus"></i>
</button>
</div>';
2019-11-15 15:11:20 +01:00
if ($editable) {
echo '
2019-05-10 23:47:45 +02:00
<a class="btn btn-danger ask pull-right" data-backto="record-edit" data-op="delete_filter" data-id="'.$additional['id'].'">
<i class="fa fa-trash"></i> '.tr('Elimina').'
</a>';
2019-11-15 15:11:20 +01:00
}
2019-05-10 23:47:45 +02:00
2019-11-15 15:11:20 +01:00
echo '
2019-05-10 23:47:45 +02:00
<a class="btn btn-warning ask pull-right" data-backto="record-edit" data-msg="'.($additional['enabled'] ? tr('Disabilitare questo elemento?') : tr('Abilitare questo elemento?')).'" data-op="change" data-id="'.$additional['id'].'" data-class="btn btn-lg btn-warning" data-button="'.($additional['enabled'] ? tr('Disabilita') : tr('Abilita')).'">
<i class="fa fa-eye-slash"></i> '.($additional['enabled'] ? tr('Disabilita') : tr('Abilita')).'
</a>';
2019-11-15 15:11:20 +01:00
echo '
2019-05-10 23:47:45 +02:00
</div>
<div id="additional-'.$additional['id'].'" class="box-body collapse">
<div class="row">
<div class="col-md-12">
{[ "type": "textarea", "label": "'.tr('Query').'", "name": "query['.$num.']", "value": "'.prepareToField($additional['clause']).'"';
2019-11-15 15:11:20 +01:00
if (!$editable) {
echo ', "readonly": '.intval(!$editable).'';
}
echo ' ]}
2019-05-10 23:47:45 +02:00
</div>
</div>
<div class="row">
<input type="hidden" value="'.$additional['id'].'" name="id['.$num.']">
<div class="col-md-6">
{[ "type": "text", "label": "'.tr('Name').'", "name": "name['.$num.']", "value": "'.$additional['name'].'" ]}
</div>
<div class="col-md-3">
2019-06-04 19:00:44 +02:00
{[ "type": "select", "label": "'.tr('Gruppo').'", "name": "gruppo['.$num.']", "values": "query=SELECT id, nome AS descrizione FROM zz_groups ORDER BY id ASC", "value": "'.$additional['idgruppo'].'", "readonly": '.intval(!$editable).' ]}
2019-05-10 23:47:45 +02:00
</div>
<div class="col-md-3">
2019-06-04 19:00:44 +02:00
{[ "type": "select", "label": "'.tr('Posizione').'", "name": "position['.$num.']", "values": "list=\"0\":\"'.tr('WHERE').'\",\"1\": \"'.tr('HAVING').'\"", "value": "'.$additional['position'].'", "readonly": '.intval(!$editable).' ]}
2019-05-10 23:47:45 +02:00
</div>
</div>
</div>
</div>';
2019-11-15 15:11:20 +01:00
}
} else {
2019-11-13 19:27:25 +01:00
echo '<br>
<div class="alert alert-info">
<i class="fa fa-info-circle"></i>
<b>'.tr('Informazione:').'</b> '.tr('Nessun filtro per questo modulo').'.
</div>';
}
2019-05-10 23:47:45 +02:00
echo '
</div>
<div class="row">
<div class="col-md-12 text-right">
<button type="button" class="btn btn-info" id="add_filter">
<i class="fa fa-plus"></i> '.tr('Aggiungi nuovo filtro').'
</button>
<button type="submit" class="btn btn-success">
<i class="fa fa-check"></i> '.tr('Salva').'
</button>
</div>
</div>
</form>';
echo '
<form class="hide" id="template_filter">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">'.tr('Nuovo filtro').'</h3>
</div>
<div class="box-body">
<div class="row">
<div class="col-md-12">
{[ "type": "textarea", "label": "'.tr('Query').'", "name": "query[-id-]" ]}
</div>
</div>
<div class="row">
<input type="hidden" value="" name="id[-id-]">
<div class="col-md-6">
{[ "type": "text", "label": "'.tr('Nome').'", "name": "name[-id-]" ]}
</div>
<div class="col-md-3">
{[ "type": "select", "label": "'.tr('Gruppo').'", "name": "gruppo[-id-]", "values": "query=SELECT id, nome AS descrizione FROM zz_groups ORDER BY id ASC" ]}
</div>
<div class="col-md-3">
{[ "type": "select", "label": "'.tr('Posizione').'", "name": "position[-id-]", "values": "list=\"0\":\"'.tr('WHERE').'\",\"1\": \"'.tr('HAVING').'\"" ]}
</div>
</div>
</div>
</div>
</form>';
echo '
<script>
var i = '.$num.';
$(document).on("click", "#add_filter", function(){
2019-07-26 17:40:52 +02:00
cleanup_inputs();
2019-05-10 23:47:45 +02:00
i++;
var text = replaceAll($("#template_filter").html(), "-id-", "" + i);
$(this).parent().parent().parent().find(".data").append(text);
2019-07-26 17:40:52 +02:00
restart_inputs();
2019-05-10 23:47:45 +02:00
});
</script>';