Skip to content
Browse files

c

  • Loading branch information...
1 parent 9520bad commit d2e44a3ccbe0991b98dbd191d204726a1c955e9b @f-marais committed Aug 15, 2012
View
2 lib/Schema/Result/EntityMaster.pm
@@ -47,6 +47,8 @@ __PACKAGE__->add_columns(
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
"name",
{ data_type => "text", is_nullable => 1 },
+ "type",
+ { data_type => "text", is_nullable => 1 },
"rel_notes",
{ data_type => "text", is_nullable => 1 },
"max_version",
View
2 lib/Schema/Result/StmListVw.pm
@@ -15,7 +15,7 @@ select c.name em_nm,b.name tgt_ent_nm,a.name tgt_itm_nm,
ifnull(f.src_itm_type,' ') src_itm_type,
ifnull(f.src_itm_precision,' ') src_itm_precision,
ifnull(f.src_ent_nm,' ') src_ent_nm,
- a.deflt
+ a.deflt, a.seq
from item a join entity b on a.et_id=b.et_id
join entity_master c on b.em_id=c.em_id
join (select c.tgt_id,d.name src_itm_nm,
View
117 mojo/lib/Rpt.pm
@@ -1,117 +0,0 @@
-package Web::Rpt::Mis;
-use strict;
-use warnings;
-use Mojo::Base 'Mojolicious::Controller';
-
-# Action
-sub show {
- shift->render(inline => <<EOF,layout=>'kromco');
- <h2>MIS Report Parameters </h2>
- <form method="post" action="<%= url_for %>" >
- <table><tr><td> Order Number:</td><td>
- <input type="text" name="orderno" ></td></tr>
- <tr><td>Customer Number:</td> <td>
- <input type="text" name="custno" > </td></tr>
- <tr><td>Receipts Start Date:</td> <td>
- <input type="text" name="startdate" > </td></tr><tr>
- <td>Receipts End Date:</td> <td>
- <input type="text" name="enddate" ></td></tr><tr>
- <tr><td>Receipt:</td> <td>
- <input type="text" name="receiptnr" > </td></tr>
- <tr><td>Exit Ref:</td> <td>
- <input type="text" name="exit_ref" > </td></tr>
- <tr><td>Farm:</td> <td>
- <input type="text" name="farm_id" > </td></tr>
- <tr><td>Farm SubGroup:</td> <td>
- <input type="text" name="farm_subgroup" > </td></tr>
- <tr><td>Class:</td> <td>
- <input type="text" name="line_type" > </td></tr>
- <tr><td>Fruit Type:</td> <td>
- <input type="text" name="fruit_type" > </td></tr>
- <tr><td>Customer Cat:</td> <td>
- <input type="text" name="custcat" > </td></tr>
- <tr><td>Currency:</td> <td>
- <input type="text" name="currency" > </td></tr>
- <tr><td>Season:</td> <td>
- <input type="text" name="season" > </td></tr>
- <td>Maximum rows in displayed result:</td> <td>
- <input type="text" name="maxrows" >
- </td></tr> </table>
-<BR><table><tr><td><h3>Count</h3></td><td></td></tr>
-<tr><td>Equivalent</td><td>
-%= radio_button Count => 'Equivalent'
-</td></tr><tr><td>Actual</td><td>
-%= radio_button Count => 'Actual', id => 'count'
-</td></tr></table>
- <input type="submit" id="sb" value="Run Report" >
- </form>
-EOF
-}
-
-sub run {
- my $self = shift; # ($self is Mojolicious::Controller object)
-
- my $order = $self->param('orderno');
- my $message = $self->param('message');
-
- return $self->render(template => 'error',
- message => 'Please input both Start and End date for Receipts')
- unless ($self->param('startdate')
- && $self->param('enddate'));
-
- my $sql_fn;
- $sql_fn=$ENV{MIS} . '/prg/rp0017.sql';
- open my $sql_fh,"<",$sql_fn or die "Cannot open sql file";
-
- my $sql=do{local $/;<$sql_fh>};
-
- my $hr=$self->req->body_params->to_hash;
- $self->stash(prm=>$hr);
- my $prms ='';
- $prms .= $_ . ":" . $hr->{$_} . "," for keys %$hr;
- $self->app->log->debug('Client:' . $self->tx->remote_address . ' is requesting ' . $prms);
-
- Web::subst(\$sql,'ORDER',$self->param('orderno'));
- Web::subst(\$sql,'CUST',$self->param('custno'));
- Web::subst(\$sql,'STARTDATE',$self->param('startdate'));
- Web::subst(\$sql,'ENDDATE',$self->param('enddate'));
- Web::subst(\$sql,'RECEIPT',$self->param('receiptnr'));
- Web::subst(\$sql,'EXITREF',$self->param('exit_ref'));
- Web::subst(\$sql,'FARMID',$self->param('farm_id'));
- Web::subst(\$sql,'FARMSG',$self->param('farm_subgroup'));
- Web::subst(\$sql,'LINETYPE',$self->param('line_type'));
- Web::subst(\$sql,'FRUITTYPE',$self->param('fruit_type'));
- Web::subst(\$sql,'CUSTCAT',$self->param('custcat'));
- Web::subst(\$sql,'CURRENCY',$self->param('currency'));
- Web::subst(\$sql,'SEASON',$self->param('season'));
- if ($self->param('Count') eq 'Actual')
- {
- $sql =~s/\[< EQV_COUNT >\]/actual_count/gm;
- $sql =~s/\[< EQV_QTY >\]/carton_quantity/gm;
- }
- else
- {
- $sql =~s/\[< EQV_COUNT >\]/equivalent_count/gm;
- $sql =~s/\[< EQV_QTY >\]/equivalent_quantity/gm;
- }
- $sql =~s/where\s*?;/;/msi;
- $self->stash(sql=>$sql);
- $self->stash(maxrows=>$self->param('maxrows')
- || 25);
-
- # $self->stash(hdr=>qq {<br>hdr<br>});
- #-----------------------------------------
- # This is a routine to put a comma after
- # the 1st 3 chars of the objects column
- #
- $self->stash(col_cb=>sub { });
- return $self->render(template=>'/tabout')
-};
-
-1;
-
-=head1 MIS Report
-
-Reports on MIS data
-
-=cut
View
19 mojo/lib/STM.pm
@@ -62,22 +62,17 @@ sub startup {
$self->redirect_to('/');
});
-# $r->get('/rpt/:controller')->to( controller=>'notf',
-# action=>'show', namespace=>'Web::Rpt');
-# $r->post('/rpt/:controller')->to( controller=>'notf',
-# action=>'run', namespace=>'Web::Rpt');
-# # Documentation browser under "/perldoc"
-#
- $auth->route('/:route', route => [ qw(upload search itmdet stmlist ) ])
- ->to( cb => sub {
+ $auth->route('/logout')->to('lobby#logout');
+ $auth->route('/about')->to('lobby#about');
+ $auth->route('/:user_type/menu')->to('lobby#signed_in_menu');
+ # $auth->route('/:controller/:action')->to('sql#notf');
+ $auth->route('/:route'
+# route => [ qw(upload search itmdet stmlist ) ]
+ )->to( cb => sub {
my $self=shift;
return $self->render($self->stash('route'));
});
- $auth->route('/logout')->to('lobby#logout');
- $auth->route('/about')->to('lobby#about');
- $auth->route('/:user_type/menu')->to('lobby#signed_in_menu');
- $auth->route('/:controller/:action')->to('sql#notf');
}
1;
View
100 mojo/lib/STM/Sql.pm
@@ -1,100 +0,0 @@
-package STM::Sql;
-use Mojo::Base 'Mojolicious::Controller';
-
-use utf8;
-
-sub tgt_ent_det {
- my $self = shift;
- my ( $rs );
- $rs = $self->app->schema->resultset('EntDetVw')->search(
- {
- 'me.tgt_ent_nm' => $self->param("tgt"),
- 'me.em_nm' => $self->param("em")
- },
- { columns => [qw(tgt_itm_nm type bus_rule src_itm_nm src_ent_nm )]}
- );
- my $ent_nm =
- $self->render_partial( text => '<H3>'
- . $self->param("em") . ":"
- . $self->param("tgt")
- . " as Target"
- . '</H3>' );
- my $tb = $self->render_partial(
- template => '/tabout',
- title => 'Entity Detail - Target',
- rs => $rs,
- chk_blanks => 3
- );
-
- # check if 1st col same as prev row,
- # if so, blank out 1st 3 cols
- $self->render( text => $ent_nm . $tb . '<BR>' );
-}
-
-sub src_ent_det {
- my $self = shift;
- my ( $rs, $disp_end, $srch, @cols, $chk_blanks );
- $rs = $self->app->schema->resultset('EntDetVw')->search(
- {
- 'me.tgt_ent_nm' => $self->param("tgt"),
- 'me.src_ent_nm' => $self->param("src"),
- 'me.em_nm' => $self->param("em")
- },
- {
- columns => [
- qw(tgt_itm_nm type bus_rule src_itm_nm
- src_ent_nm )
- ]
- }
- );
- my $ent_nm = $self->render_partial(
- text => '<H3>' . $self->param("em") . ":"
- . $self->param("src") . " as Source for "
- . $self->param("tgt") . '</H3>' );
- my $tb = $self->render_partial(
- template => '/tabout',
- title => 'Entity Detail - Source + Target',
- rs => $rs,
- chk_blanks => 0
- );
-
- $self->render( text => $ent_nm . $tb . '<BR>' );
-}
-
-sub itm_det {
- my $self = shift;
- my $ent_nm =
- $self->render_partial( text => '<H3>' . $self->param("for") . '</H3>' );
- $self->stash(
- sql => q{select a.name, a.type, ' in ',
- b.name
- from item a join entity b
- on a.et_id=b.et_id
- left join (select c.tgt_id,d.name src_itm_nm,
- e.name src_ent_nm,d.seq src_seq
- from i2i c, item d, entity e
- where c.src_id=d.it_id and d.et_id=e.et_id) f
- on a.it_id=f.tgt_id
- where b.name='} . $self->param("for") . q{'
- order by a.seq,f.src_seq }
- );
-
- # $self->stash(col_cb=>sub { });
- my $tb = $self->render_partial(
- template => '/tabout',
- title => 'Entity Detail',
- chk_blanks => 3
- ); # check if 1st col same as prev row,
- # if so, blank out 1st 3 cols
- $self->render( text => $ent_nm . $tb . '<BR>' );
-}
-
-sub notf {
- my $self = shift;
- $self->render(
- title => 'Not Found at all',
- text => 'Page Not Found at all'
- );
-}
-
-1;
View
10 mojo/templates/entdet.html.ep
@@ -0,0 +1,10 @@
+% title 'Entity:' . param('ent');
+% my $rs;
+% $rs = $self->app->schema->resultset('Entity')->search(
+% { 'me.name' => param('ent'),
+% 'em.name' => param('em') },{
+% join=> 'em',
+% columns => [qw(name scope type description )]});
+<%= include 'showrs', partial => 1,
+ title => 'Entity', rs=> $rs, chk_blanks => 0, url => {} %>
+<br>
View
9 mojo/templates/search.html.ep
@@ -14,7 +14,7 @@
% {max_version => 1});
% while (my $em=$em_rs->next) {
<H3><%= $em->name %></H3>
-% my $rs = $self->app->schema->resultset('EntDetVw')->search(
+% my $rs = $self->app->schema->resultset('StmListVw')->search(
% \[ 'em_nm=? AND (tgt_ent_nm like ? OR src_ent_nm like ?) ',
% [ 'em_nm', $em->name ],
% [ 'tgt_ent_nm', '%' . param('match') . '%' ],
@@ -23,7 +23,10 @@
% distinct => 1});
<%= include 'showrs', partial => 1,
title => 'Entity', rs=> $rs, chk_blanks => 0 ,
- url => {src_ent_nm => '/stmlist?tgt=tgt_ent_nm&src=src_ent_nm'}
+ url => {src_ent_nm => '/stmlist?em='
+ . $em->name . '&tgt=tgt_ent_nm&src=src_ent_nm',
+ tgt_ent_nm => '/stmlist?em='
+ . $em->name . '&tgt=tgt_ent_nm'}
%>
% }
<br>
@@ -34,7 +37,7 @@
% {max_version => 1});
% while (my $em=$em_rs->next) {
<H3><%= $em->name %></H3>
-% my $rs = $self->app->schema->resultset('EntDetVw')->search(
+% my $rs = $self->app->schema->resultset('StmListVw')->search(
% \[ 'tgt_itm_nm like ? OR src_itm_nm like ? ',
% [ 'em_nm', $em->name ],
% [ 'tgt_itm_nm', '%' . param('match') . '%' ],
View
2 mojo/templates/showrs.html.ep
@@ -53,7 +53,7 @@
% my $ul=$url->{$col};
% $ul=~s/$_/$row->$_/eg for @cols;
% $ul=url_for $ul;
-% $cel = '<a href=' . $ul . '>' . $row->$col . '</a>';
+% $cel = '<a href=' . $ul . q{>} . $row->$col . '</a>';
% } elsif (exists $urlfor{$col} && defined $urlfor{$col} ) {
% my $ul=$urlfor{$col};
% $ul=~s/$col/$row->$col/eg;
View
39 mojo/templates/stmlist.html.ep
@@ -0,0 +1,39 @@
+% title 'Entity Detail';
+% my $rs;
+% my $cols= [ qw( tgt_itm_nm tgt_itm_type tgt_itm_precision tgt_itm_scale
+% bus_rule src_itm_nm
+% src_itm_type src_itm_precision src_ent_nm deflt) ];
+<H3> <%= (param('tgt') ? 'Target:' . param('tgt')
+ : ' ') . (param('src') ? 'Source:' . param('src') : ' ') %></H3>
+% if (param('src')) {
+% if (param('tgt')) {
+<br><%= param('src') %><a href=<%= $self->url_for('/stmlist?em='
+ . param('em') . '&src=' . param('src')) %>> as Source</a>
+% $rs = $self->app->schema->resultset('StmListVw')->search(
+% { 'tgt_ent_nm' => param('tgt'),
+% 'em_nm' => param('em'),
+% 'src_ent_nm' => param('src') },{
+% columns=> [qw(tgt_itm_nm tgt_itm_type tgt_itm_precision
+% tgt_itm_scale bus_rule src_itm_nm src_itm_type
+% src_itm_precision deflt )] ,
+% distinct => 1});
+% } else {
+<br><a href=<%= $self->url_for('/stmlist?em=' . param('em') . '&tgt='
+ . param('src')) %>>Show <%= param('src') %> as Target</a>
+% $rs = $self->app->schema->resultset('StmListVw')->search(
+% { 'src_ent_nm' => param('src') ,
+% 'em_nm' => param('em') },{
+% columns=> [qw(tgt_ent_nm tgt_itm_nm tgt_itm_type
+% tgt_itm_precision tgt_itm_scale bus_rule src_itm_nm
+% src_itm_type src_itm_precision deflt)],distinct => 1});
+% }
+<%= include 'showrs', partial => 1, rs=> $rs, chk_blanks => 0 , url => {} %>
+% } else {
+<br><a href=<%= $self->url_for('/stmlist?em=' . param('em') . '&src='
+ . param('tgt')) %>>Show <%= param('tgt') %> as Source</a>
+% $rs = $self->app->schema->resultset('StmListVw')->search(
+% { 'tgt_ent_nm' => param('tgt'), 'em_nm' => param('em') },
+% {columns=> $cols, order_by => 'seq',distinct => 1});
+<%= include 'showrs', partial => 1, rs=> $rs, chk_blanks => 5 , url => {} %>
+% }
+<br>
View
8 mojo/templates/uploadrun.html.ep
@@ -1,8 +0,0 @@
-% title 'Upload';
-Thanks for uploading <%= $size %> byte file <%= $name %>.<br>
-% sleep 3;
-
-<!--
-my $x= join("<br>",split (/\n/, qx[$ENV{MIS}/parsexcel.pl $ENV{MIS}/tmp/$name] ));
-
--->
View
7 script/parsexcel.pl
@@ -340,10 +340,12 @@ =head1 Testing
select c.name ,count(*)
from entity c, entity_master d
-where c.em_id=d.em_id and d.version=0.04
+where c.em_id=d.em_id
group by c.name
order by c.name;
+select * from entity;
+
select d.name,d.version,count(distinct c.name)
from entity c, entity_master d
where c.em_id=d.em_id group by d.name,d.version;
@@ -378,5 +380,4 @@ =head1 Items per entity master
)
AND name = 'FEWR dfsdfs';
-
-
+update entity_master set name = 'CBS Rewards' ;

0 comments on commit d2e44a3

Please sign in to comment.
Something went wrong with that request. Please try again.