From 83da7fe92bb0560ce8a54a3a04930014f689ba83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rainer=20G=C3=BCmpelein?= Date: Sun, 23 Jan 2022 19:16:23 +0100 Subject: [PATCH] SWK Tarif on register and delete_account on craete --- copri4/main/src/Mod/APIfunc.pm | 23 ++++++++++++----------- copri4/main/src/Mod/APIjsonserver.pm | 2 +- copri4/main/src/Mod/Indexsharee.pm | 9 ++++++--- copri4/main/src/Mod/Shareework.pm | 8 +++++++- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/copri4/main/src/Mod/APIfunc.pm b/copri4/main/src/Mod/APIfunc.pm index e00fd78..27ce40b 100755 --- a/copri4/main/src/Mod/APIfunc.pm +++ b/copri4/main/src/Mod/APIfunc.pm @@ -1031,7 +1031,7 @@ sub booking_update(){ $geo_debug .= "Out of station distance: $stations_raw->{$id}->{barcode}|$latitude,$longitude,$latitude_station,$longitude_station --> $geo_distance_next Meter ($geo_distance_next <= $geo_distance) station_next: $station_next\n"; $booking_values->{response_state} = "Failure 2178: bike " . $q->param('bike') . " out of GEO fencing. $geo_distance_next meter distance to next station $station_next ."; - $booking_values->{response_text} = "Achtung! Ihr aktueller Standort liegt außerhalb einer Fahrradstation. Die Miete Fahrrad Nr. " . $q->param('bike') . " kann nicht $state_text werden. $geo_distance_next Meter Entfernung zur nächsten Station $station_next ."; + $booking_values->{response_text} = "Achtung! Ihr aktueller Standort liegt außerhalb einer Fahrradstation. Die Miete Fahrrad Nr. " . $q->param('bike') . " kann nicht $state_text werden. $geo_distance_next Meter Entfernung zur nächsten Station $station_next . Falls Sie sich doch an einer Station befinden, dann wiederholen Sie \"Miete beenden\"."; } }else{ @@ -1299,7 +1299,7 @@ sub service_automatic { my $station_id = ""; my $bike_id = ""; - $station_id = $1 if($q->param('station') && $q->param('station') =~ /(\d+)/); + $station_id = $1 if($q->param('station') =~ /(\d+)/);#could be also 0 $bike_id = $1 if($q->param('bike') && $q->param('bike') =~ /(\d+)/); my $authraw = { c_id => $owner };#default sys API my $lock_charge = "Achtung, Fahrradschloss Ladung unter " . $q->param('voltage') . "%"; @@ -1498,10 +1498,11 @@ sub bikes_available(){ } if(ref($tariff_content) eq "HASH"){ foreach my $tid (sort { $tariff_content->{$a}->{barcode} <=> $tariff_content->{$b}->{barcode} } keys (%$tariff_content)){ - $bw->log("bikes_available tariff_content tariff_description if($record->{$id}->{main_id} == $tariff_content->{$tid}->{int12} && $auth->{txt30} =~ /$tariff_content->{$tid}->{barcode}/) BIKE:",$return->{$id}->{bike},""); + #$bw->log("bikes_available tariff_content tariff_description if($record->{$id}->{main_id} == $tariff_content->{$tid}->{int12} && $auth->{txt30} =~ /$tariff_content->{$tid}->{barcode}/) BIKE:",$return->{$id}->{bike},""); foreach(@adr_tariff){ if($record->{$id}->{main_id} == $tariff_content->{$tid}->{int12} && $_ == $tariff_content->{$tid}->{barcode}){ + $bw->log("bikes_available for user c_id: $auth->{c_id} if($record->{$id}->{main_id} == $tariff_content->{$tid}->{int12} && $_ == $tariff_content->{$tid}->{barcode}) on BIKE:",$return->{$id}->{bike},""); $return->{$id}->{tariff_description}->{name} = "$tariff_content->{$tid}->{ct_name}"; $return->{$id}->{tariff_description}->{number} = "$tariff_content->{$tid}->{barcode}"; @@ -1544,18 +1545,19 @@ sub bikes_all(){ my $station_id = ""; my $bike_id = ""; - $station_id = $1 if($q->param('station') && $q->param('station') =~ /(\d+)/); + #$station_id = $1 if($q->param('station') && $q->param('station') =~ /(\d+)/);#doesn't get 0 + $station_id = $1 if($q->param('station') =~ /(\d+)/); $bike_id = $1 if($q->param('bike') && $q->param('bike') =~ /(\d+)/); $pref->{int04} = "=::$station_id" if(looks_like_number($station_id)); $pref->{ barcode} = "=::$bike_id" if(looks_like_number($bike_id)); my $record = {}; #on servicetool only stations on user_tour - $bw->log("stations_service_tour",$stations_allraw,""); + $bw->log("stations_service_tour of adr c_id: $auth->{c_id}",$stations_allraw,""); my @stations_service_tour = (); #shareetool - if($q->param('authcookie') && $dbt->{merchant_ids}->{$varenv->{merchant_id}}->{id} && $dbt->{merchant_ids}->{$varenv->{merchant_id}}->{id} == 187){ + if(!$pref->{int04} && $q->param('authcookie') && $dbt->{merchant_ids}->{$varenv->{merchant_id}}->{id} && $dbt->{merchant_ids}->{$varenv->{merchant_id}}->{id} == 187){ my $stations = ""; if(ref($stations_allraw) eq "HASH" && scalar(@{$user_tour} >= 1)){ foreach my $id (sort { $stations_allraw->{$a}->{int04} <=> $stations_allraw->{$b}->{int04} } keys (%$stations_allraw)){ @@ -1564,17 +1566,16 @@ sub bikes_all(){ } $stations = join(",",@stations_service_tour); $stations =~ s/[a-z_]+//ig; - $pref->{int04} = "IN::($stations)" if($stations); - $bw->log("sub bikes_all with user_tour",$pref,""); + $pref->{int04} = "IN::($stations)" if($stations || $stations eq "0"); } - $record = $dbt->fetch_record($dbh,$pref) if(ref($bike_group) eq "ARRAY" && @{$bike_group}[0]); #bikes_all only if authenticated #}else{ # $bw->log("sub bikes_all",$pref,""); # $record = $dbt->fetch_record($dbh,$pref) if(ref($bike_group) eq "ARRAY" && @{$bike_group}[0]); } - + $bw->log("sub bikes_all with user_tour ($station_id) @stations_service_tour",$pref,""); + $record = $dbt->fetch_record($dbh,$pref) if(ref($bike_group) eq "ARRAY" && @{$bike_group}[0]); my $bikes_on_station = {}; my $op_return = {}; @@ -1736,7 +1737,7 @@ sub stations_all(){ my $station_id = ""; my $work_val_id = ""; - $station_id = $1 if($q->param('station') && $q->param('station') =~ /(\d+)/); + $station_id = $1 if($q->param('station') =~ /(\d+)/);#could be also 0 $work_val_id = $1 if($q->param('work_val') && $q->param('work_val') =~ /(\d+)/); if(looks_like_number($station_id)){ $pref->{int04} = "=::$station_id"; diff --git a/copri4/main/src/Mod/APIjsonserver.pm b/copri4/main/src/Mod/APIjsonserver.pm index 697026c..ddaaff8 100755 --- a/copri4/main/src/Mod/APIjsonserver.pm +++ b/copri4/main/src/Mod/APIjsonserver.pm @@ -463,7 +463,7 @@ elsif($q->param('request') eq "bikes_all"){ #on servicetool only stations on user_tour my $stations_allraw = {}; - (my $stations_not_used,$stations_allraw) = $apif->stations_all($q,\%varenv,$authraw) if($aowner && $aowner eq "187");#shareetool + (my $stations_not_used,$stations_allraw) = $apif->stations_all($q,\%varenv,"",$authraw) if($aowner && $aowner eq "187");#shareetool my ($bikes_all,$bikes_allraw,$bikes_on_station) = $apif->bikes_all($q,\%varenv,$authraw,$stations_allraw); diff --git a/copri4/main/src/Mod/Indexsharee.pm b/copri4/main/src/Mod/Indexsharee.pm index 7382935..27137fa 100755 --- a/copri4/main/src/Mod/Indexsharee.pm +++ b/copri4/main/src/Mod/Indexsharee.pm @@ -194,7 +194,9 @@ sub handler { #2020-07-09 if user-pw authorized, then ignore conflict_ because it matches exist user-data if($tinkc_id && $returnwww && $returnwww =~ /conflict_txt07|conflict_txt08/){ #delete user-pw conflict registration and going on with existing data - $db->delete_content("contentadr",$tinkc_id); + #$db->delete_content("contentadr",$tinkc_id); + $return = $tk->delete_account($tinkc_id,$users_dms->{u_id}); + $apif->authout($q,$coo) if($coo); print redirect("$varenv{wwwhost}/$varenv{mandant}/Anmelden?conflict_failure=1"); exit 0; @@ -203,8 +205,9 @@ sub handler { #we need this to get $R::sessionid to FormEdit #if(length($coo) > 20 && !$q->cookie(-name=>'domcookie')){ ($api_return,$users_sharee) = $apif->auth_verify($q,$author->{authcookie},""); - if(($returnwww && $returnwww =~ /\w+/) || ($users_sharee->{txt31} && $users_sharee->{txt31} =~ /\w/)){ - print redirect("$varenv{wwwhost}/$varenv{mandant}/Account/$varenv{accounting_1}?sessionid=$coo"); + if(($returnwww && $returnwww =~ /failure::(.*)/) || ($users_sharee->{txt31} && $users_sharee->{txt31} =~ /\w/)){ + $returnwww =~ s/::/=/g; + print redirect("$varenv{wwwhost}/$varenv{mandant}/Account/$varenv{accounting_1}?sessionid=$coo\&$returnwww"); exit 0; }else{ print redirect("$varenv{wwwhost}/$varenv{mandant}/Account/$varenv{accounting_1_5}?sessionid=$coo"); diff --git a/copri4/main/src/Mod/Shareework.pm b/copri4/main/src/Mod/Shareework.pm index 131a432..4cf52c0 100755 --- a/copri4/main/src/Mod/Shareework.pm +++ b/copri4/main/src/Mod/Shareework.pm @@ -338,7 +338,13 @@ sub save_account(){ if($bonus_record->{c_id} > 3){#means if not file greped with static c_id <= 3 $dbt->update_content4comp($dbh_operator,$bonus_record->{c_id},"-","1"); } - @txt30_op = ("$bonus_record->{int22}") if($bonus_record->{int22}); + + if($bonus_collect->{1}->{int22} && $bonus_collect->{2}->{int22}){ + @txt30_op = ("$bonus_collect->{1}->{int22}","$bonus_collect->{2}->{int22}"); + print FILE "SWK bonus_collect on adr insert:\n" . Dumper($bonus_collect) . "\n"; + }elsif($bonus_record->{int22}){ + @txt30_op = ("$bonus_record->{int22}"); + } } #address hash wit bonusnr my $adr_bonus = {