Adding station_type, category and text-cms

This commit is contained in:
ragu 2023-03-30 17:45:12 +02:00
parent 47bf368903
commit cc82e0856a
8 changed files with 136 additions and 40 deletions

View file

@ -1486,7 +1486,7 @@ sub smartlock {
#only by system=Ilockit
if($record_pos->{int11} eq "2" && $q->param('voltage') && $q->param('voltage') =~ /(\d+)/){
$update_cc->{int14} = $1;
$self->service_automatic($q,"") if($1 <= 50);
$self->service_automatic($q,"") if($1 <= 60);
}
my $update_pos = {
@ -1813,6 +1813,7 @@ sub bikes_available(){
$authed = 1 if(ref($auth) eq "HASH" && $auth->{c_id} > 0);
(my $bike_group,my $bike_node,my $user_tour,$tariff_content,$adrtarif_hash) = $self->fetch_tariff($varenv->{dbname},$auth,$q->param('authcookie'));
$bw->log("$varenv->{dbname} bikes_available bike_group:",$bike_group,"");
#print Dumper($bike_group);
#print Dumper($bike_node);
my $main_ids = join(",",@{$bike_node});
@ -2120,7 +2121,7 @@ sub stations_available(){
my $authcookie = $q->param('authcookie') || $q->cookie('domcookie');
my ($bike_group,$bike_node,$user_tour,$tariff_content,$adrtarif_hash) = $self->fetch_tariff($varenv->{dbname},$auth,$authcookie,$cachme);
$bw->log("fetch_tariff adrtarif_hash from $varenv->{dbname}\n",$adrtarif_hash,"");
#$bw->log("fetch_tariff adrtarif_hash from $varenv->{dbname}\n",$adrtarif_hash,"");
#station_group and bike_group alias bike nodes.type_id
my $station_group = "";
@ -2228,6 +2229,30 @@ sub stations_available(){
$return->{$id}->{description} = "$description";
$return->{$id}->{state} = "$dbt->{copri_conf}->{bike_state}->{$record->{$id}->{int10}}";
$return->{$id}->{gps_radius} = "$record->{$id}->{int06}";
#new station category
#defaults
$return->{$id}->{station_type} = {};
my @station_group = ();
if($record->{$id}->{txt25} && $record->{$id}->{txt25} =~ /\d\s\d/){
@station_group = split(/\s/,$record->{$id}->{txt25});
}elsif($record->{$id}->{txt25}){
@station_group = ("$record->{$id}->{txt25}");
}
foreach(@station_group){
if($_ && $dbt->{copri_conf}->{type_id}->{$_}){
$return->{$id}->{station_type}->{$dbt->{copri_conf}->{type_id}->{$_}}->{bike_group} = "$dbt->{operator}->{$varenv->{dbname}}->{oprefix}$_";
my $bike_count2 = 0;
foreach my $b_id (keys (%$record_bikes)){
if($record->{$id}->{int04} == $record_bikes->{$b_id}->{int04}){
$bike_count2++ if($_ == $record_bikes->{$b_id}->{type_id});
}
}
$return->{$id}->{station_type}->{$dbt->{copri_conf}->{type_id}->{$_}}->{bike_count} = "$bike_count2";
}
}
#deprecated
$return->{$id}->{station_group} = "";
if($record->{$id}->{txt25}){
$record->{$id}->{txt25} =~ s/(\d+)/$dbt->{operator}->{$varenv->{dbname}}->{oprefix}$1/g;
@ -2527,7 +2552,7 @@ sub fetch_tariff(){
}
#else select all available user tarif entries
$tariff_all = $dbt->fetch_record($dbh,$tariff);
$bw->log("$dbname Tariff type for operator registered user by int18:$tariff->{int18} select 4:",$tariff_all,"");
$bw->log("$dbname Tariff type for operator registered user with Tarif $auth_operator->{txt30} by int18:$tariff->{int18} select 4:",$tariff_all,"");
}
#end operators address
else{
@ -2546,12 +2571,14 @@ sub fetch_tariff(){
if($auth_operator->{txt30} && $auth_operator->{txt30} =~ /\d\s\d/){
%tarif_hash = map { $_ => 1 } split(/\s+/,$auth_operator->{txt30});
}elsif($auth_operator->{txt30}){
$tarif_hash{$auth_operator->{txt30}} = 1;
}elsif($auth_operator->{txt30} && $auth_operator->{txt30} =~ /(\d+)/){
$tarif_hash{$1} = 1;
}
if(ref($tariff_all) eq "HASH"){
foreach my $rid (keys (%$tariff_all)){
#$bw->log("$dbname Tariff hash $auth_operator->{txt30}|$tariff_all->{$rid}->{barcode} --> $tarif_hash{$tariff_all->{$rid}->{barcode}}",\%tarif_hash,"");
if(ref(\%tarif_hash) eq "HASH" && $tarif_hash{$tariff_all->{$rid}->{barcode}}){
foreach my $tk (keys(%tarif_hash)){
$bw->log("Tarif FOUND condition: $tk && $rid && $tariff_all->{$rid}->{barcode} == $tk","","");