95 lines
5.6 KiB
PHP
95 lines
5.6 KiB
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'] ];?>" />
|
|
<? if ( is_array( $this -> values['columns_edit'] ) ): foreach ( $this -> values['columns_edit'] as $ce ):?>
|
|
<? if ( $ce['type'] == 'hidden' ):?>
|
|
<input type="hidden" name="<?= $ce['db'];?>" value="<?= $ce['value'];?>" />
|
|
<? else:?>
|
|
<div class="form-group">
|
|
<label for="<?= $ce['db'];?>" class="col col-lg-3 control-label"><?= $ce['name'];?>:</label>
|
|
<? if ( $ce['type'] == 'text' ):?>
|
|
<div class="col col-lg-9">
|
|
<input type="text" class="form-control <? if ( $ce['require'] ):?>require<? endif;?>" name="<?= $ce['db'];?>" id="<?= $ce['db'];?>"
|
|
<?
|
|
if ( is_array( $ce['params'] ) ): foreach( $ce['params'] as $key => $val ):
|
|
echo $key . '="' . $val . '"';
|
|
endforeach; endif;
|
|
?> value="<?= htmlspecialchars( $this -> element[ $ce['db'] ] );?>" <? if ( $ce['readonly-edit'] and $this -> element[ $this -> values['id'] ] ):?>readonly="readonly"<? endif;?> />
|
|
</div>
|
|
<? elseif ( $ce['type'] == 'select' ):?>
|
|
<div class="col col-lg-9">
|
|
<select name="<?= $ce['db'];?>" id="<?= $ce['db'];?>" class="form-control <? if ( $ce['require'] ):?>require<? endif;?>"
|
|
<?
|
|
if ( is_array( $ce['params'] ) ): foreach( $ce['params'] as $key => $val ):
|
|
echo $key . '="' . $val . '"';
|
|
endforeach; endif;
|
|
?>>
|
|
<option value="null">---- <?= $ce['name'];?> ----</option>
|
|
<? if ( $ce['replace']['sql'] ):?>
|
|
<?
|
|
$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>';
|
|
}
|
|
?>
|
|
<? else:?>
|
|
<?
|
|
if ( is_array( $ce['replace']['array'] ) ): foreach ( $ce['replace']['array'] as $key => $val ):
|
|
?>
|
|
<option value="<?= $key;?>"
|
|
<? 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"
|
|
<? endif;?>
|
|
>
|
|
<?= $val;?>
|
|
</option>
|
|
<?
|
|
endforeach; endif;
|
|
?>
|
|
<? endif;?>
|
|
</select>
|
|
</div>
|
|
<? elseif ( $ce['type'] == 'radio' ):?>
|
|
<div class="col col-lg-9">
|
|
<? 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;?>" <? if ( $this -> element[ $ce['db'] ] == $key ):?>checked="checked"<? endif;?> />
|
|
<label for="<?= $ce['db'] . '_' . $key;?>"><?= $val;?></label>
|
|
</div>
|
|
<? endforeach; endif;?>
|
|
</div>
|
|
<? elseif ( $ce['type'] == 'textarea' ):?>
|
|
<div class="col col-lg-8">
|
|
<textarea name="<?= $ce['db'];?>" id="<?= $ce['db'];?>" class="form-control"
|
|
<?
|
|
if ( is_array( $ce['params'] ) ): foreach( $ce['params'] as $key => $val ):
|
|
echo $key . '="' . $val . '"';
|
|
endforeach; endif;
|
|
?>><?= $this -> element[ $ce['db'] ];?></textarea>
|
|
</div>
|
|
<? endif;?>
|
|
</div>
|
|
<? endif;?>
|
|
<? endforeach; endif;?>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|