first commit
This commit is contained in:
419
libraries/grid/templates/container.php
Normal file
419
libraries/grid/templates/container.php
Normal file
@@ -0,0 +1,419 @@
|
||||
<? $this -> values['name'] ? $g_table = $this -> values['name'] : $g_table = $this -> values[ 'table' ];?>
|
||||
<div class="g-container" id="g-<?= $g_table;?>" data="table:<?= $g_table;?>">
|
||||
<?
|
||||
if (
|
||||
$this -> values['actions']['add'] === true
|
||||
or
|
||||
$this -> values['actions']['edit']
|
||||
or
|
||||
is_array( $this -> values['buttons'] )
|
||||
or
|
||||
$this -> values['hide_columns']
|
||||
or
|
||||
$this -> values['csv']
|
||||
or
|
||||
$this -> values['print']
|
||||
):?>
|
||||
<div class="row mb10" style="height: 50px;">
|
||||
<?
|
||||
if ( $this -> values['title'] )
|
||||
echo '<div id="g-title">' . $this -> values['title'] . '</div>';
|
||||
?>
|
||||
<? if ( ( ( $this -> values['actions']['add'] === true or $this -> values['actions']['edit'] ) ) || is_array( $this -> values['buttons'] ) ):?>
|
||||
<div class="col-xs-12 col-md-9" id="g-menu">
|
||||
<? if ( $this -> values['actions']['add'] === true ):?>
|
||||
<a href="#" id="g-add" class="btn btn-success btn-sm mr5">
|
||||
<i class="fa fa-plus-circle mr5"></i>Dodaj
|
||||
</a>
|
||||
<? endif;?>
|
||||
<a href="#" id="g-save" class="btn btn-success btn-sm mr5" url="<?= $this -> values['actions']['add_url'];?>" <? if ( $this -> values['actions']['back_url'] ):?>back_url="<?= $this -> values['actions']['back_url'];?>"<? endif;?>>
|
||||
<i class="fa fa-check-circle mr5"></i>Zatwierdź
|
||||
</a>
|
||||
<a href="#" id="g-cancel" class="btn btn-danger btn-sm mr5">
|
||||
<i class="fa fa-times-circle mr5"></i>Anuluj
|
||||
</a>
|
||||
<? if ( $this -> values['multiselect'] and $this -> values['actions']['delete'] ):?>
|
||||
<a href="#" id="g-multidelete" class="btn btn-danger btn-sm mr5" <? if ( $this -> values['multidelete_url'] ):?>url="<?= $this -> values['multidelete_url'];?>"<? endif;?>>
|
||||
<i class="fa fa-times-circle mr5"></i>Usuń wybrane
|
||||
</a>
|
||||
<? endif;?>
|
||||
<?
|
||||
if ( is_array( $this -> values['buttons'] ) )
|
||||
{
|
||||
foreach ( $this -> values['buttons'] as $button )
|
||||
{
|
||||
echo \Html::button(
|
||||
array(
|
||||
'class' => $button['toggle'] === true ? $button['class'] . ' g-toggle btn-sm mr5' : $button['class'] . ' btn-sm mr5',
|
||||
'url' => $button['url'] != '' ? $button['url'] : null,
|
||||
'text' => $button['label'],
|
||||
'icon' => $button['icon'],
|
||||
'js' => $button['js'] != '' ? $button['js'] : null,
|
||||
'style' => $button['toggle'] === true ? 'display: none; ' . $button['style'] : $button['style']
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<? endif;?>
|
||||
<div class="col col-xs-12 col-md-3 pull-right">
|
||||
<div class="row mb10" style="position: relative;">
|
||||
<div class="col col-xs-12">
|
||||
<? if ( $this -> values['hide_columns'] ):?>
|
||||
<a href="#" id="g-select-columns" class="btn btn-dark pull-right ml5" title="pokaż/ukryj kolumny">
|
||||
<i class="fa fa-bars"></i>
|
||||
</a>
|
||||
<a href="#" id='g-columns-list-close' class="btn btn-danger pull-right ml5" onclick="jQuery( '#g-columns-list' ).toggle(); return false;">
|
||||
<i class='fa fa-close fa-lg'></i>
|
||||
</a>
|
||||
<? endif;?>
|
||||
<? if ( $this -> values['csv'] ):?>
|
||||
<a href="#" class="btn btn-dark pull-right g-csv ml5" title="eksportuj do pliku csv">
|
||||
<i class="fa fa-save mr5"></i> csv
|
||||
</a>
|
||||
<? endif;?>
|
||||
<? if ( $this -> values['print'] ):?>
|
||||
<a href="#" class="btn btn-dark pull-right g-print ml5" title="drukuj">
|
||||
<i class="fa fa-print"></i>
|
||||
</a>
|
||||
<? endif;?>
|
||||
</div>
|
||||
<div id="g-columns-list" data="table:<?= $g_table;?>">
|
||||
<ul>
|
||||
<?
|
||||
if ( is_array( $this -> values['columns_view'] ) )
|
||||
{
|
||||
$i = 0;
|
||||
foreach ( $this -> values['columns_view'] as $column )
|
||||
{
|
||||
if ( $column['autoincrement'] === null and $column['action'] === null )
|
||||
{
|
||||
?>
|
||||
<li i="<?= $i;?>">
|
||||
<input type="checkbox" class="g-column-toggle" <? if ( $this -> values['hidden_columns'][$i] !== 'true' ):?>checked="checked"<? endif;?> id="<?= $g_table . '-' . $i;?>" />
|
||||
<span input="<?= $g_table . '-' . $i;?>"><?= $column['name'];?></span>
|
||||
</li>
|
||||
<?
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<? endif;?>
|
||||
<div id="g-results">
|
||||
<?= $this -> values['content'];?>
|
||||
</div>
|
||||
<div id="g-loader"></div>
|
||||
</div>
|
||||
<? if ( $this -> values['include_plugins'] ):?>
|
||||
<script type="text/javascript">
|
||||
var dir = '<?= gdir;?>';
|
||||
</script>
|
||||
<!-- iradio -->
|
||||
<link rel='stylesheet' type='text/css' href='<?= gdir;?>/plugins/icheck/skins/minimal/minimal.css' />
|
||||
<link rel='stylesheet' type='text/css' href='<?= gdir;?>/plugins/icheck/skins/minimal/blue.css' />
|
||||
<script type="text/javascript" src="<?= gdir;?>/plugins/icheck/icheck.min.js"></script>
|
||||
<!-- ipromptu -->
|
||||
<link rel='stylesheet' type='text/css' href='<?= gdir;?>/plugins/impromptu/jquery-impromptu.css' />
|
||||
<script type='text/javascript' src='<?= gdir;?>/plugins/impromptu/jquery-impromptu.js'></script>
|
||||
<!-- tooltip -->
|
||||
<link rel='stylesheet' type='text/css' href='<?= gdir;?>/plugins/tooltipster-master/css/tooltipster.css' />
|
||||
<link rel='stylesheet' type='text/css' href='<?= gdir;?>/plugins/tooltipster-master/css/themes/tooltipster-punk.css' />
|
||||
<script type='text/javascript' src='<?= gdir;?>/plugins/tooltipster-master/js/jquery.tooltipster.js'></script>
|
||||
<!-- context menu -->
|
||||
<link rel="stylesheet" type="text/css" href="<?= gdir;?>/plugins/jq-context-menu/context.standalone.css" />
|
||||
<script type="text/javascript" src="<?= gdir;?>/plugins/jq-context-menu/context.js"></script>
|
||||
<!-- grid -->
|
||||
<link rel="stylesheet" type="text/css" href="<?= gdir;?>/css/grid.css" />
|
||||
<script type="text/javascript" src="<?= gdir;?>/js/grid.js"></script>
|
||||
<? endif;?>
|
||||
<script type="text/javascript">
|
||||
menu_context_<?= str_replace( '-', '_', $g_table );?> = {
|
||||
id: '<?= $g_table;?>-context',
|
||||
data: [
|
||||
{ header: 'Opcje' }
|
||||
<? if ( is_array( $this -> values['columns_view'] ) ): foreach ( $this -> values['columns_view'] as $column ):?>
|
||||
<? if ( $column['action']['type'] == 'button' ):?>
|
||||
, {
|
||||
text: '<i class="fa fa-th-list"></i><?= $column['button']['label'];?>',
|
||||
action: function( e, selector ) {
|
||||
<?
|
||||
if ( $column['action']['js'] )
|
||||
{
|
||||
echo $_SESSION[ 'g' . $g_table ] -> convertStringJS( $column['action']['js'] );
|
||||
echo 'eval( out );';
|
||||
}
|
||||
elseif ( $column['action']['url'] )
|
||||
{
|
||||
echo $_SESSION[ 'g' . $g_table ] -> convertStringJS( $column['action']['url'] );
|
||||
echo 'document.location.href = out;';
|
||||
}
|
||||
?>
|
||||
}
|
||||
}
|
||||
<? endif;?>
|
||||
<? if ( $column['action']['type'] == 'edit' ):?>
|
||||
, {
|
||||
text: '<i class="fa fa-cog"></i>Edytuj',
|
||||
action: function( e, selector ) {
|
||||
<?
|
||||
if ( $column['action']['js'] )
|
||||
{
|
||||
echo $_SESSION[ 'g' . $g_table ] -> convertStringJS( $column['action']['js'] );
|
||||
echo 'eval( out );';
|
||||
}
|
||||
elseif ( $column['action']['url'] )
|
||||
{
|
||||
echo $_SESSION[ 'g' . $g_table ] -> convertStringJS( $column['action']['url'] );
|
||||
echo 'document.location.href = out;';
|
||||
}
|
||||
?>
|
||||
}
|
||||
}
|
||||
<? endif;?>
|
||||
<? if ( $column['action']['type'] == 'delete' ):?>
|
||||
, {
|
||||
text: '<i class="fa fa-trash"></i>Usuń',
|
||||
action: function( e, selector ) {
|
||||
jQuery.prompt( 'Na pewno chcesz usunąć wybrany element?', {
|
||||
title: 'Potwierdź?',
|
||||
submit: function(e,v,m,f) {
|
||||
if ( v == true ) {
|
||||
<?
|
||||
if ( $column['action']['js'] )
|
||||
{
|
||||
echo $_SESSION[ 'g' . $g_table ] -> convertStringJS( $column['action']['js'] );
|
||||
echo 'eval( out );';
|
||||
}
|
||||
elseif ( $column['action']['url'] )
|
||||
{
|
||||
echo $_SESSION[ 'g' . $g_table ] -> convertStringJS( $column['action']['url'] );
|
||||
echo 'document.location.href = out;';
|
||||
}
|
||||
?>
|
||||
}
|
||||
},
|
||||
buttons: {
|
||||
'tak': true,
|
||||
'nie': false
|
||||
},
|
||||
focus: 1
|
||||
});
|
||||
}
|
||||
}
|
||||
<? endif;?>
|
||||
<? endforeach; endif;?>
|
||||
<? if ( $this -> values['actions']['edit'] and $this -> values['src'] === null ):?>
|
||||
, {
|
||||
text: '<i class="fa fa-cog"></i>Edytuj',
|
||||
action: function( e, selector )
|
||||
{
|
||||
var gedit = selector.attr( '<?= $this -> values['id'];?>' );
|
||||
|
||||
var data = selector.parents( '.g-container' ).attr( 'data' );
|
||||
data = data.split( ";" );
|
||||
|
||||
for ( index = 0; index < data.length; ++index )
|
||||
{
|
||||
var vars = data[ index ].split( ':') ;
|
||||
|
||||
if ( vars[0] === 'table' )
|
||||
var gtable = vars[1];
|
||||
}
|
||||
jQuery.ajax(
|
||||
{
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: dir + '/ajax.php',
|
||||
data:
|
||||
{
|
||||
gtable: gtable,
|
||||
gedit: gedit,
|
||||
a: 'gedit'
|
||||
},
|
||||
beforeSend: function()
|
||||
{
|
||||
jQuery( '.dropdown-menu' ).hide();
|
||||
jQuery( "#g-" + gtable ).find( '#g-loader' ).show();
|
||||
},
|
||||
success: function( data )
|
||||
{
|
||||
response = jQuery.parseJSON( data ); jQuery( '.g-container' ).find( '#g-loader' ).hide();
|
||||
if ( response.status === 'ok' )
|
||||
{
|
||||
jQuery( '#g-add, #g-search' ).hide();
|
||||
jQuery( '#g-cancel, #g-save' ).show();
|
||||
jQuery( '#g-' + gtable ).find( '#g-results' ).empty().html( response.output );
|
||||
}
|
||||
else
|
||||
{
|
||||
return jQuery.prompt( "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie.", {
|
||||
title: "Błąd",
|
||||
buttons: { "Zamknij": true }
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
<? endif;?>
|
||||
<? if ( $this -> values['actions']['delete'] and $this -> values['src'] === null ):?>
|
||||
, {
|
||||
text: '<i class="fa fa-trash"></i>Usuń',
|
||||
action: function( e, selector )
|
||||
{
|
||||
jQuery.prompt( 'Na pewno chcesz usunąć wybrany element?',
|
||||
{
|
||||
title: 'Potwierdź?',
|
||||
submit: function(e,v,m,f)
|
||||
{
|
||||
if ( v == true )
|
||||
{
|
||||
var gdelete = selector.attr( '<?= $this -> values['id'];?>' );
|
||||
var url = selector.find( '.g-delete' ).attr( 'url' ).replace( '[ID]', gdelete );
|
||||
|
||||
var data = selector.parents( '.g-container' ).attr( 'data' );
|
||||
data = data.split( ";" );
|
||||
|
||||
for ( index = 0; index < data.length; ++index )
|
||||
{
|
||||
var vars = data[ index ].split( ':') ;
|
||||
|
||||
if ( vars[0] === 'table' )
|
||||
var gtable = vars[1];
|
||||
}
|
||||
|
||||
if ( url !== '' )
|
||||
{
|
||||
jQuery.ajax(
|
||||
{
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: url,
|
||||
data:
|
||||
{
|
||||
gdelete: gdelete,
|
||||
a: 'gdelete'
|
||||
},
|
||||
beforeSend: function()
|
||||
{
|
||||
jQuery( '.dropdown-menu' ).hide();
|
||||
jQuery( "#g-" + gtable ).find( '#g-loader' ).show();
|
||||
},
|
||||
success: function( data )
|
||||
{
|
||||
response = jQuery.parseJSON( data ); jQuery( '.g-container' ).find( '#g-loader' ).hide();
|
||||
if ( response.status === 'ok' )
|
||||
{
|
||||
if ( response.msg !== null )
|
||||
create_message( response.msg );
|
||||
|
||||
jQuery.ajax(
|
||||
{
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: dir + '/ajax.php',
|
||||
data:
|
||||
{
|
||||
gtable: gtable,
|
||||
a: 'gdraw'
|
||||
},
|
||||
beforeSend: function()
|
||||
{
|
||||
jQuery( "#g-" + gtable ).find( '#g-loader' ).show();
|
||||
},
|
||||
success: function( data )
|
||||
{
|
||||
response = jQuery.parseJSON( data ); jQuery( '.g-container' ).find( '#g-loader' ).hide();
|
||||
if ( response.status === 'ok' )
|
||||
{
|
||||
jQuery( '#g-' + gtable ).find( '#g-results' ).empty().html( response.output );
|
||||
}
|
||||
else
|
||||
{
|
||||
return jQuery.prompt( "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie.", {
|
||||
title: "Błąd",
|
||||
buttons: { "Zamknij": true }
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
return jQuery.prompt( "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie.", {
|
||||
title: "Błąd",
|
||||
buttons: { "Zamknij": true }
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
jQuery.ajax(
|
||||
{
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: dir + '/ajax.php',
|
||||
data:
|
||||
{
|
||||
gtable: gtable,
|
||||
gdelete: gdelete,
|
||||
a: 'gdraw'
|
||||
},
|
||||
beforeSend: function()
|
||||
{
|
||||
jQuery( "#g-" + gtable ).find( '#g-loader' ).show();
|
||||
},
|
||||
success: function( data )
|
||||
{
|
||||
response = jQuery.parseJSON( data ); jQuery( '.g-container' ).find( '#g-loader' ).hide();
|
||||
if ( response.status === 'ok' )
|
||||
{
|
||||
|
||||
if ( response.msg !== null )
|
||||
create_message( response.msg );
|
||||
|
||||
jQuery( '#g-' + gtable ).find( '#g-results' ).empty().html( response.output );
|
||||
}
|
||||
else
|
||||
{
|
||||
return jQuery.prompt( "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie.", {
|
||||
title: "Błąd",
|
||||
buttons: { "Zamknij": true }
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
buttons: {
|
||||
'tak': true,
|
||||
'nie': false
|
||||
},
|
||||
focus: 1
|
||||
});
|
||||
}
|
||||
}
|
||||
<? endif;?>
|
||||
]
|
||||
};
|
||||
jQuery( function() {
|
||||
context.init({
|
||||
preventDoubleContext: true,
|
||||
above: 'auto'
|
||||
});
|
||||
jQuery( '#g-columns-list input[type="checkbox"]' ).iCheck({
|
||||
checkboxClass: 'icheckbox_minimal-blue',
|
||||
radioClass: 'iradio_minimal-blue'
|
||||
});
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user