chiark / gitweb /
Show commod class in voyage plan too
[ypp-sc-tools.web-live.git] / yarrg / web / routetrade
index 08bad334569ea32178ec8e6e7d3345bf4d8060e5..72e9bf7a8a96cf706e4557d6fd26cadfb2dfd2e2 100644 (file)
@@ -693,25 +693,31 @@ Generated by YARRG at <strong><%
                } unless $$todo;
                $$todo->{'commodname'}= $f->{'commodname'};
                $$todo->{'posinclass'}= '';
-               if ($f->{'posinclass'}) {
-                       my $findclass= $dbh->prepare(<<END);
+               my $incl= $f->{'posinclass'};
+
+               my $findclass= $dbh->prepare(<<END);
 SELECT commodclass, maxposinclass FROM commodclasses WHERE commodclassid = ?
 END
-                       $findclass->execute($f->{'commodclassid'});
-                       my $classinfo= $findclass->fetchrow_hashref();
-                       if ($classinfo->{'maxposinclass'} >= 8) {
+               $findclass->execute($f->{'commodclassid'});
+               my $classinfo= $findclass->fetchrow_hashref();
+               if ($classinfo) {
+                       my $clname= $classinfo->{'commodclass'};
+                       my $desc= encode_entities(sprintf "%s is under %s",
+                                       $f->{'commodname'}, $clname);
+                       my $abbrev= substr($clname,0,1);
+                       if ($incl) {
                                my $maxpic= $classinfo->{'maxposinclass'};
-                               my $inpic= $f->{'posinclass'};
-                               my @tmbs= qw(TT T M B BB);
-                               my $tmbi= ($inpic+0.5)*$#tmbs/$maxpic;
-                               my $desc= (sprintf "%s is under %s,".
-                                       " commodity %d of %d",
-                                       $f->{'commodname'},
-                                       $classinfo->{'commodclass'},
-                                       $inpic, $maxpic);
-                               $$todo->{'posinclass'}=
- "<div class=mouseover title=\"$desc\">$tmbs[$tmbi]</div>";
+                               $desc.= (sprintf ", commodity %d of %d",
+                                       $incl, $maxpic);
+                               if ($classinfo->{'maxposinclass'} >= 8) {
+                                       my @tmbs= qw(tt t m b bb);
+                                       my $tmbi= ($incl+0.5)*$#tmbs/$maxpic;
+                                       $abbrev.= " ".$tmbs[$tmbi];
+                               }
                        }
+                       $$todo->{'posinclass'}=
+                               "<div class=mouseover title=\"$desc\">"
+                               .$abbrev."</div>";
                }
                $$todo->{'stallname'}= $stallname;
                $$todo->{Price}= $price;