Files
2026-03-09 00:13:00 +01:00

94 lines
5.7 KiB
PHP

<?php $this -> values['name'] ? $g_table = $this -> values['name'] : $g_table = $this -> values[ 'table' ];?>
<div class="row">
<div class="col col-md-6">
<div class="g-container" data="table:<?= $this -> values['id'];?>">
<div class="panel panel-info panel-border top">
<div class="panel-heading">
<span class="panel-title"><?= $this -> element[ $this -> values['id'] ] ? $tmp = 'Edytuj element' : $tmp = 'Dodaj element';?></span>
</div>
<div class="panel-body">
<form method="POST" id="fg-<?= $g_table;?>" class="g-form form-horizontal">
<input type="hidden" name="<?= $this -> values['id'];?>" value="<?= $this -> element[ $this -> values['id'] ];?>" />
<?php if ( is_array( $this -> values['columns_edit'] ) ): foreach ( $this -> values['columns_edit'] as $ce ):?>
<?php if ( $ce['type'] == 'hidden' ):?>
<input type="hidden" name="<?= $ce['db'];?>" value="<?= $ce['value'];?>" />
<?php else:?>
<div class="form-group">
<label for="<?= $ce['db'];?>" class="col col-lg-3 control-label"><?= $ce['name'];?>:</label>
<?php if ( $ce['type'] == 'text' ):?>
<div class="col col-lg-9">
<input type="text" class="form-control <?php if ( $ce['require'] ):?>require<?php endif;?>" name="<?= $ce['db'];?>" id="<?= $ce['db'];?>"
<?php
if ( is_array( $ce['params'] ) ): foreach( $ce['params'] as $key => $val ):
echo $key . '="' . $val . '"';
endforeach; endif;
?> value="<?= htmlspecialchars( $this -> element[ $ce['db'] ] );?>" <?php if ( $ce['readonly-edit'] and $this -> element[ $this -> values['id'] ] ):?>readonly="readonly"<?php endif;?> />
</div>
<?php elseif ( $ce['type'] == 'select' ):?>
<div class="col col-lg-9">
<select name="<?= $ce['db'];?>" id="<?= $ce['db'];?>" class="form-control <?php if ( $ce['require'] ):?>require<?php endif;?>"
<?php
if ( is_array( $ce['params'] ) ): foreach( $ce['params'] as $key => $val ):
echo $key . '="' . $val . '"';
endforeach; endif;
?>>
<option value="null">---- <?= $ce['name'];?> ----</option>
<?php if ( $ce['replace']['sql'] ):?>
<?php $results = $_SESSION[ 'g' . $g_table ] -> connectToDb() -> query( $ce['replace']['sql'] ) -> fetchAll();
if ( is_array( $results ) ) foreach ( $results as $row )
{
echo '<option value="' . $row[0] . '"';
if ( $this -> element[ $ce['db'] ] !== null and $row[0] == $this -> element[ $ce['db'] ] )
echo ' selected="selected" ';
echo '>' . $row[1] . '</option>';
}
?>
<?php else:?>
<?php
if ( is_array( $ce['replace']['array'] ) ): foreach ( $ce['replace']['array'] as $key => $val ):
?>
<option value="<?= $key;?>"
<?php if (
( $this -> element[ $ce['db'] ] !== null and $key == $this -> element[ $ce['db'] ] )
or
( $this -> element[ $ce['db'] ] === null and isset( $ce['default_value'] ) and $ce['default_value'] == $key )
):?>
selected="selected"
<?php endif;?>
>
<?= $val;?>
</option>
<?php
endforeach; endif;
?>
<?php endif;?>
</select>
</div>
<?php elseif ( $ce['type'] == 'radio' ):?>
<div class="col col-lg-9">
<?php if ( is_array( $ce['replace']['array'] ) ): foreach ( $ce['replace']['array'] as $key => $val ):?>
<div class="radio-custom mt10" style="display: inline-block;">
<input type="radio" name="<?= $ce['db'];?>" id="<?= $ce['db'] . '_' . $key;?>" value="<?= $key;?>" <?php if ( $this -> element[ $ce['db'] ] == $key ):?>checked="checked"<?php endif;?> />
<label for="<?= $ce['db'] . '_' . $key;?>"><?= $val;?></label>
</div>
<?php endforeach; endif;?>
</div>
<?php elseif ( $ce['type'] == 'textarea' ):?>
<div class="col col-lg-8">
<textarea name="<?= $ce['db'];?>" id="<?= $ce['db'];?>" class="form-control"
<?php
if ( is_array( $ce['params'] ) ): foreach( $ce['params'] as $key => $val ):
echo $key . '="' . $val . '"';
endforeach; endif;
?>><?= $this -> element[ $ce['db'] ];?></textarea>
</div>
<?php endif;?>
</div>
<?php endif;?>
<?php endforeach; endif;?>
</form>
</div>
</div>
</div>
</div>
</div>