diff --git a/copri4/main/src/Mod/APIfunc.pm b/copri4/main/src/Mod/APIfunc.pm index b572d67..6cb9781 100755 --- a/copri4/main/src/Mod/APIfunc.pm +++ b/copri4/main/src/Mod/APIfunc.pm @@ -2205,6 +2205,9 @@ sub stations_available(){ #group_id must have 6 numbers like 300103 my $pref_sql = ""; + + #select by bike.type_id bike-group on booking update, to get available stations on bike return by filter logic + if(ref($record_pos) eq "HASH" && $record_pos->{int29}){ $pref_sql .= " and ("; foreach my $type_id (@{$bike_group}){ #on rental end select only stations which are defined @@ -2228,6 +2231,34 @@ sub stations_available(){ } $pref_sql =~ s/OR$//; $pref_sql .= ")"; + } + #select by bike.main_id Flot only if no booking update, to keep private/hidden Tarif logic + else{ + $pref_sql .= " and ("; + foreach my $main_id (@{$bike_node}){ + #on rental end select only stations which are defined + #A-A rental + if($station_bike_node && $main_id =~ /(\d+)/ && $aa_station){ + my $node_id = $1; + if($node_id == $station_bike_node){ + $pref_sql .= " ct.int04 = $aa_station OR"; + } + #A-B rental + }elsif($station_bike_node && $main_id =~ /(\d+)/){ + my $node_id = $1; + if($node_id == $station_bike_node){ + $pref_sql .= " ct.txt24 like '%$node_id%' OR"; + } + #without a rental + }elsif($main_id =~ /(\d+)/){ + my $node_id = $1; + $pref_sql .= " ct.txt24 like '%$node_id%' OR"; + } + } + $pref_sql =~ s/OR$//; + $pref_sql .= ")"; + } + $pref_sql = "" if($pref_sql !~ /\d/); $bw->log("stations_available --> station_bike_node:$station_bike_node|aa_station:$aa_station|bike_node:@{$bike_node}|bike_group:@{$bike_group}|pref_sql:\n",$pref_sql,"");