From 25a86e87e5c136f8cc56c69d10c92c7fc188ecd6 Mon Sep 17 00:00:00 2001 From: ragu Date: Tue, 28 Jun 2022 13:50:59 +0200 Subject: [PATCH] sig service automatic and rental edit fix --- copri4/main/src/Mod/APIfunc.pm | 21 ++++++++++++++------- copri4/main/src/Mod/APIsigclient.pm | 4 ++-- copri4/main/src/Mod/Pricing.pm | 4 ++-- copri4/main/src/Tpl/BaseEdit.pm | 3 ++- copri4/main/src/Tpl/Calorin.pm | 8 ++++---- copri4/shareeapp-operator/src/Lib/Mlogic.pm | 2 +- 6 files changed, 25 insertions(+), 17 deletions(-) diff --git a/copri4/main/src/Mod/APIfunc.pm b/copri4/main/src/Mod/APIfunc.pm index 48ac01d..0fefae9 100755 --- a/copri4/main/src/Mod/APIfunc.pm +++ b/copri4/main/src/Mod/APIfunc.pm @@ -1032,7 +1032,7 @@ sub booking_update(){ state => "", lock_state => "", #station_lock_state => "", - #co2saving => "", + co2saving => "", response_state => "OK 1017: No update", response_text => "Der Mietstatus wurde nicht geƤndert.", }; @@ -1527,7 +1527,7 @@ sub booking_update(){ } my $co2saving = ""; - #$booking->{int26} = 10 if(!$booking->{int26} && ($auth->{c_id} == 1842 || $auth->{c_id} == 5781 || $auth->{c_id} == 11765 || $auth->{c_id} == 1843));#10 km test + $booking->{int26} = 10 if(!$booking->{int26} && ($auth->{c_id} == 1842 || $auth->{c_id} == 5781 || $auth->{c_id} == 11765 || $auth->{c_id} == 1843));#10 km test if($booking->{int26}){ $co2saving = "Einsparung: "; my $co2diff = $pri->co2calc($booking); @@ -1586,12 +1586,19 @@ sub service_automatic { $q->param(-name=>'work_val',-value=>"$lock_charge"); my $article = looks_like_number($bike_id) || looks_like_number($station_id); - (my $xresponse->{$article}, my $responseraw, my $node_template, my $crecord) = $self->service_select($q,$authraw,"","1"); + #insert only new dataset if mtime > 10 days + (my $xresponse->{$article}, my $pos_record, my $node_template, my $crecord) = $self->service_select($q,$authraw,"","10"); + my $service_id = ""; + foreach my $id (sort { $pos_record->{$a}->{barcode} <=> $pos_record->{$b}->{barcode} } keys (%$pos_record)){ + $service_id = $pos_record->{$id}->{c_id} if($pos_record->{$id}->{c_id} > 1); + } - if(ref($xresponse->{$article}) ne "HASH" || !$xresponse->{$article}->{c_id}){ + if(!$service_id){ ($response->{service_id}) = $self->service_insert($q,$authraw,$node_template,$crecord); - $bw->log("service_automatic insert ($xresponse->{$article}->{c_id}) ",$response,""); + $bw->log("service_automatic insert ($response->{service_id}) ",$response,""); my $rows = $self->service_update($q,$authraw,$node_template,$response->{service_id}); + }elsif($service_id){ + my $rows = $self->service_update($q,$authraw,$node_template,$service_id); } } @@ -1854,8 +1861,8 @@ sub bikes_available(){ #new rental_description $return->{$id}->{rental_description}->{name} = "$tariff_content->{$tid}->{ct_name}"; $return->{$id}->{rental_description}->{id} = "$tariff_content->{$tid}->{barcode}"; - $return->{$id}->{rental_description}->{reserve_timerange} = "15 Min"; - $return->{$id}->{rental_description}->{reserve_timerange} = "30 Min" if($record->{$id}->{int11} == 3);#sig timeout time + $return->{$id}->{rental_description}->{reserve_timerange} = "15"; + $return->{$id}->{rental_description}->{reserve_timerange} = "30" if($record->{$id}->{int11} == 3);#sig timeout time $return->{$id}->{rental_description}->{rental_info}->{1} = ["Tracking","Ich stimme der Speicherung (Tracking) meiner Fahrstrecke zwecks wissenschaftlicher Auswertung und Berechnung der CO2-Einsparung zu!"] if($record->{$id}->{int25}); $return->{$id}->{rental_description}->{rental_info}->{2} = ["AGB","Mit der Mietrad Anmietung wird folgender Betreiber AGB zugestimmt (als Demo sharee AGB)."] if($auth->{c_id} && ($auth->{c_id} == 1842 || $auth->{c_id} == 5781 || $auth->{c_id} == 22262 || $auth->{c_id} == 38883)); diff --git a/copri4/main/src/Mod/APIsigclient.pm b/copri4/main/src/Mod/APIsigclient.pm index 28ea552..1cba1a5 100755 --- a/copri4/main/src/Mod/APIsigclient.pm +++ b/copri4/main/src/Mod/APIsigclient.pm @@ -203,7 +203,7 @@ sub sig_available { #new rental_description $response_out->{$bike}->{rental_description}->{name} = "$tariff_content->{$tid}->{ct_name}"; $response_out->{$bike}->{rental_description}->{id} = "$tariff_content->{$tid}->{barcode}"; - $response_out->{$bike}->{rental_description}->{reserve_timerange} = "30 Min"; + $response_out->{$bike}->{rental_description}->{reserve_timerange} = "30"; $response_out->{$bike}->{rental_description}->{rental_info}->{1} = ["Tracking","Ich stimme der Speicherung (Tracking) meiner Fahrstrecke zwecks wissenschaftlicher Auswertung und Berechnung der CO2-Einsparung zu!"];#TODO if($resp->{gps_tracker_id}); $response_out->{$bike}->{rental_description}->{rental_info}->{2} = ["AGB","Mit der Mietrad Anmietung wird folgender Betreiber AGB zugestimmt (als Demo sharee AGB)."] if($ctadr->{c_id} && ($ctadr->{c_id} == 1842 || $ctadr->{c_id} == 5781 || $ctadr->{c_id} == 22262)); @@ -233,7 +233,7 @@ sub sig_available { $return2copri->{$bike}->{int11} = 3;#system $return2copri->{$bike}->{int25} = 1;#tracking on $return2copri->{$bike}->{barcode} = $bike_id; - $return2copri->{$bike}->{txt22} = $resp->{id};#sig bikeId like 380116b5-0522-43da-ab66-477744a731a3 + $return2copri->{$bike}->{txt22} = $resp->{id};#sig bikeId used by rental $return2copri->{$bike}->{int04} = $1 if($response_out->{$bike}->{station} =~ /(\d+)/); $return2copri->{$bike}->{txt01} = "$response_out->{$bike}->{description}"; $return2copri->{$bike}->{int25} = "1" if($resp->{gps_tracker_id}); diff --git a/copri4/main/src/Mod/Pricing.pm b/copri4/main/src/Mod/Pricing.pm index 60236d7..4f38a29 100755 --- a/copri4/main/src/Mod/Pricing.pm +++ b/copri4/main/src/Mod/Pricing.pm @@ -319,8 +319,8 @@ sub fetch_rentalfeed { #new rental_description $return->{rental_description}->{name} = "$ctpos->{txt04}"; $return->{rental_description}->{id} = "$ctpos->{int09}"; - $return->{rental_description}->{reserve_timerange} = "15 Min"; - $return->{rental_description}->{reserve_timerange} = "30 Min" if($ctpos->{int11} == 3); + $return->{rental_description}->{reserve_timerange} = "15"; + $return->{rental_description}->{reserve_timerange} = "30" if($ctpos->{int11} == 3); foreach my $td (sort keys (%$td_template)){ my $time_unit = ""; diff --git a/copri4/main/src/Tpl/BaseEdit.pm b/copri4/main/src/Tpl/BaseEdit.pm index 3188744..9939c51 100755 --- a/copri4/main/src/Tpl/BaseEdit.pm +++ b/copri4/main/src/Tpl/BaseEdit.pm @@ -150,7 +150,7 @@ sub tpl(){ $occupied_style = "color:#ff1493" if($cttpos->{int10} == 2 ||$cttpos->{int10} == 3 || $cttpos->{int10} == 6); if($cttpos->{int35} && $cttpos->{start_time} && $cttpos->{end_time}){ - $cttpos->{end_time} = $now_dt if($cttpos->{int10} == 3); + $cttpos->{end_time} = $now_dt if($cttpos->{int10} == 3 && $cttpos->{int20} == 2); ($pricing,$counting) = $pri->counting_rental(\%varenv,$cttpos,"calc_price"); $rental_feed = $pri->fetch_rentalfeed(\%varenv,$cttpos,$counting); $gesamt = $pri->round($pricing->{total_price}); @@ -305,6 +305,7 @@ EOF my ($key,$des,$size,$postdes) = split /=/,$_; if($key =~ /c_id|ct_name|txt08|barcode/){ + print $q->hidden(-name=>"$key",-override=>1,-value=>"$cttpos->{$key}"),"\n" if($key eq "barcode"); print $q->Tr(),"\n"; print $q->td({-class=>'left_italic_cms'},"$des"),"\n"; print $q->td({-class=>'content1_cms'}, $q->b("$cttpos->{$key}")),"\n"; diff --git a/copri4/main/src/Tpl/Calorin.pm b/copri4/main/src/Tpl/Calorin.pm index a30249e..f159b43 100755 --- a/copri4/main/src/Tpl/Calorin.pm +++ b/copri4/main/src/Tpl/Calorin.pm @@ -192,7 +192,7 @@ sub tpl(){ end_date_time => "$end_date_time", } if(!$R::cttpos_id); - $search->{c_id} = $R::c_id if($R::base_edit eq "save_pos" && $R::c_id); + $search->{barcode} = $q->escapeHTML("$R::barcode") if($R::base_edit eq "save_pos" && $R::barcode); if(!$start_chck && !$end_chck){ if($node_meta->{ct_table} eq "contenttranspos"){ @@ -242,7 +242,7 @@ sub tpl(){ #$h++; my ($key,$des,$size) = split /=/,$_; my $valxx = $q->param("$_"); - $valxx = "" if($R::base_edit eq "save_pos");#empty search fields + $valxx = "" if($R::base_edit eq "save_pos" && $key ne "barcode");#empty search fields, select only bike number if($key =~ /time/){ $size="10px"; @@ -275,9 +275,9 @@ sub tpl(){ else{ $size="9px" if($key =~ /int/); if($key =~ /ct_name/){ - print $q->textfield(-class=>'stxt2',-name=>"$key",-default=>"",-size=>"$size",-override=>'1',-maxlength=>40, -placeholder=>"$des",-autofocus=>1),"\n"; + print $q->textfield(-class=>'stxt2',-name=>"$key",-default=>"$valxx",-size=>"$size",-override=>'1',-maxlength=>40, -placeholder=>"$des",-autofocus=>1),"\n"; }else{ - print $q->textfield(-class=>'stxt2',-name=>"$key",-default=>"",-size=>"$size",-override=>'1', -maxlength=>40, -placeholder=>"$des"),"\n"; + print $q->textfield(-class=>'stxt2',-name=>"$key",-default=>"$valxx",-size=>"$size",-override=>'1', -maxlength=>40, -placeholder=>"$des"),"\n"; } } } diff --git a/copri4/shareeapp-operator/src/Lib/Mlogic.pm b/copri4/shareeapp-operator/src/Lib/Mlogic.pm index 64043c2..4c2a56a 100755 --- a/copri4/shareeapp-operator/src/Lib/Mlogic.pm +++ b/copri4/shareeapp-operator/src/Lib/Mlogic.pm @@ -45,7 +45,7 @@ sub tpl(){ #my $api_test = "sharee_fr01"; my $bike="FR1538"; #my $api_test = "sharee_fr01"; my $bike="FR4781";#Tracking and BVB test #my $api_test = "sharee_kn"; my $bike="KN205"; - #my $api_test = "sharee_wue"; my $bike="WUE5524"; + #my $api_test = "sharee_wue"; my $bike="WUE5525"; my $api_test = "sharee_sx"; my $bike="S3X1001"; #my $api_test = "sharee_ren"; my $bike="REN2";