Permalink
Browse files

Added flexigrid to report

  • Loading branch information...
1 parent 1bbdabe commit 9eaaa89314c43bd6ebad7a4a36f3e5605c9ab898 @kthakore committed Jan 28, 2011
@@ -28,27 +28,14 @@ sub base : Chained('/') PathPart('report') CaptureArgs(0) {
$c->response->redirect( $c->uri_for('/unauthorized') )
unless ( grep /(g_admin)/, @roles );
-
- unless( $c->stash->{student_cols} )
- {
- my @stu_cols = $c->model('DB::Student')->result_source()->_columns();
-
- my $student_cols;
-
- foreach(@stu_cols)
- {
- my @key = keys(%$_);
- foreach( sort(@key ))
- {
- push( @$student_cols, { value => $_, text => $_ } );
- }
- }
- $c->stash->{student_cols}= $student_cols;
- }
-
+
+ $c->stash->{student_cols}= $self->_prepare_columns($c, 'DB::Student') unless $c->stash->{student_cols};
+ $c->stash->{supervisor_cols}= $self->_prepare_columns($c, 'DB::Supervisor') unless $c->stash->{supervisor_cols};
+ $c->stash->{advisor_cols}= $self->_prepare_columns($c, 'DB::MeetingAdvisor') unless $c->stash->{advisor_cols};
}
+
sub index : Chained('base') : PathPart('') : Args(0) {
my ( $self, $c ) = @_;
@@ -61,6 +48,43 @@ sub add_query : Chained('base') : PathPart('add_query') : Args(0) {
}
+sub test_query : Chained('base') : PathPart('test_query') : Args(0) {
+ my ( $self, $c ) = @_;
+
+ my $query = {};
+ foreach(0..$c->req->param('count'))
+ {
+ $query->{$c->req->{parameters}->{"column_$_"}} =
+ { $c->req->{parameters}->{"condition_$_"} => $c->req->{parameters}->{"text_$_"} };
+ }
+
+ my @foo =$c->model('DB::Student')->search( $query );
+
+ $c->res->body( Dumper(\@foo) );
+
+ $c->stash(template => 'report/index.tt' );
+
+}
+
+sub _prepare_columns
+{
+ my ($self, $c , $db ) = @_;
+
+ my @stu_cols = $c->model($db)->result_source()->_columns();
+
+ my $student_cols;
+
+ foreach(@stu_cols)
+ {
+ my @key = keys(%$_);
+ foreach( sort(@key ))
+ {
+ push( @$student_cols, { value => $_, text => $_ } );
+ }
+ }
+ return $student_cols;
+}
+
=head1 AUTHOR
Kartik Thakore,,,
@@ -1,6 +1,4 @@
-<script>$("th").css("border","1px solid black");</script>
-
</body>
</html>
@@ -42,7 +42,24 @@
});
</script>
+<style>
+ body
+ {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 12px;
+ }
+ .flexigrid div.fbutton .add
+ {
+ background: url(css/images/add.png) no-repeat center left;
+ }
+ .flexigrid div.fbutton .delete
+ {
+ background: url(css/images/close.png) no-repeat center left;
+ }
+</style>
<script type="text/javascript" src="[% c.uri_for('/static/') %]scripts/jquery-ui-timepicker-addon.js"></script>
+<script type="text/javascript" src="[% c.uri_for('/static/') %]scripts/flexigrid/flexigrid.pack.js"></script>
+<link type="text/css" href="[% c.uri_for('/static/') %]scripts/css/flexigrid/flexigrid.css" rel="stylesheet" />
<style type="text/css">
.ui-timepicker-div .ui-widget-header{ margin-bottom: 8px; }
@@ -1,21 +1,11 @@
[% PROCESS header.tt %]
-
-<script>
-var condition = 0;
-var datum = '';
-function select_data( data, table)
-{
-
- var row;
-
- if( data == 'student')
- {
+[% BLOCK data_col %]
row = $('<tr> </th>');
row.append('<tr><th>Columns To Show</th>');
row.append('<th><select multiple="multiple" name="columns" size="4">'+
- [% FOREACH cols IN student_cols %]
+ [% FOREACH cols IN total_cols %]
'<option value="[%cols.value%]"> [%cols.text%] </option>'+
[% END %]
@@ -25,6 +15,38 @@ function select_data( data, table)
datum = data;
add_condition( table, '');
+
+[% END %]
+
+[% BLOCK data_opt %]
+
+obj = $('<th><select name="column_'+condition+'" id="column_'+condition+'" >'+
+ [% FOREACH cols IN total_cols %]
+ '<option value="[%cols.value%]"> [%cols.text%] </option>'+
+ [% END %]
+ '</select></th>');
+
+[% END %]
+
+<script>
+var condition = 0;
+var datum = '';
+function select_data( data, table)
+{
+
+ var row;
+
+ if( data == 'student')
+ {
+ [% PROCESS data_col total_cols=student_cols %]
+ }
+ else if( data == 'supervisor')
+ {
+ [% PROCESS data_col total_cols=supervisor_cols %]
+ }
+ else if (data == 'advisor')
+ {
+ [% PROCESS data_col total_cols=advisor_cols %]
}
@@ -38,15 +60,18 @@ function options()
'</select>');
if( datum == 'student' )
{
-
- obj = $('<th><select name="column_'+condition+'" id="column_'+condition+'" >'+
- [% FOREACH cols IN student_cols %]
- '<option value="[%cols.value%]"> [%cols.text%] </option>'+
- [% END %]
- '</select></th>');
-
+ [% PROCESS data_opt total_cols=student_cols %]
+ }
+ else if( datum == 'supervisor')
+ {
+ [% PROCESS data_opt total_cols=supervisor_cols %]
+ }
+ else if (datum == 'advisor')
+ {
+ [% PROCESS data_opt total_cols=advisor_cols %]
}
+
return obj;
}
@@ -68,15 +93,14 @@ function add_condition( table,op)
'</th><th>'+
'<input name="text_'+condition+'" id="text_'+condition+'"></th>');
table.append(row);
-
condition++;
}
</script>
<div id="content">
<form id="make_query" action="[%c.uri_for('add_query')%]" method="POST">
-
+<input type="hidden" id="count" />
<table id="query_table">
<tr>
<th>
@@ -103,7 +127,6 @@ $('#datum').change( function(){
{
select_data( value, $('#query_table'));
$('.cond_but').removeAttr('disabled');
- $('#datum').attr('disabled', true);
}
else
{
@@ -112,6 +135,17 @@ $('#datum').change( function(){
});
</script>
<input type="submit" value="save query" />
+<input type="button" value="try query" onclick=" var form = $('#make_query').attr('action', '[%c.uri_for('test_query') %] '); $('<input>').attr({ type: 'hidden', name: 'count', value: condition }).appendTo(form); form.submit()" />
</form>
+[% IF result_data %]
+<table class="flexme">
+</table>
+<script>
+$('.flexme').flexigrid();
+</script>
+
+[% END %]
+
</div>
[% PROCESS footer.tt %]
+
Oops, something went wrong.

0 comments on commit 9eaaa89

Please sign in to comment.