diff --git a/lib/CXGN/Stock/Catalog.pm b/lib/CXGN/Stock/Catalog.pm index 098c8aa32d..2d2cacba48 100644 --- a/lib/CXGN/Stock/Catalog.pm +++ b/lib/CXGN/Stock/Catalog.pm @@ -6,32 +6,39 @@ use Data::Dumper; extends 'CXGN::JSONProp'; -# a general human readable description of the stock -has 'description' => ( isa => 'Str', is => 'rw' ); - # a list of representative images, given as image_ids has 'images' => ( isa => 'Maybe[ArrayRef]', is => 'rw' ); -# availability status: in_stock, delayed, currently_unavailable ... -has 'availability' => ( isa => 'Str', is => 'rw' ); - # list of hashrefs like { stock_center => { name => ..., count_available => ..., delivery_time => } } has 'order_source' => ( isa => 'ArrayRef', is => 'rw'); +# item type such as single accession or a set of 10 accessions +has 'item_type' => ( isa => 'Str', is => 'rw'); + +# material type such as seed or plant +has 'material_type' => ( isa => 'Str', is => 'rw'); + # center that generates clones or seed has 'material_source' => ( isa => 'Str', is => 'rw'); -# item type such as single accession or a set of 10 accessions -has 'item_type' => ( isa => 'Str', is => 'rw'); +has 'category' => ( isa => 'Str', is => 'rw' ); + +has 'species' => ( isa => 'Str', is => 'rw' ); + +has 'variety' => ( isa => 'Str', is => 'rw', required => 0); -# the breeding program this clones originated from has 'breeding_program' => ( isa => 'Int', is => 'rw'); -# -has 'category' => ( isa => 'Str', is => 'rw' ); +has 'additional_info' => ( isa => 'Str', is => 'rw', required => 0 ); has 'contact_person_id' => ( isa => 'Int', is => 'rw') ; +# a general human readable description of the stock +#has 'description' => ( isa => 'Str', is => 'rw' ); + +# availability status: in_stock, delayed, currently_unavailable ... +#has 'availability' => ( isa => 'Str', is => 'rw' ); + sub BUILD { my $self = shift; @@ -42,7 +49,7 @@ sub BUILD { $self->prop_primary_key('stockprop_id'); $self->prop_type('stock_catalog_json'); $self->cv_name('stock_property'); - $self->allowed_fields( [ qw | item_type category description material_source breeding_program availability contact_person_id images | ] ); + $self->allowed_fields( [ qw | item_type species variety material_type category material_source additional_info breeding_program contact_person_id images | ] ); $self->parent_table('stock'); $self->parent_primary_key('stock_id'); @@ -92,7 +99,6 @@ sub get_item_details { foreach my $field (@fields){ push @item_details, $detail_hash->{$field}; } -# print STDERR "ITEM DETAILS =".Dumper(\@item_details)."\n"; return \@item_details; } diff --git a/lib/CXGN/Stock/Order.pm b/lib/CXGN/Stock/Order.pm index e6ce2bf8f8..53fe594560 100644 --- a/lib/CXGN/Stock/Order.pm +++ b/lib/CXGN/Stock/Order.pm @@ -92,34 +92,23 @@ sub get_orders_from_person_id { my $order_to_name=$person->get_first_name()." ".$person->get_last_name(); my $orderprop_rs = $people_schema->resultset('SpOrderprop')->search( { sp_order_id => $order_id } ); + my $all_items = (); while (my $item_result = $orderprop_rs->next()){ my @list; my $item_json = $item_result->value(); my $item_hash = JSON::Any->jsonToObj($item_json); - my $all_items = $item_hash->{'clone_list'}; - foreach my $each_item (@$all_items) { - my $item_name = (keys %$each_item)[0]; - my $quantity = $each_item->{$item_name}->{'quantity'}; - my $comments = $each_item->{$item_name}->{'comments'}; - my $additional_info = $each_item->{$item_name}->{'additional_info'}; - - my $each_item_details; - if ($additional_info && $comments) { - $each_item_details = $item_name . "," . " " . "quantity:" . $quantity . ",". " "."additional info:". $additional_info. "," . " " . "comments:" . $comments; - } elsif ($additional_info && (!$comments)){ - $each_item_details = $item_name . "," . " " . "quantity:" . $quantity . ",". " "."additional info:". $additional_info; - } elsif ((!$additional_info) && $comments) { - $each_item_details = $item_name . "," . " " . "quantity:" . $quantity . "," . " "."comments:" . $comments; - } else { - $each_item_details = $item_name . "," . " " . "quantity:" . $quantity; - } - push @list, $each_item_details; - } - my @sort_list = sort @list; - $item_list = join("
", @sort_list); + $all_items = $item_hash->{'clone_list'}; } - push @orders, [$order_id, $create_date, $item_list, $order_status, $completion_date, $order_to_name, $comments ]; + push @orders, { + order_id => $order_id, + create_date => $create_date, + clone_list => $all_items, + order_status => $order_status, + completion_date => $completion_date, + order_to_name => $order_to_name, + comments => $comments + } } return \@orders; @@ -138,7 +127,6 @@ sub get_orders_to_person_id { my $item_list; my $order_id = $result->sp_order_id(); my $order_from_id = $result->order_from_id(); -# my $order_to_id = $result->order_to_id(); my $order_status = $result->order_status(); my $create_date = $result->create_date(); my $completion_date = $result->completion_date(); @@ -147,44 +135,25 @@ sub get_orders_to_person_id { my $order_from_name=$person->get_first_name()." ".$person->get_last_name(); my $orderprop_rs = $people_schema->resultset('SpOrderprop')->search( { sp_order_id => $order_id } ); + my $all_items = (); while (my $item_result = $orderprop_rs->next()){ my @list; my $item_json = $item_result->value(); my $item_hash = JSON::Any->jsonToObj($item_json); - my $all_items = $item_hash->{'clone_list'}; - foreach my $each_item (@$all_items) { - my $item_name = (keys %$each_item)[0]; - my $quantity = $each_item->{$item_name}->{'quantity'}; - my $comments = $each_item->{$item_name}->{'comments'}; - my $additional_info = $each_item->{$item_name}->{'additional_info'}; - - my $each_item_details; - if ($additional_info && $comments) { - $each_item_details = $item_name . "," . " " . "quantity:" . $quantity . ",". " "."additional info:". $additional_info. "," . " " . "comments:" . $comments; - } elsif ($additional_info && (!$comments)){ - $each_item_details = $item_name . "," . " " . "quantity:" . $quantity . ",". " "."additional info:". $additional_info; - } elsif ((!$additional_info) && $comments) { - $each_item_details = $item_name . "," . " " . "quantity:" . $quantity . "," . " "."comments:" . $comments; - } else { - $each_item_details = $item_name . "," . " " . "quantity:" . $quantity; - } - push @list, $each_item_details; - } - my @sort_list = sort @list; - $item_list = join("
", @sort_list); + $all_items = $item_hash->{'clone_list'}; } push @orders, { order_id => $order_id, order_from_name => $order_from_name, create_date => $create_date, - item_list => $item_list, + clone_list => $all_items, order_status => $order_status, completion_date => $completion_date, contact_person_comments => $comments } } -# print STDERR "ORDERS =".Dumper(\@orders)."\n"; + return \@orders; } @@ -215,30 +184,8 @@ sub get_order_details { my $item_json = $orderprop_rs->value(); my $item_hash = JSON::Any->jsonToObj($item_json); my $all_items = $item_hash->{'clone_list'}; - my @list; - foreach my $each_item (@$all_items) { - my $item_name = (keys %$each_item)[0]; - my $quantity = $each_item->{$item_name}->{'quantity'}; - my $comments = $each_item->{$item_name}->{'comments'}; - my $additional_info = $each_item->{$item_name}->{'additional_info'}; - - my $each_item_details; - if ($additional_info && $comments) { - $each_item_details = $item_name . "," . " " . "quantity:" . $quantity . ",". " "."additional info:". $additional_info. "," . " " . "comments:" . $comments; - } elsif ($additional_info && (!$comments)){ - $each_item_details = $item_name . "," . " " . "quantity:" . $quantity . ",". " "."additional info:". $additional_info; - } elsif ((!$additional_info) && $comments) { - $each_item_details = $item_name . "," . " " . "quantity:" . $quantity . "," . " "."comments:" . $comments; - } else { - $each_item_details = $item_name . "," . " " . "quantity:" . $quantity; - } - push @list, $each_item_details; - } - my @sort_list = sort @list; - my $item_list = join("
", @sort_list); - push @order_details, $order_id, $order_from_name, $create_date, $item_list, $order_to_name, $order_status, $comments; -# print STDERR "DETAILS =".Dumper(\@order_details)."\n"; + push @order_details, $order_id, $order_from_name, $create_date, $all_items, $order_to_name, $order_status, $comments; return \@order_details; diff --git a/lib/CXGN/Stock/ParseUpload/Plugin/CatalogXLS.pm b/lib/CXGN/Stock/ParseUpload/Plugin/CatalogXLS.pm index 30b12028ae..8830a5f16f 100644 --- a/lib/CXGN/Stock/ParseUpload/Plugin/CatalogXLS.pm +++ b/lib/CXGN/Stock/ParseUpload/Plugin/CatalogXLS.pm @@ -35,7 +35,7 @@ sub _validate_with_plugin { my %supported_types; my %supported_categories; my %supported_material_sources; - my %supported_availability; + my %supported_material_types; $supported_types{'single item'} = 1; $supported_types{'set of items'} = 1; @@ -43,13 +43,18 @@ sub _validate_with_plugin { $supported_categories{'released variety'} = 1; $supported_categories{'pathogen assay'} = 1; $supported_categories{'control'} = 1; + $supported_categories{'transgenic line'} = 1; - $supported_material_sources{'OrderingSystemTest'} = 1; - $supported_material_sources{'Sendusu'} = 1; + $supported_material_types{'seed'} = 1; + $supported_material_types{'plant'} = 1; + $supported_material_types{'construct'} = 1; - $supported_availability{'in stock'} = 1; - $supported_availability{'out of stock'} = 1; - $supported_availability{'available in 3 months'} = 1; +# $supported_material_sources{'OrderingSystemTest'} = 1; +# $supported_material_sources{'Sendusu'} = 1; + +# $supported_availability{'in stock'} = 1; +# $supported_availability{'out of stock'} = 1; +# $supported_availability{'available in 3 months'} = 1; #try to open the excel file and report any errors $excel_obj = $parser->parse($filename); @@ -78,61 +83,65 @@ sub _validate_with_plugin { } #get column headers - my $name_header; - my $type_header; + my $item_name_header; + my $item_type_header; + my $material_type_header; my $category_header; - my $description_header; + my $additional_info_header; my $material_source_header; my $breeding_program_header; - my $availability_header; +# my $availability_header; my $contact_person_header; if ($worksheet->get_cell(0,0)) { - $name_header = $worksheet->get_cell(0,0)->value(); + $item_name_header = $worksheet->get_cell(0,0)->value(); } if ($worksheet->get_cell(0,1)) { - $type_header = $worksheet->get_cell(0,1)->value(); + $item_type_header = $worksheet->get_cell(0,1)->value(); } if ($worksheet->get_cell(0,2)) { - $category_header = $worksheet->get_cell(0,2)->value(); + $material_type_header = $worksheet->get_cell(0,2)->value(); } if ($worksheet->get_cell(0,3)) { - $description_header = $worksheet->get_cell(0,3)->value(); + $category_header = $worksheet->get_cell(0,3)->value(); } if ($worksheet->get_cell(0,4)) { - $material_source_header = $worksheet->get_cell(0,4)->value(); + $additional_info_header = $worksheet->get_cell(0,4)->value(); } if ($worksheet->get_cell(0,5)) { - $breeding_program_header = $worksheet->get_cell(0,5)->value(); + $material_source_header = $worksheet->get_cell(0,5)->value(); } if ($worksheet->get_cell(0,6)) { - $availability_header = $worksheet->get_cell(0,6)->value(); + $breeding_program_header = $worksheet->get_cell(0,6)->value(); } if ($worksheet->get_cell(0,7)) { $contact_person_header = $worksheet->get_cell(0,7)->value(); } - if (!$name_header || $name_header ne 'item_name' ) { + if (!$item_name_header || $item_name_header ne 'item_name' ) { push @error_messages, "Cell A1: item_name is missing from the header"; } - if (!$type_header || $type_header ne 'type') { - push @error_messages, "Cell B1: type is missing from the header"; + if (!$item_type_header || $item_type_header ne 'item_type') { + push @error_messages, "Cell B1: item_type is missing from the header"; + } + if (!$material_type_header || $material_type_header ne 'material_type') { + push @error_messages, "Cell C1: material_type is missing from the header"; } if (!$category_header || $category_header ne 'category') { - push @error_messages, "Cell C1: category is missing from the header"; + push @error_messages, "Cell D1: category is missing from the header"; } - if (!$description_header || $description_header ne 'description') { - push @error_messages, "Cell D1: description is missing from the header"; + if (!$additional_info_header || $additional_info_header ne 'additional_info') { + push @error_messages, "Cell E1: additional_info is missing from the header"; } if (!$material_source_header || $material_source_header ne 'material_source') { - push @error_messages, "Cell E1: material_source is missing from the header"; + push @error_messages, "Cell F1: material_source is missing from the header"; } if (!$breeding_program_header || $breeding_program_header ne 'breeding_program') { - push @error_messages, "Cell F1: breeding_program is missing from the header"; - } - if (!$availability_header || $availability_header ne 'availability') { - push @error_messages, "Cell G1: availability is missing from the header"; + push @error_messages, "Cell G1: breeding_program is missing from the header"; } +# if (!$availability_header || $availability_header ne 'availability') { +# push @error_messages, "Cell G1: availability is missing from the header"; +# } if (!$contact_person_header || $contact_person_header ne 'contact_person_username') { push @error_messages, "Cell H1: contact_person_username is missing from the header"; } @@ -144,38 +153,44 @@ sub _validate_with_plugin { my $row_name = $row+1; my $item_name; my $item_type; + my $material_type; my $category; - my $description; + my $additional_info; my $material_source; my $breeding_program; - my $availability; +# my $availability; my $contact_person_username; if ($worksheet->get_cell($row,0)) { $item_name = $worksheet->get_cell($row,0)->value(); + $item_name =~ s/^\s+|\s+$//g; } if ($worksheet->get_cell($row,1)) { $item_type = $worksheet->get_cell($row,1)->value(); $item_type =~ s/^\s+|\s+$//g; } if ($worksheet->get_cell($row,2)) { - $category = $worksheet->get_cell($row,2)->value(); - $category =~ s/^\s+|\s+$//g; + $material_type = $worksheet->get_cell($row,2)->value(); + $material_type =~ s/^\s+|\s+$//g; } if ($worksheet->get_cell($row,3)) { - $description = $worksheet->get_cell($row,3)->value(); + $category = $worksheet->get_cell($row,3)->value(); + $category =~ s/^\s+|\s+$//g; } if ($worksheet->get_cell($row,4)) { - $material_source = $worksheet->get_cell($row,4)->value(); - $material_source =~ s/^\s+|\s+$//g; + $additional_info = $worksheet->get_cell($row,4)->value(); } if ($worksheet->get_cell($row,5)) { - $breeding_program = $worksheet->get_cell($row,5)->value(); + $material_source = $worksheet->get_cell($row,5)->value(); + $material_source =~ s/^\s+|\s+$//g; } if ($worksheet->get_cell($row,6)) { - $availability = $worksheet->get_cell($row,6)->value(); - $availability =~ s/^\s+|\s+$//g; + $breeding_program = $worksheet->get_cell($row,6)->value(); } +# if ($worksheet->get_cell($row,6)) { +# $availability = $worksheet->get_cell($row,6)->value(); +# $availability =~ s/^\s+|\s+$//g; +# } if ($worksheet->get_cell($row,7)) { $contact_person_username = $worksheet->get_cell($row,7)->value(); } @@ -186,35 +201,38 @@ sub _validate_with_plugin { } if (!$item_type || $item_type eq '') { - push @error_messages, "Cell B$row_name: type missing"; + push @error_messages, "Cell B$row_name: item_type missing"; } elsif (!$supported_types{$item_type}) { - push @error_messages, "Cell B$row_name: type is not supported: $item_type"; + push @error_messages, "Cell B$row_name: item_type is not supported: $item_type"; + } + + if (!$material_type || $material_type eq '') { + push @error_messages, "Cell C$row_name: material_type missing"; + } elsif (!$supported_material_types{$material_type}) { + push @error_messages, "Cell C$row_name: material type is not supported: $material_type"; } if (!$category || $category eq '') { - push @error_messages, "Cell C$row_name: category missing"; + push @error_messages, "Cell D$row_name: category missing"; } elsif (!$supported_categories{$category}) { push @error_messages, "Cell C$row_name: category is not supported: $category"; } - if (!$description || $description eq '') { - push @error_messages, "Cell D$row_name: description missing"; - } - if (!$material_source || $material_source eq '') { - push @error_messages, "Cell E$row_name: material_source missing"; - } elsif (!$supported_material_sources{$material_source}) { - push @error_messages, "Cell E$row_name: material source is not supported: $material_source"; - } +# if (!$material_source || $material_source eq '') { +# push @error_messages, "Cell E$row_name: material_source missing"; +# } elsif (!$supported_material_sources{$material_source}) { +# push @error_messages, "Cell E$row_name: material source is not supported: $material_source"; +# } if (!$breeding_program || $breeding_program eq '') { - push @error_messages, "Cell F$row_name: breeding_program missing"; + push @error_messages, "Cell G$row_name: breeding_program missing"; } - if (!$availability || $availability eq '') { - push @error_messages, "Cell G$row_name: availability missing"; - } elsif (!$supported_availability{$availability}) { - push @error_messages, "Cell G$row_name: availability is not supported: $availability"; - } +# if (!$availability || $availability eq '') { +# push @error_messages, "Cell G$row_name: availability missing"; +# } elsif (!$supported_availability{$availability}) { +# push @error_messages, "Cell G$row_name: availability is not supported: $availability"; +# } if (!$contact_person_username || $contact_person_username eq '') { push @error_messages, "Cell H$row_name: contact person username missing"; @@ -237,16 +255,18 @@ sub _validate_with_plugin { } - my @stocks_missing; +# my @stocks_missing; my @catalog_items = keys %seen_stock_names; my $catalog_item_validator = CXGN::List::Validate->new(); - my @accessions_missing = @{$catalog_item_validator->validate($schema,'uniquenames',\@catalog_items)->{'missing'}}; - if (scalar(@accessions_missing) > 0) { - @stocks_missing = @{$catalog_item_validator->validate($schema,'populations',\@accessions_missing)->{'missing'}}; - } +# my @accessions_missing = @{$catalog_item_validator->validate($schema,'uniquenames',\@catalog_items)->{'missing'}}; +# if (scalar(@accessions_missing) > 0) { +# @stocks_missing = @{$catalog_item_validator->validate($schema,'populations',\@accessions_missing)->{'missing'}}; +# } + + my @stocks_missing = @{$catalog_item_validator->validate($schema,'stocks',\@catalog_items)->{'missing'}}; if (scalar(@stocks_missing) > 0){ - push @error_messages, "The following catalog items are not in the database as accession or population: ".join(',',@stocks_missing); + push @error_messages, "The following catalog items are not in the database: ".join(',',@stocks_missing); } my @breeding_programs = keys %seen_program_names; @@ -302,11 +322,12 @@ sub _parse_with_plugin { my $row_name = $row+1; my $item_name; my $item_type; + my $material_type; my $category; - my $description; + my $additional_info; my $material_source; my $breeding_program; - my $availability; +# my $availability; my $contact_person_username; if ($worksheet->get_cell($row,0)) { @@ -316,20 +337,23 @@ sub _parse_with_plugin { $item_type = $worksheet->get_cell($row,1)->value(); } if ($worksheet->get_cell($row,2)) { - $category = $worksheet->get_cell($row,2)->value(); + $material_type = $worksheet->get_cell($row,2)->value(); } if ($worksheet->get_cell($row,3)) { - $description = $worksheet->get_cell($row,3)->value(); + $category = $worksheet->get_cell($row,3)->value(); } if ($worksheet->get_cell($row,4)) { - $material_source = $worksheet->get_cell($row,4)->value(); + $additional_info = $worksheet->get_cell($row,4)->value(); } if ($worksheet->get_cell($row,5)) { - $breeding_program = $worksheet->get_cell($row,5)->value(); + $material_source = $worksheet->get_cell($row,5)->value(); } if ($worksheet->get_cell($row,6)) { - $availability = $worksheet->get_cell($row,6)->value(); + $breeding_program = $worksheet->get_cell($row,6)->value(); } +# if ($worksheet->get_cell($row,6)) { +# $availability = $worksheet->get_cell($row,6)->value(); +# } if ($worksheet->get_cell($row,7)) { $contact_person_username = $worksheet->get_cell($row,7)->value(); } @@ -341,11 +365,12 @@ sub _parse_with_plugin { $parsed_result{$item_name} = { 'item_type' => $item_type, + 'material_type' => $material_type, 'category' => $category, - 'description' => $description, + 'additional_info' => $additional_info, 'material_source' => $material_source, 'breeding_program' => $breeding_program_id, - 'availability' => $availability, +# 'availability' => $availability, 'contact_person_id' => $contact_person_id, } } diff --git a/lib/SGN/Controller/AJAX/Catalog.pm b/lib/SGN/Controller/AJAX/Catalog.pm index 3fbc971754..af4182d617 100644 --- a/lib/SGN/Controller/AJAX/Catalog.pm +++ b/lib/SGN/Controller/AJAX/Catalog.pm @@ -23,16 +23,18 @@ sub add_catalog_item_POST : Args(0) { my $c = shift; my $schema = $c->dbic_schema('Bio::Chado::Schema', 'sgn_chado'); my $dbh = $c->dbc->dbh; - - my $item_name = $c->req->param('item_name'); - my $item_type = $c->req->param('item_type'); - my $item_category = $c->req->param('item_category'); - my $item_description = $c->req->param('item_description'); - my $item_material_source = $c->req->param('item_material_source'); - my $item_breeding_program_id = $c->req->param('item_breeding_program'); - my $item_availability = $c->req->param('item_availability'); + my $ordering_site = $c->config->{ordering_site}; + + my $item_name = $c->req->param('name'); + my $item_type = $c->req->param('type'); + my $item_material_type = $c->req->param('material_type'); + my $item_category = $c->req->param('category'); + my $item_additional_info = $c->req->param('additional_info'); + my $item_material_source = $c->req->param('material_source'); + my $item_breeding_program_id = $c->req->param('breeding_program_id'); my $contact_person = $c->req->param('contact_person'); my $item_prop_id = $c->req->param('item_prop_id'); + my $item_stock_id; if (!$c->user()) { print STDERR "User not logged in... not adding a catalog item.\n"; @@ -40,12 +42,26 @@ sub add_catalog_item_POST : Args(0) { return; } + my $item_stock_id; + my $item_species; + my $item_variety; my $item_rs = $schema->resultset("Stock::Stock")->find({uniquename => $item_name}); + my $variety_type_id = SGN::Model::Cvterm->get_cvterm_row($schema, 'variety', 'stock_property')->cvterm_id(); + if (!$item_rs) { $c->stash->{rest} = {error_string => "Item name is not in the database!",}; return; } else { $item_stock_id = $item_rs->stock_id(); + my $organism_id = $item_rs->organism_id(); + my $organism = $schema->resultset("Organism::Organism")->find({organism_id => $organism_id}); + $item_species = $organism->species(); + my $item_stockprop = $schema->resultset("Stock::Stockprop")->find({stock_id => $item_stock_id, type_id => $variety_type_id}); + if ($item_stockprop) { + $item_variety = $item_stockprop->value(); + } else { + $item_variety = 'NA'; + } } my $sp_person_id = CXGN::People::Person->get_person_by_username($dbh, $contact_person); @@ -67,11 +83,13 @@ sub add_catalog_item_POST : Args(0) { }); $stock_catalog->item_type($item_type); - $stock_catalog->category($item_category); - $stock_catalog->description($item_description); + $stock_catalog->material_type($item_material_type); $stock_catalog->material_source($item_material_source); + $stock_catalog->category($item_category); + $stock_catalog->species($item_species); + $stock_catalog->variety($item_variety); $stock_catalog->breeding_program($item_breeding_program_id); - $stock_catalog->availability($item_availability); + $stock_catalog->additional_info($item_additional_info); $stock_catalog->contact_person_id($sp_person_id); $stock_catalog->store(); @@ -179,21 +197,36 @@ sub upload_catalog_items_POST : Args(0) { } if ($parsed_data) { + my $variety_type_id = SGN::Model::Cvterm->get_cvterm_row($schema, 'variety', 'stock_property')->cvterm_id(); my %catalog_info = %{$parsed_data}; foreach my $item_name (keys %catalog_info) { + my $item_species; + my $item_variety; my $stock_rs = $schema->resultset("Stock::Stock")->find({uniquename => $item_name}); my $stock_id = $stock_rs->stock_id(); - print STDERR "STOCK ID =".Dumper($stock_id)."\n"; + my $organism_id = $stock_rs->organism_id(); + my $organism = $schema->resultset("Organism::Organism")->find({organism_id => $organism_id}); + $item_species = $organism->species(); + my $item_stockprop = $schema->resultset("Stock::Stockprop")->find({stock_id => $stock_id, type_id => $variety_type_id}); + if ($item_stockprop) { + $item_variety = $item_stockprop->value(); + } else { + $item_variety = 'NA'; + } + my %catalog_info_hash = %{$catalog_info{$item_name}}; my $stock_catalog = CXGN::Stock::Catalog->new({ bcs_schema => $schema, item_type => $catalog_info_hash{item_type}, + material_type => $catalog_info_hash{material_type}, + species => $item_species, + variety => $item_variety, category => $catalog_info_hash{category}, - description => $catalog_info_hash{description}, + additional_info => $catalog_info_hash{additional_info}, material_source => $catalog_info_hash{material_source}, breeding_program => $catalog_info_hash{breeding_program}, - availability => $catalog_info_hash{availability}, +# availability => $catalog_info_hash{availability}, contact_person_id => $catalog_info_hash{contact_person_id}, parent_id => $stock_id }); @@ -216,11 +249,11 @@ sub get_catalog :Path('/ajax/catalog/items') :Args(0) { my $self = shift; my $c = shift; my $schema = $c->dbic_schema('Bio::Chado::Schema', 'sgn_chado'); + my @catalog_items; my $catalog_obj = CXGN::Stock::Catalog->new({ bcs_schema => $schema}); my $catalog_ref = $catalog_obj->get_catalog_items(); # print STDERR "ITEM RESULTS =".Dumper($catalog_ref)."\n"; - my @catalog_items; my @catalog_list = @$catalog_ref; foreach my $catalog_item (@catalog_list) { my @item_details = (); @@ -229,7 +262,7 @@ sub get_catalog :Path('/ajax/catalog/items') :Args(0) { my $stock_rs = $schema->resultset("Stock::Stock")->find({stock_id => $item_id }); my $item_name = $stock_rs->uniquename(); - my $program_id = $item_details[4]; + my $program_id = $item_details[7]; my $program_rs = $schema->resultset('Project::Project')->find({project_id => $program_id}); my $program_name = $program_rs->name(); @@ -237,11 +270,13 @@ sub get_catalog :Path('/ajax/catalog/items') :Args(0) { item_id => $item_id, item_name => $item_name, item_type => $item_details[0], - category => $item_details[1], - description => $item_details[2], - material_source => $item_details[3], + species => $item_details[1], + variety => $item_details[2], + material_type => $item_details[3], + category => $item_details[4], + material_source => $item_details[5], + additional_info => $item_details[6], breeding_program => $program_name, - availability => $item_details[5], }; } @@ -279,18 +314,12 @@ sub item_image_list :Path('/ajax/catalog/image_list') :Args(1) { my $image_page = "/image/view/$image_obj_id"; my $small_image = $image_obj->get_image_url("thumbnail"); -# print STDERR "IMAGE OBJECT ID =".Dumper($image_obj_id)."\n"; -# print STDERR "IMAGE OBJECT NAME =".Dumper($image_obj_name)."\n"; -# print STDERR "IMAGE OBJECT DESCRIPTION =".Dumper($image_obj_description)."\n"; -# print STDERR "IMAGE MEDIUM =".Dumper($medium_image)."\n"; -# print STDERR "IMAGE PAGE =".Dumper($image_page)."\n"; push @image_list, { image_id => $image_obj_id, image_name => $image_obj_name, small_image => qq| |, image_description => $image_obj_description, }; -# print STDERR "IMAGE LIST =".Dumper(\@image_list)."\n"; } $c->stash->{rest} = {data => \@image_list}; diff --git a/lib/SGN/Controller/AJAX/Order.pm b/lib/SGN/Controller/AJAX/Order.pm index 20d1bc23d4..e46e7a19d8 100644 --- a/lib/SGN/Controller/AJAX/Order.pm +++ b/lib/SGN/Controller/AJAX/Order.pm @@ -46,7 +46,8 @@ sub submit_order_POST : Args(0) { my $time = DateTime->now(); my $timestamp = $time->ymd()."_".$time->hms(); my $request_date = $time->ymd(); -# print STDERR "LIST ID =".Dumper($list_id)."\n"; + my $order_properties = $c->config->{order_properties}; + my @properties = split ',',$order_properties; if (!$c->user()) { print STDERR "User not logged in... not adding a catalog item.\n"; @@ -66,9 +67,14 @@ sub submit_order_POST : Args(0) { my @all_items = @$items; foreach my $ordered_item (@all_items) { my @ona_info = (); - my @ordered_item_split = split /,/, $ordered_item; - my $number_of_fields = @ordered_item_split; - my $item_name = $ordered_item_split[0]; + my $order_details_ref = decode_json ($ordered_item); + my %order_details = %{$order_details_ref}; + my $item_name = $order_details{'Item Name'}; + my %each_item_details; + foreach my $field (@properties) { + $each_item_details{$field} = $order_details{$field}; + } + my $item_rs = $schema->resultset("Stock::Stock")->find( { uniquename => $item_name }); my $item_id = $item_rs->stock_id(); my $item_info_rs = $schema->resultset("Stock::Stockprop")->find({stock_id => $item_id, type_id => $catalog_cvterm_id}); @@ -79,48 +85,12 @@ sub submit_order_POST : Args(0) { my $item_source = $item_info_hash->{'material_source'}; $group_by_contact_id{$contact_person_id}{'item_list'}{$item_name}{'item_type'} = $item_type; $group_by_contact_id{$contact_person_id}{'item_list'}{$item_name}{'material_source'} = $item_source; - - my $quantity_string = $ordered_item_split[1]; - my @quantity_info = split /:/, $quantity_string; - my $quantity = $quantity_info[1]; - $quantity =~ s/^\s+|\s+$//g; - $group_by_contact_id{$contact_person_id}{'item_list'}{$item_name}{'quantity'} = $quantity; - - my $ona_additional_info; - if ($number_of_fields == 3) { - my $optional_field = $ordered_item_split[2]; - my @optional_field_array = split /:/, $optional_field; - my $optional_title = $optional_field_array[0]; - $optional_title =~ s/^\s+|\s+$//g; - print STDERR "OPTIONAL TITLE =".Dumper($optional_title)."\n"; - my $optional_info = $optional_field_array[1]; - $optional_info =~ s/^\s+|\s+$//g; - print STDERR "OPTIONAL INFO =".Dumper($optional_info)."\n"; - if ($optional_title eq 'Comments') { - $group_by_contact_id{$contact_person_id}{'item_list'}{$item_name}{'comments'} = $optional_info; - } elsif ($optional_title eq 'Additional Info') { - $group_by_contact_id{$contact_person_id}{'item_list'}{$item_name}{'additional_info'} = $optional_info; - $ona_additional_info = $optional_info; - print STDERR "ONA ADDITIONAL INFO =".Dumper($ona_additional_info)."\n"; - } - } elsif ($number_of_fields == 4) { - my $additional_info_field = $ordered_item_split[2]; - my @additional_info_array = split /:/, $additional_info_field; - my $additional_info = $additional_info_array[1]; - $additional_info =~ s/^\s+|\s+$//g; - $group_by_contact_id{$contact_person_id}{'item_list'}{$item_name}{'additional_info'} = $additional_info; - $ona_additional_info = $additional_info; - my $comments_field = $ordered_item_split[3]; - my @comments_array = split /:/, $comments_field; - my $comments = $comments_array[1]; - $comments =~ s/^\s+|\s+$//g; - $group_by_contact_id{$contact_person_id}{'item_list'}{$item_name}{'comments'} = $comments; - } - - @ona_info = ($item_source, $item_name, $quantity, $ona_additional_info, $request_date); - $group_by_contact_id{$contact_person_id}{'ona'}{$item_name} = \@ona_info; + $group_by_contact_id{$contact_person_id}{'item_list'}{$item_name} = \%each_item_details; } +# @ona_info = ($item_source, $item_name, $quantity, $ona_additional_info, $request_date); +# $group_by_contact_id{$contact_person_id}{'ona'}{$item_name} = \@ona_info; + my $ordering_service_name = $c->config->{ordering_service_name}; my $ordering_service_url = $c->config->{ordering_service_url}; my $ona_new_id; @@ -131,7 +101,7 @@ sub submit_order_POST : Args(0) { my $history_info = {}; my $item_ref = $group_by_contact_id{$contact_id}{'item_list'}; my %item_hashes = %{$item_ref}; - my @item_list = map { { $_ => $item_hashes{$_} } } keys %item_hashes; + my @item_list = map { { $_ => $item_hashes{$_} } } sort keys %item_hashes; my $new_order = CXGN::Stock::Order->new( { people_schema => $people_schema, dbh => $dbh}); $new_order->order_from_id($user_id); @@ -139,7 +109,6 @@ sub submit_order_POST : Args(0) { $new_order->order_status("submitted"); $new_order->create_date($timestamp); my $order_id = $new_order->store(); -# print STDERR "ORDER ID =".($order_id)."\n"; if (!$order_id){ $c->stash->{rest} = {error_string => "Error saving your order",}; return; @@ -208,7 +177,6 @@ sub submit_order_POST : Args(0) { my $message_hash_d = decode_json $message_d; foreach my $t (@$message_hash_d) { if ($t->{'data_value'} eq $order_file_name) { -# print STDERR "DELETE INFO =".Dumper($t)."\n"; getstore($t->{media_url}, $previous_order_temp_file_path); $order_ona_id = $t->{id}; } @@ -366,6 +334,9 @@ sub get_user_current_orders :Path('/ajax/order/current') Args(0) { my $schema = $c->dbic_schema("Bio::Chado::Schema"); my $people_schema = $c->dbic_schema('CXGN::People::Schema'); my $dbh = $c->dbc->dbh; + my $ordering_site = $c->config->{ordering_site}; + my $order_properties = $c->config->{order_properties}; + my @properties = split ',',$order_properties; my $user_id; if (!$c->user){ @@ -379,13 +350,34 @@ sub get_user_current_orders :Path('/ajax/order/current') Args(0) { my $orders = CXGN::Stock::Order->new({ dbh => $dbh, people_schema => $people_schema, order_from_id => $user_id}); my $all_orders_ref = $orders->get_orders_from_person_id(); + my @current_orders; my @all_orders = @$all_orders_ref; foreach my $order (@all_orders) { - if (($order->[3]) ne 'completed') { - push @current_orders, [qq{$order->[0]}, $order->[1], $order->[2], $order->[3], $order->[5], $order->[6]] + if (($order->{'order_status'}) ne 'completed') { + my $clone_list = $order->{'clone_list'}; + my $item_name; + my @all_item_details = (); + my $all_details_string; + my $empty_string = ''; + foreach my $each_item (@$clone_list) { + my @request_details = (); + $item_name = (keys %$each_item)[0]; + push @request_details, ""."Item Name"."". ":"."".$item_name; + foreach my $field (@properties) { + my $each_detail = $each_item->{$item_name}->{$field}; + my $detail_string = $field. ":"."".$each_detail; + push @request_details, $detail_string; + } + push @request_details, $empty_string; + my $details_string = join("
", @request_details); + push @all_item_details, $details_string; + } + $all_details_string = join("
", @all_item_details); + push @current_orders, [qq{$order->{'order_id'}}, $order->{'create_date'}, $all_details_string, $order->{'order_status'}, $order->{'order_to_name'}, $order->{'comments'}] } } + $c->stash->{rest} = {data => \@current_orders}; } @@ -395,6 +387,9 @@ sub get_user_completed_orders :Path('/ajax/order/completed') Args(0) { my $schema = $c->dbic_schema("Bio::Chado::Schema"); my $people_schema = $c->dbic_schema('CXGN::People::Schema'); my $dbh = $c->dbc->dbh; + my $ordering_site = $c->config->{ordering_site}; + my $order_properties = $c->config->{order_properties}; + my @properties = split ',',$order_properties; my $user_id; if (!$c->user){ @@ -410,9 +405,30 @@ sub get_user_completed_orders :Path('/ajax/order/completed') Args(0) { my $all_orders_ref = $orders->get_orders_from_person_id(); my @completed_orders; my @all_orders = @$all_orders_ref; + foreach my $order (@all_orders) { - if (($order->[3]) eq 'completed') { - push @completed_orders, [qq{$order->[0]}, $order->[1], $order->[2], $order->[3], $order->[4], $order->[5], $order->[6]] + if (($order->{'order_status'}) eq 'completed') { + my $clone_list = $order->{'clone_list'}; + my $item_name; + my @all_item_details = (); + my $empty_string = ''; + my $all_details_string; + foreach my $each_item (@$clone_list) { + my @request_details = (); + $item_name = (keys %$each_item)[0]; + push @request_details, ""."Item Name"."". ":"."".$item_name; + foreach my $field (@properties) { + my $each_detail = $each_item->{$item_name}->{$field}; + my $detail_string = $field. ":"."".$each_detail; + push @request_details, $detail_string; + } + push @request_details, $empty_string; + my $details_string = join("
", @request_details); + push @all_item_details, $details_string; + } + $all_details_string = join("
", @all_item_details); + + push @completed_orders, [qq{$order->{'order_id'}}, $order->{'create_date'}, $all_details_string, $order->{'order_status'}, $order->{'completion_date'}, $order->{'order_to_name'}, $order->{'comments'}] } } @@ -427,6 +443,9 @@ sub get_vendor_current_orders :Path('/ajax/order/vendor_current_orders') Args(0) my $schema = $c->dbic_schema("Bio::Chado::Schema"); my $people_schema = $c->dbic_schema('CXGN::People::Schema'); my $dbh = $c->dbc->dbh; + my $ordering_site = $c->config->{ordering_site}; + my $order_properties = $c->config->{order_properties}; + my @properties = split ',',$order_properties; my $user_id; if (!$c->user){ @@ -443,11 +462,33 @@ sub get_vendor_current_orders :Path('/ajax/order/vendor_current_orders') Args(0) my @vendor_current_orders; my @all_vendor_orders = @$vendor_orders_ref; - foreach my $vendor_order (@all_vendor_orders) { - if (($vendor_order->{'order_status'}) ne 'completed') { - push @vendor_current_orders, $vendor_order + foreach my $vendor_order (@all_vendor_orders) { + if (($vendor_order->{'order_status'}) ne 'completed') { + my $clone_list = $vendor_order->{'clone_list'}; + my $item_name; + my @all_item_details = (); + my $all_details_string; + my $empty_string = ''; + foreach my $each_item (@$clone_list) { + my @request_details = (); + $item_name = (keys %$each_item)[0]; + push @request_details, ""."Item Name"."". ":"."".$item_name; + foreach my $field (@properties) { + my $each_detail = $each_item->{$item_name}->{$field}; + my $detail_string = $field. ":"."".$each_detail; + push @request_details, $detail_string; + } + push @request_details, $empty_string; + my $details_string = join("
", @request_details); + + push @all_item_details, $details_string; } + $all_details_string = join("
", @all_item_details); + + $vendor_order->{'order_details'} = $all_details_string; + push @vendor_current_orders, $vendor_order } + } $c->stash->{rest} = {data => \@vendor_current_orders}; @@ -460,6 +501,9 @@ sub get_vendor_completed_orders :Path('/ajax/order/vendor_completed_orders') Arg my $schema = $c->dbic_schema("Bio::Chado::Schema"); my $people_schema = $c->dbic_schema('CXGN::People::Schema'); my $dbh = $c->dbc->dbh; + my $ordering_site = $c->config->{ordering_site}; + my $order_properties = $c->config->{order_properties}; + my @properties = split ',',$order_properties; my $user_id; if (!$c->user){ @@ -478,6 +522,27 @@ sub get_vendor_completed_orders :Path('/ajax/order/vendor_completed_orders') Arg my @all_vendor_orders = @$vendor_orders_ref; foreach my $vendor_order (@all_vendor_orders) { if (($vendor_order->{'order_status'}) eq 'completed') { + my $clone_list = $vendor_order->{'clone_list'}; + my $item_name; + my @all_item_details = (); + my $empty_string = ''; + my $all_details_string; + foreach my $each_item (@$clone_list) { + my @request_details = (); + $item_name = (keys %$each_item)[0]; + push @request_details, ""."Item Name"."". ":"."".$item_name; + foreach my $field (@properties) { + my $each_detail = $each_item->{$item_name}->{$field}; + my $detail_string = $field. ":"."".$each_detail; + push @request_details, $detail_string; + } + push @request_details, $empty_string; + my $details_string = join("
", @request_details); + push @all_item_details, $details_string; + } + $all_details_string = join("
", @all_item_details); + $vendor_order->{'order_details'} = $all_details_string; + push @vendor_completed_orders, $vendor_order } } @@ -547,6 +612,95 @@ sub update_order :Path('/ajax/order/update') :Args(0) { $c->stash->{rest} = {success => "1",}; +} + + +sub single_step_submission : Path('/ajax/order/single_step_submission') : ActionClass('REST'){ } + +sub single_step_submission_POST : Args(0) { + my $self = shift; + my $c = shift; + my $schema = $c->dbic_schema('Bio::Chado::Schema', 'sgn_chado'); + my $people_schema = $c->dbic_schema('CXGN::People::Schema'); + my $dbh = $c->dbc->dbh(); + my $time = DateTime->now(); + my $timestamp = $time->ymd()."_".$time->hms(); + my $request_date = $time->ymd(); + my $item_name = $c->req->param('item_name'); + my $order_details = decode_json ($c->req->param('order_details')); + my %details; + + $details{$item_name} = $order_details; + if (!$c->user()) { + print STDERR "User not logged in... not adding a catalog item.\n"; + $c->stash->{rest} = {error_string => "You must be logged in to add a catalog item." }; + return; + } + my $user_id = $c->user()->get_object()->get_sp_person_id(); + my $user_name = $c->user()->get_object()->get_username(); + my $user_role = $c->user->get_object->get_user_type(); + + my $catalog_cvterm_id = SGN::Model::Cvterm->get_cvterm_row($schema, 'stock_catalog_json', 'stock_property')->cvterm_id(); + my $item_rs = $schema->resultset("Stock::Stock")->find( { uniquename => $item_name }); + my $item_id = $item_rs->stock_id(); + my $item_info_rs = $schema->resultset("Stock::Stockprop")->find({stock_id => $item_id, type_id => $catalog_cvterm_id}); + my $item_info_string = $item_info_rs->value(); + my $item_info_hash = decode_json $item_info_string; + my $contact_person_id = $item_info_hash->{'contact_person_id'}; + my $item_type = $item_info_hash->{'item_type'}; + $details{$item_name}{'item_type'} = $item_type; + push my @item_list, \%details; + print STDERR "REQUEST DETAILS =".Dumper(\%details)."\n"; + my @history = (); + my $history_info = {}; + + my $new_order = CXGN::Stock::Order->new( { people_schema => $people_schema, dbh => $dbh}); + $new_order->order_from_id($user_id); + $new_order->order_to_id($contact_person_id); + $new_order->order_status("submitted"); + $new_order->create_date($timestamp); + my $order_id = $new_order->store(); +# print STDERR "ORDER ID =".($order_id)."\n"; + if (!$order_id){ + $c->stash->{rest} = {error_string => "Error saving your order",}; + return; + } + + $history_info ->{'submitted'} = $timestamp; + push @history, $history_info; + + + my $order_prop = CXGN::Stock::OrderBatch->new({ bcs_schema => $schema, people_schema => $people_schema}); + $order_prop->clone_list(\@item_list); + $order_prop->parent_id($order_id); + $order_prop->history(\@history); + my $order_prop_id = $order_prop->store_sp_orderprop(); +# print STDERR "ORDER PROP ID =".($order_prop_id)."\n"; + + if (!$order_prop_id){ + $c->stash->{rest} = {error_string => "Error saving your order",}; + return; + } + + my $contact_person = CXGN::People::Person -> new($dbh, $contact_person_id); + my $contact_email = $contact_person->get_contact_email(); + + my $host = $c->config->{main_production_site_url}; + my $project_name = $c->config->{project_name}; + my $subject="Ordering Notification from $project_name"; + my $body=<stash->{rest}->{success} .= 'Your request has been submitted successfully and the vendor has been notified.'; } diff --git a/lib/SGN/Controller/Catalog.pm b/lib/SGN/Controller/Catalog.pm index ea459f12fa..84c037e6e1 100644 --- a/lib/SGN/Controller/Catalog.pm +++ b/lib/SGN/Controller/Catalog.pm @@ -29,6 +29,15 @@ sub stock_catalog :Path('/catalog/view') :Args(0) { my $additional_order_info = $c->config->{additional_order_info}; $c->stash->{additional_order_info} = $additional_order_info; + my $ordering_type = $c->config->{ordering_type}; + $c->stash->{ordering_type} = $ordering_type; + + my $order_properties = $c->config->{order_properties}; + my $order_properties_dialog = $c->config->{order_properties_dialog}; + + $c->stash->{order_properties} = $order_properties; + $c->stash->{order_properties_dialog} = $order_properties_dialog; + $c->stash->{template} = '/order/catalog.mas'; } @@ -62,7 +71,6 @@ sub catalog_item_details : Path('/catalog/item_details') Args(1) { return; } else { $item_prop_id = $stock_catalog_info->stockprop_id(); -# print STDERR "STOCKPROP ID =".Dumper($item_prop_id)."\n"; } my $stock_catalog_item = $schema->resultset("Stock::Stock")->find({stock_id => $item_id}); @@ -74,14 +82,17 @@ sub catalog_item_details : Path('/catalog/item_details') Args(1) { my $item_obj = CXGN::Stock::Catalog->new({ bcs_schema => $schema, parent_id => $item_id}); my $details_ref = $item_obj->get_item_details(); my @item_details = @$details_ref; + print STDERR "ITEM DETAILS =".Dumper(\@item_details)."\n"; my $item_type = $item_details[0]; - my $category = $item_details[1]; - my $description = $item_details[2]; - my $material_source = $item_details[3]; - my $program_id = $item_details[4]; - my $availability = $item_details[5]; - my $contact_person_id = $item_details[6]; - my $images = $item_details[7]; + my $species = $item_details[1]; + my $variety = $item_details[2]; + my $material_type = $item_details[3]; + my $category = $item_details[4]; + my $material_source = $item_details[5]; + my $additional_info = $item_details[6]; + my $program_id = $item_details[7]; + my $contact_person_id = $item_details[8]; + my $images = $item_details[9]; my $image_id = $images->[0]; my $image_obj = SGN::Image->new($dbh, $image_id); my $medium_image = $image_obj->get_image_url("medium"); @@ -95,14 +106,15 @@ sub catalog_item_details : Path('/catalog/item_details') Args(1) { # print STDERR "CONTACT PERSON NAME=".Dumper($contact_person_username)."\n"; $c->stash->{item_id} = $item_id; $c->stash->{item_name} = $item_name; - $c->stash->{species} = $species; $c->stash->{item_type} = $item_type; + $c->stash->{species} = $species; + $c->stash->{variety} = $variety; + $c->stash->{material_type} = $material_type; $c->stash->{category} = $category; - $c->stash->{description} = $description; $c->stash->{material_source} = $material_source; + $c->stash->{additional_info} = $additional_info; $c->stash->{program_id} = $program_id; $c->stash->{breeding_program} = $program_name; - $c->stash->{availability} = $availability; $c->stash->{contact_person_username} = $contact_person_username; $c->stash->{item_prop_id} = $item_prop_id; $c->stash->{image} = qq| |, diff --git a/lib/SGN/Controller/Order.pm b/lib/SGN/Controller/Order.pm index 0088665ad5..56185aa419 100644 --- a/lib/SGN/Controller/Order.pm +++ b/lib/SGN/Controller/Order.pm @@ -34,6 +34,8 @@ sub order_details :Path('/order/details/view') : Args(1) { my $c = shift; my $people_schema = $c->dbic_schema('CXGN::People::Schema'); my $dbh = $c->dbc->dbh; + my $order_properties = $c->config->{order_properties}; + my @properties = split ',',$order_properties; if (! $c->user()) { $c->res->redirect( uri( path => '/user/login', query => { goto_url => $c->req->uri->path_query } ) ); @@ -46,13 +48,28 @@ sub order_details :Path('/order/details/view') : Args(1) { } my $order_number = shift; - my $order_rs = CXGN::Stock::Order->new({ dbh => $dbh, people_schema => $people_schema, sp_order_id => $order_number}); - my $order_result = $order_rs->get_order_details(); + my $order_obj = CXGN::Stock::Order->new({ dbh => $dbh, people_schema => $people_schema, sp_order_id => $order_number}); + my $order_result = $order_obj->get_order_details(); + + my $all_items = $order_result->[3]; + my $item_name; + my $all_details_string; + foreach my $each_item (@$all_items) { + my @item_details = (); + $item_name = (keys %$each_item)[0]; + push @item_details, ""."Item Name"."". ":"."".$item_name; + foreach my $field (@properties) { + my $each_detail = $each_item->{$item_name}->{$field}; + my $detail_string = $field. ":"."".$each_detail; + push @item_details, $detail_string; + } + $all_details_string = join("
", @item_details); + } $c->stash->{order_id} = $order_result->[0]; $c->stash->{order_from} = $order_result->[1]; $c->stash->{create_date} = $order_result->[2]; - $c->stash->{item_list} = $order_result->[3]; + $c->stash->{item_list} = $all_details_string; $c->stash->{order_to} = $order_result->[4]; $c->stash->{order_status} = $order_result->[5]; $c->stash->{comments} = $order_result->[6]; diff --git a/mason/order/add_catalog_item_dialog.mas b/mason/order/add_catalog_item_dialog.mas index 4c2d662b96..1882180b16 100644 --- a/mason/order/add_catalog_item_dialog.mas +++ b/mason/order/add_catalog_item_dialog.mas @@ -1,5 +1,6 @@ <%args> $timestamp => localtime() +$ordering_type => undef +
+ +
+ +
+
@@ -36,23 +48,20 @@ $timestamp => localtime() +
- +
- +
-
- +
+
@@ -61,17 +70,6 @@ $timestamp => localtime()
-
- -
- -
-
@@ -128,35 +126,51 @@ jQuery(document).ready(function(){ jQuery('#submit_catalog_item').click( function() { var name = jQuery('#item_name').val(); var type = jQuery('#item_type').val(); + var material_type = jQuery('#item_material_type').val(); var category = jQuery('#item_category').val(); - var description = jQuery('#item_description').val(); + var additional_info = jQuery('#item_additional_info').val(); var material_source = jQuery('#item_material_source').val(); var breeding_program = jQuery('#item_breeding_program_id').val(); - var availability = jQuery('#item_availability').val(); var contact_person = jQuery('#contact_person_name').val(); - if (name == '') { alert("Please provide a name") }; - if (type == '') { alert("Please select a type") }; - if (category == '') { alert("Please select a category") }; - if (description == '') { alert("Please provide a description") }; - if (material_source == '') { alert("Please select a material source") }; - if (breeding_program == '') { alert("Please select a breeding program") }; - if (availability == '') { alert("Please indicate availability") }; - if (contact_person == '') { alert("Please indicate contact person") }; + if (name == '') { + alert("Please provide a name"); + return; + } + if (type == '') { + alert("Please select an item type"); + return; + } + if (material_type == '') { + alert("Please select a material type"); + return; + } + if (category == '') { + alert("Please select a category"); + return; + } + if (breeding_program == '') { + alert("Please select a program"); + return; + } + if (contact_person == '') { + alert("Please provide contact username"); + return; + } jQuery.ajax({ url: '/ajax/catalog/add_item', dataType: "json", type: 'POST', data : { - 'item_name' : name, - 'item_type': type, - 'item_category': category, - 'item_description': description, - 'item_material_source': material_source, - 'item_breeding_program': breeding_program, - 'item_availability': availability, - 'contact_person': contact_person + 'name' : name, + 'type': type, + 'material_type': material_type, + 'category': category, + 'additional_info': additional_info, + 'material_source': material_source, + 'breeding_program_id': breeding_program, + 'contact_person': contact_person, }, beforeSend: function(response){ jQuery('#working_modal').modal('show'); diff --git a/mason/order/catalog.mas b/mason/order/catalog.mas index 5bb89b2233..e3459513e5 100644 --- a/mason/order/catalog.mas +++ b/mason/order/catalog.mas @@ -3,6 +3,9 @@ $check_vendor_role $ordering_service_name => undef $additional_order_info => undef +$ordering_type => undef +$order_properties => undef +$order_properties_dialog => undef @@ -34,6 +37,7 @@ $additional_order_info => undef
+% if ($ordering_type ne 'single_step') {
+%}

Go to Manage Order Page

@@ -121,16 +126,23 @@ $additional_order_info => undef +% if ($ordering_type eq 'single_step') { + +%} else { +%} -<& /order/upload_catalog_items_dialog.mas &> -<& /order/add_catalog_item_dialog.mas &> +<& /order/upload_catalog_items_dialog.mas, ordering_type => $ordering_type&> +<& /order/add_catalog_item_dialog.mas, ordering_type => $ordering_type &>