set multi public tariff on booking

This commit is contained in:
Rainer Gümpelein 2022-01-18 13:30:05 +01:00
parent 235b788024
commit 4a0cc8aacb
2 changed files with 35 additions and 12 deletions

View file

@ -775,6 +775,13 @@ sub net_booking(){
my $ctadr = $db->get_contentrow("contentadr",$auth->{c_id}); my $ctadr = $db->get_contentrow("contentadr",$auth->{c_id});
my $update_adr = {
table => "contentadr",
mtime => "now()",
owner => "$owner",
c_id => "$ctadr->{c_id}",
};
my $pref = { my $pref = {
table => "contenttrans", table => "contenttrans",
fetch => "one", fetch => "one",
@ -815,6 +822,7 @@ sub net_booking(){
foreach my $id (keys (%$tariff_content)){ foreach my $id (keys (%$tariff_content)){
foreach(@adr_tariff){ foreach(@adr_tariff){
if($tariff_content->{$id}->{int12} && $tariff_content->{$id}->{int12} == $ct->{main_id} && $tariff_content->{$id}->{barcode} && $_ == $tariff_content->{$id}->{barcode}){ if($tariff_content->{$id}->{int12} && $tariff_content->{$id}->{int12} == $ct->{main_id} && $tariff_content->{$id}->{barcode} && $_ == $tariff_content->{$id}->{barcode}){
$bw->log("1. net_booking tariff loop matches:",$tariff_content->{$id}->{barcode},"");
$tariff_nr = $tariff_content->{$id}->{barcode}; $tariff_nr = $tariff_content->{$id}->{barcode};
} }
} }
@ -822,6 +830,7 @@ sub net_booking(){
#2021-07-10, if no tarif then update user account to fallback default public or private or hidden tarif #2021-07-10, if no tarif then update user account to fallback default public or private or hidden tarif
#if(!$tariff_nr && !$ctadr->{txt30}) #if(!$tariff_nr && !$ctadr->{txt30})
if(!$tariff_nr){ if(!$tariff_nr){
my @txt30 = ();
foreach my $id (keys (%$tariff_content)){ foreach my $id (keys (%$tariff_content)){
# #int18 # #int18
#<sharing_type> #<sharing_type>
@ -831,12 +840,16 @@ sub net_booking(){
#</sharing_type> #</sharing_type>
if($tariff_content->{$id}->{int18} && ($tariff_content->{$id}->{int18} == 2 || $tariff_content->{$id}->{int18} == 3 || $tariff_content->{$id}->{int18} == 4)){ if($tariff_content->{$id}->{int18} && ($tariff_content->{$id}->{int18} == 2 || $tariff_content->{$id}->{int18} == 3 || $tariff_content->{$id}->{int18} == 4)){
if($tariff_content->{$id}->{int12} && $tariff_content->{$id}->{int12} == $ct->{main_id} && $tariff_content->{$id}->{barcode}){ if($tariff_content->{$id}->{int12} && $tariff_content->{$id}->{int12} == $ct->{main_id} && $tariff_content->{$id}->{barcode}){
$bw->log("2. net_booking tariff loop matches:",$tariff_content->{$id}->{barcode},"");
$tariff_nr = $tariff_content->{$id}->{barcode}; $tariff_nr = $tariff_content->{$id}->{barcode};
} }
if($tariff_content->{$id}->{int12} && $tariff_content->{$id}->{barcode}){
push(@txt30, "$tariff_content->{$id}->{barcode}");
} }
} }
$bw->log("--> NO user tariff defined, update user account to fallback default public or private or hidden",$tariff_nr,""); }
$db->updater("contentadr","c_id",$ctadr->{c_id},"txt30","$tariff_nr",$owner); $bw->log("--> NO user tariff defined, update user account to fallback default public or private or hidden",\@txt30,"");
$dbt->update_one($dbh,$update_adr,"txt30='@txt30'");
}else{ }else{
$bw->log("--> user tariff selected",$tariff_nr,""); $bw->log("--> user tariff selected",$tariff_nr,"");
} }

View file

@ -151,31 +151,41 @@ print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$user_m
### ###
print $q->div({-style=>'margin:15px;'},"&nbsp;"),"\n"; print $q->div({-style=>'margin:15px;'},"&nbsp;"),"\n";
#config
my $uriop = "$dbt->{operator}->{$operator_key}->{operatorApp}/APIjsonserver"; my $uriop = "$dbt->{operator}->{$operator_key}->{operatorApp}/APIjsonserver";
my $bike = "FR1003";
my $latitude = "47.927738";
my $longitude = "7.973855";
if($operator_key eq "sharee_kn"){
$bike = "KN259";
$latitude = "47.66267";
$longitude = "9.17262";
}
print $q->div({-style=>'margin:15px;'},"-------------- $uriop --------------------"),"\n"; print $q->div({-style=>'margin:15px;'},"-------------- $uriop --------------------"),"\n";
my $booking_request = "$uriop?request=booking_request&bike=FR1003&authcookie=$coo"; my $booking_request = "$uriop?request=booking_request&bike=$bike&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_request"},"[ booking_request ]---> $booking_request")),"\n"; print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_request"},"[ booking_request ]---> $booking_request")),"\n";
my $booking_update_cancel = "$uriop?request=booking_update&bike=FR1003&state=canceled&authcookie=$coo"; my $booking_update_cancel = "$uriop?request=booking_update&bike=$bike&state=canceled&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_update_cancel"},"[ booking_update_cancel ]---> $booking_update_cancel")),"\n"; print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_update_cancel"},"[ booking_update_cancel ]---> $booking_update_cancel")),"\n";
my $booking_update_locking = "$uriop?request=booking_update&bike=FR1003&lock_state=locking&authcookie=$coo"; my $booking_update_locking = "$uriop?request=booking_update&bike=$bike&lock_state=locking&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_update_locking"},"[ booking_update_locking ]---> $booking_update_locking")),"\n"; print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_update_locking"},"[ booking_update_locking ]---> $booking_update_locking")),"\n";
my $booking_update_locked = "$uriop?request=booking_update&bike=FR1003&lock_state=locked&authcookie=$coo"; my $booking_update_locked = "$uriop?request=booking_update&bike=$bike&lock_state=locked&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_update_locked"},"[ booking_update_locked ]---> $booking_update_locked")),"\n"; print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_update_locked"},"[ booking_update_locked ]---> $booking_update_locked")),"\n";
my $booking_update_unlocked = "$uriop?request=booking_update&bike=FR1003&lock_state=unlocked&authcookie=$coo"; my $booking_update_unlocked = "$uriop?request=booking_update&bike=$bike&lock_state=unlocked&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_update_unlocked"},"[ booking_update_unlocked ]---> $booking_update_unlocked")),"\n"; print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_update_unlocked"},"[ booking_update_unlocked ]---> $booking_update_unlocked")),"\n";
my $booking_update_oc_ul = "$uriop?request=booking_update&bike=FR1003&state=occupied&lock_state=unlocked&authcookie=$coo"; my $booking_update_oc_ul = "$uriop?request=booking_update&bike=$bike&state=occupied&lock_state=unlocked&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_update_oc_ul"},"[ booking_update_oc_ul ]---> $booking_update_oc_ul")),"\n"; print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_update_oc_ul"},"[ booking_update_oc_ul ]---> $booking_update_oc_ul")),"\n";
my $booking_request_oc_ul = "$uriop?request=booking_request&bike=FR1003&state=occupied&lock_state=unlocked&authcookie=$coo"; my $booking_request_oc_ul = "$uriop?request=booking_request&bike=$bike&state=occupied&lock_state=unlocked&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_request_oc_ul"},"[ booking_request_oc_ul ]---> $booking_request_oc_ul")),"\n"; print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_request_oc_ul"},"[ booking_request_oc_ul ]---> $booking_request_oc_ul")),"\n";
my $booking_update_av_lo = "$uriop?request=booking_update&bike=FR1003&state=available&lock_state=locked&latitude=47.927738&longitude=7.973855&gps_age=300&user_device_manufaturer=samsung)&user_device_model=SM-G398FN&user_device_platform=Android&user_device_version=10&user_device_id=90af86831c10374d&authcookie=$coo"; my $booking_update_av_lo = "$uriop?request=booking_update&bike=$bike&state=available&lock_state=locked&latitude=$latitude&longitude=$longitude&gps_age=300&user_device_manufaturer=samsung)&user_device_model=SM-G398FN&user_device_platform=Android&user_device_version=10&user_device_id=90af86831c10374d&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_update_av_lo"},"[ booking_update_av_lo ]---> $booking_update_av_lo")),"\n"; print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_update_av_lo"},"[ booking_update_av_lo ]---> $booking_update_av_lo")),"\n";
my $user_feedback = "$uriop?request=user_feedback&bike=FR1003&bike_broken=1&message=testnachricht äöü&authcookie=$coo"; my $user_feedback = "$uriop?request=user_feedback&bike=$bike&bike_broken=1&message=testnachricht äöü&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$user_feedback"},"[ user_feedback ]---> $user_feedback")),"\n"; print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$user_feedback"},"[ user_feedback ]---> $user_feedback")),"\n";
print "<div style='text-align:center;'>"; print "<div style='text-align:center;'>";