diff --git a/copri4/main/src/Mod/APIfunc.pm b/copri4/main/src/Mod/APIfunc.pm index 469be83..79e8aa5 100755 --- a/copri4/main/src/Mod/APIfunc.pm +++ b/copri4/main/src/Mod/APIfunc.pm @@ -2176,21 +2176,7 @@ sub stations_available(){ 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+)/){ + if($main_id =~ /(\d+)/){ my $node_id = $1; $pref_sql .= " ct.txt24 like '%$node_id%' OR"; } @@ -2268,20 +2254,25 @@ sub stations_available(){ $return->{$id}->{operator_data}->{operator_phone} = $hotline_data->{txt07} if($hotline_data->{txt07}); $return->{$id}->{operator_data}->{operator_email} = $hotline_data->{txt08} if($hotline_data->{txt08}); - $return->{$id}->{cached} = "0"; + $return->{$id}->{cached} = "0"; + $return->{$id}->{withpub} = "0"; + if($dbt->{operator}->{$varenv->{dbname}}->{cache_station} == 1 && $cachme){ + $return->{$id}->{cached} = "1"; + foreach my $tarif_key (keys(%$adrtarif_hash)){ + $return->{$id}->{withpub}= "1" if($adrtarif_hash->{$tarif_key} == 2); + } + } + $op_return->{$dbt->{operator}->{$varenv->{dbname}}->{oprefix} . $id} = $return->{$id}; + } + } #json caching if($dbt->{operator}->{$varenv->{dbname}}->{cache_station} == 1 && $cachme){ - $return->{$id}->{withpub} = "0"; #order by sharing_type foreach my $tarif_key (keys(%$adrtarif_hash)){ - $return->{$id}->{withpub}= "1" if($adrtarif_hash->{$tarif_key} == 2 || $adrtarif_hash->{$tarif_key} == 5); - $return->{$id}->{cached} = "$cachme"; - $op_return->{$dbt->{operator}->{$varenv->{dbname}}->{oprefix} . $id} = $return->{$id}; - #my $stationsout = $json->pretty->encode({ shareejson => { stations => $op_return } }); my $stationsout = $json->pretty->encode($op_return); if($cachme){ @@ -2302,8 +2293,6 @@ sub stations_available(){ } } }#end caching - } - } return ($op_return, $record); }#end stations_available @@ -2500,8 +2489,14 @@ sub fetch_tariff(){ elsif(looks_like_number($cachme) && $cachme > 0){ $tariff->{barcode} = $cachme; $tariff_all = $dbt->fetch_record($dbh,$tariff); - $auth_operator = { txt30 => "$cachme" }; - $bw->log("$dbname $cachme Tariff type for No operator registered user by barcode:$tariff->{barcode} select 2:",$tariff_all,""); + if($tariff_all->{$cachme}->{int18} == 2 || $tariff_all->{$cachme}->{int18} == 5){ + delete $tariff->{barcode}; + $tariff->{int18} = 2; + $tariff_all = $dbt->fetch_record($dbh,$tariff); + }else{ + $auth_operator = { txt30 => "$cachme" }; + } + $bw->log("$dbname $cachme Tariff type for No operator registered user by barcode:$tariff->{barcode} OR int18: $tariff->{int18} select 2:",$tariff_all,""); } #if no primary address then only 2=public elsif((ref($adr) ne "HASH" || !$adr->{c_id}) && ($dbname ne "sharee_lv")){ diff --git a/copri4/main/src/Tpl/Karte_osm.pm b/copri4/main/src/Tpl/Karte_osm.pm index 9fcf7eb..fcd9d1a 100755 --- a/copri4/main/src/Tpl/Karte_osm.pm +++ b/copri4/main/src/Tpl/Karte_osm.pm @@ -145,7 +145,7 @@ var icon_red = L.icon({ }); //stations and bikes at all -if(1==2){ +if('$dbt->{operator}->{$varenv->{dbname}}->{merchant_id}'){ Promise.all([ fetch( "$uri_request/GBFSout?request=stations_available&authcookie=$api_return->{authcookie}" @@ -204,9 +204,11 @@ Promise.all([ map.fitBounds(layerGroup.getBounds()); }); -}//end stations and bikes at all +} //Only stations with bike_count +else{ + Promise.all([ fetch( "$uri_request/GBFSout?request=stations_available&authcookie=$api_return->{authcookie}" @@ -249,7 +251,7 @@ Promise.all([ map.fitBounds(layerGroup.getBounds()); }); - +} EOF diff --git a/copri4/shareeconf/examples/global.cfg b/copri4/shareeconf/examples/global.cfg index 0e24ce4..4def06a 100755 --- a/copri4/shareeconf/examples/global.cfg +++ b/copri4/shareeconf/examples/global.cfg @@ -59,6 +59,7 @@ initMap="47.976634, 7.825490" map_zoom="13" cache_station=0 + withpub=0 dbname=sharee_operator host=localhost @@ -93,6 +94,7 @@ initMap="47.976634, 7.825490" map_zoom="13" cache_station=0 + withpub=0 dbname=sharee_operator host=localhost @@ -128,6 +130,7 @@ id = 298 name = "example Pr" + app_name="" project="all" user_agent = "" initMap = "47.976634, 7.825490" @@ -141,6 +144,7 @@ id = 296 name = "example Op" + app_name="" project="Example" user_agent = "" initMap = "47.976634, 7.825490" @@ -154,6 +158,7 @@ id = 294 name = "example Web" + app_name="" project="Example" user_agent = "" initMap = "47.976634, 7.825490" @@ -167,6 +172,7 @@ id = 295 name = "example App" + app_name="sharee.bike" project="Example" user_agent = "" initMap = "47.976634, 7.825490" @@ -188,8 +194,8 @@ logdir = "/var/log/copri4" basedir = "/var/www/copri4" - 300101 = "Lastenräder" - 300103 = "Stadträder" + 300101 = "Lastenrad" + 300103 = "Stadtrad" 2 = "public"