gest366/lib/campi_personalizzati.php

52 lines
1.8 KiB
PHP
Raw Permalink Normal View History

2021-02-24 20:40:04 +00:00
<?php
// testo se modulo abilitato a campi personalizzabili
$query_c = "SELECT count(id) as tot FROM zz_campi_add WHERE deleted='0' and id_module=\"".$id_module."\" ";
$rs_campi = $dbo->fetchArray( $query_c );
$var_campi = $rs_campi[0]['tot'];
if( $var_campi >0 ){
// apro il pannello
?>
<div class="panel panel-<?php echo $_SESSION['profilo_pannello'] ?>">
<div class="panel-heading">
<h3 class="panel-title"><?php echo tr('Campi Personalizzati'); ?></h3>
</div>
<div class="panel-body">
<?php
$rs_campi = $dbo->fetchArray("SELECT * FROM zz_campi_add WHERE deleted='0' and id_module='".$id_module."' order by id");
for( $i=0; $i<sizeof($rs_campi); $i++ ){
$id_label=$rs_campi[$i]['id_label'];
$id_campo=$rs_campi[$i]['id_campo'];
$dimensione=$rs_campi[$i]['dimensione'];
// cerco valore alltrimenti lo creo se nuovo
$rs_valore = $dbo->fetchArray("SELECT valore FROM zz_campi_val WHERE id_campo='".$rs_campi[$i]['id']."' and id_module='".$id_module."' and id_record='".$id_record."'");
if ( sizeof($rs_valore) == '0' ){
// inizializzo il campo
$dbo->query("INSERT INTO zz_campi_val( id_campo, valore , id_module,id_record ) VALUES( '".$rs_campi[$i]['id']."',' ','".$id_module."','".$id_record."')");
$valore="";
}
else{
$valore=$rs_valore[0]['valore'];
}
?>
<div class="col-md-<?php echo $dimensione ?>">
{[ "type": "text", "label": "<?php echo $id_label ?>", "name": "<?php echo $id_campo ?>", "required": 0, "class": "", "value": "<?php echo $valore ?>", "extra": "" ]}
</div>
<?php
}
// chiudo il pannello
?>
</div>
<button type="submit" class="btn-app btn-success"><i class="fa fa-check"></i> Salva </button>
</div>
<?php
}
?>