2017-08-04 16:28:16 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
include_once __DIR__.'/../../core.php';
|
|
|
|
|
|
|
|
echo '
|
2018-02-23 16:04:50 +01:00
|
|
|
<form action="" method="post" id="edit-form">
|
2017-08-04 16:28:16 +02:00
|
|
|
<input type="hidden" name="backto" value="record-edit">
|
|
|
|
<input type="hidden" name="op" value="update">
|
|
|
|
|
|
|
|
<!-- DATI -->
|
|
|
|
<div class="panel panel-primary">
|
|
|
|
<div class="panel-heading">
|
2017-09-04 12:02:29 +02:00
|
|
|
<h3 class="panel-title">'.tr('Valori della sezione').'</h3>
|
2017-08-04 16:28:16 +02:00
|
|
|
</div>
|
|
|
|
|
2018-02-22 11:07:52 +01:00
|
|
|
<div class="panel-body">';
|
|
|
|
|
2017-08-04 16:28:16 +02:00
|
|
|
foreach ($records as $record) {
|
|
|
|
// Scelta fra più valori
|
|
|
|
echo '
|
2018-02-20 16:46:23 +01:00
|
|
|
<div class="col-md-6">';
|
2017-08-04 16:28:16 +02:00
|
|
|
if (preg_match("/list\[(.+?)\]/", $record['tipo'], $m)) {
|
|
|
|
$m = explode(',', $m[1]);
|
|
|
|
$list = '';
|
|
|
|
for ($j = 0; $j < count($m); ++$j) {
|
|
|
|
if ($j != 0) {
|
|
|
|
$list .= ',';
|
|
|
|
}
|
|
|
|
$list .= '\\"'.$m[$j].'\\": \\"'.$m[$j].'\\"';
|
|
|
|
}
|
|
|
|
echo '
|
|
|
|
{[ "type": "select", "label": "'.$record['nome'].'", "name": "'.$record['idimpostazione'].'", "values": "list='.$list.'", "value": "'.$record['valore'].'" ]}';
|
|
|
|
}
|
|
|
|
|
|
|
|
// query
|
|
|
|
elseif (preg_match('/^query=(.+?)$/', $record['tipo'], $m)) {
|
|
|
|
echo '
|
|
|
|
{[ "type": "select", "label": "'.$record['nome'].'", "name": "'.$record['idimpostazione'].'", "values": "'.$record['tipo'].'", "value": "'.$record['valore'].'" ]}';
|
|
|
|
}
|
|
|
|
|
|
|
|
// Boolean (checkbox)
|
|
|
|
elseif ($record['tipo'] == 'boolean') {
|
|
|
|
echo '
|
2017-09-04 12:02:29 +02:00
|
|
|
{[ "type": "checkbox", "label": "'.$record['nome'].'", "name": "'.$record['idimpostazione'].'", "placeholder": "'.tr('Attivo').'", "value": "'.$record['valore'].'" ]}';
|
2017-08-04 16:28:16 +02:00
|
|
|
} elseif ($record['tipo'] == 'textarea') {
|
|
|
|
echo '
|
|
|
|
{[ "type": "textarea", "label": "'.$record['nome'].'", "name": "'.$record['idimpostazione'].'", "value": '.json_encode($record['valore']).' ]}';
|
|
|
|
}
|
|
|
|
// Campo di testo normale
|
|
|
|
else {
|
|
|
|
$numerico = in_array($record['tipo'], ['integer', 'decimal']);
|
|
|
|
|
|
|
|
$tipo = (preg_match('/password/i', $record['nome'], $m)) ? 'password' : $tipo;
|
|
|
|
$tipo = $numerico ? 'number' : 'text';
|
|
|
|
|
|
|
|
echo '
|
|
|
|
{[ "type": "'.$tipo.'", "label": "'.$record['nome'].'", "name": "'.$record['idimpostazione'].'", "value": "'.$record['valore'].'"'.($numerico && $record['tipo'] == 'integer' ? ', "decimals": 0' : '').' ]}';
|
|
|
|
}
|
|
|
|
echo '
|
|
|
|
</div>';
|
|
|
|
}
|
2018-02-22 11:07:52 +01:00
|
|
|
|
2017-08-04 16:28:16 +02:00
|
|
|
echo '
|
|
|
|
<div class="clearfix"></div><hr>
|
|
|
|
<div class="pull-right">
|
2017-09-04 12:02:29 +02:00
|
|
|
<button type="submit" class="btn btn-success"><i class="fa fa-check"></i> '.tr('Salva modifiche').'</button>
|
2017-08-04 16:28:16 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</form>';
|