1 package SGN
::Controller
::Catalog
;
4 use URI
::FromHash
'uri';
5 use SGN
::Model
::Cvterm
;
6 use CXGN
::People
::Person
;
9 BEGIN { extends
'Catalyst::Controller'; }
12 sub stock_catalog
:Path
('/catalog/view') :Args
(0) {
17 $c->res->redirect( uri
( path
=> '/user/login', query
=> { goto_url
=> $c->req->uri->path_query } ) );
22 my $check_vendor_role = $c->user->check_roles('vendor');
23 $c->stash->{check_vendor_role
} = $check_vendor_role;
26 my $ordering_service_name = $c->config->{ordering_service_name
};
27 $c->stash->{ordering_service_name
} = $ordering_service_name;
29 my $additional_order_info = $c->config->{additional_order_info
};
30 $c->stash->{additional_order_info
} = $additional_order_info;
32 my $ordering_type = $c->config->{ordering_type
};
33 $c->stash->{ordering_type
} = $ordering_type;
35 my $order_properties = $c->config->{order_properties
};
36 my $order_properties_dialog = $c->config->{order_properties_dialog
};
38 $c->stash->{order_properties
} = $order_properties;
39 $c->stash->{order_properties_dialog
} = $order_properties_dialog;
41 $c->stash->{template
} = '/order/catalog.mas';
45 sub catalog_item_details
: Path
('/catalog/item_details') Args
(1) {
48 my $dbh = $c->dbc->dbh;
51 $c->res->redirect( uri
( path
=> '/user/login', query
=> { goto_url
=> $c->req->uri->path_query } ) );
56 my $check_vendor_role = $c->user->check_roles('vendor');
57 $c->stash->{check_vendor_role
} = $check_vendor_role;
61 # print STDERR "CATALOG STOCK ID =".Dumper($item_id)."\n";
62 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
63 my $schema = $c->dbic_schema('Bio::Chado::Schema', 'sgn_chado', $sp_person_id);
64 my $stock_catalog_type_id = SGN
::Model
::Cvterm
->get_cvterm_row($c->dbic_schema("Bio::Chado::Schema", undef, $sp_person_id), 'stock_catalog_json', 'stock_property')->cvterm_id();
66 my $stock_catalog_info = $schema->resultset("Stock::Stockprop")->find({stock_id
=> $item_id, type_id
=> $stock_catalog_type_id});
69 if (!$stock_catalog_info){
70 $c->stash->{template
} = '/generic_message.mas';
71 $c->stash->{message
} = 'The requested catalog item does not exist.';
74 $item_prop_id = $stock_catalog_info->stockprop_id();
77 my $stock_catalog_item = $schema->resultset("Stock::Stock")->find({stock_id
=> $item_id});
78 my $item_name = $stock_catalog_item->uniquename();
79 my $organism_id = $stock_catalog_item->organism_id();
80 my $organism = $schema->resultset("Organism::Organism")->find({organism_id
=> $organism_id});
81 my $species = $organism->species();
83 my $item_obj = CXGN
::Stock
::Catalog
->new({ bcs_schema
=> $schema, parent_id
=> $item_id});
84 my $details_ref = $item_obj->get_item_details();
85 my @item_details = @
$details_ref;
86 print STDERR
"ITEM DETAILS =".Dumper
(\
@item_details)."\n";
87 my $item_type = $item_details[0];
88 my $species = $item_details[1];
89 my $variety = $item_details[2];
90 my $material_type = $item_details[3];
91 my $category = $item_details[4];
92 my $material_source = $item_details[5];
93 my $additional_info = $item_details[6];
94 my $program_id = $item_details[7];
95 my $availability = $item_details[8];
97 $availability = 'available';
99 my $contact_person_id = $item_details[9];
100 my $images = $item_details[10];
101 my $image_id = $images->[0];
102 my $image_obj = SGN
::Image
->new($dbh, $image_id);
103 my $medium_image = $image_obj->get_image_url("medium");
105 my $person = CXGN
::People
::Person
->new($dbh, $contact_person_id);
106 my $contact_person_username = $person->get_username;
108 my $program_rs = $schema->resultset('Project::Project')->find({project_id
=> $program_id});
109 my $program_name = $program_rs->name();
111 # print STDERR "CONTACT PERSON NAME=".Dumper($contact_person_username)."\n";
112 $c->stash->{item_id
} = $item_id;
113 $c->stash->{item_name
} = $item_name;
114 $c->stash->{item_type
} = $item_type;
115 $c->stash->{species
} = $species;
116 $c->stash->{variety
} = $variety;
117 $c->stash->{material_type
} = $material_type;
118 $c->stash->{category
} = $category;
119 $c->stash->{material_source
} = $material_source;
120 $c->stash->{additional_info
} = $additional_info;
121 $c->stash->{program_id
} = $program_id;
122 $c->stash->{breeding_program
} = $program_name;
123 $c->stash->{availability
} = $availability;
124 $c->stash->{contact_person_username
} = $contact_person_username;
125 $c->stash->{item_prop_id
} = $item_prop_id;
126 $c->stash->{image
} = qq|<a href
="$medium_image" class="stock_image_group" rel
="gallery-figures"><img src
="$medium_image"/></a> |,
127 $c->stash->{selected_image_id
} = $image_id;
128 $c->stash->{main_page
} = qq{<a href
="/stock/$item_id/view">$item_name</a
>};
130 $c->stash->{template
} = '/order/catalog_item_details.mas';