From 75c38a872151c142bb3bdb82b1791b5455648073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rainer=20G=C3=BCmpelein?= Date: Tue, 12 Apr 2022 11:21:19 +0200 Subject: [PATCH] Tariff refactoring init --- copri4/main/css/local_style_2.css | 2 +- copri4/main/src/Mod/APIfunc.pm | 10 +- copri4/main/src/Mod/APIjsonserver.pm | 49 ++--- copri4/main/src/Mod/APIsigoclient.pm | 15 +- copri4/main/src/Mod/Callib.pm | 20 +-- copri4/main/src/Mod/DBtank.pm | 3 +- copri4/main/src/Mod/KMLout.pm | 6 +- copri4/main/src/Mod/Prelogic.pm | 2 +- copri4/main/src/Mod/Pricing.pm | 169 +++++++++++++++++- copri4/main/src/Tpl/BaseEdit.pm | 9 + copri4/main/src/Tpl/Liste3.pm | 2 +- copri4/main/src/Tpl/MandantConf.pm | 2 +- copri4/main/src/scripts/tests/index.pl | 15 +- copri4/shareeapp-operator/src/Tpl/FormEdit.pm | 4 +- copri4/shareedms-operator/src/Lib/Mlogic.pm | 4 +- copri4/shareeweb-project/src/Lib/Mlogic.pm | 9 +- 16 files changed, 243 insertions(+), 78 deletions(-) diff --git a/copri4/main/css/local_style_2.css b/copri4/main/css/local_style_2.css index 579c291..a1b2aa9 100755 --- a/copri4/main/css/local_style_2.css +++ b/copri4/main/css/local_style_2.css @@ -663,7 +663,7 @@ div#savestate { div#ContentLogin { text-align:center; - max-width:400px; + max-width:450px; width:100%; padding:20px; margin:20px auto; diff --git a/copri4/main/src/Mod/APIfunc.pm b/copri4/main/src/Mod/APIfunc.pm index 6cce4bd..2625dff 100755 --- a/copri4/main/src/Mod/APIfunc.pm +++ b/copri4/main/src/Mod/APIfunc.pm @@ -1626,7 +1626,15 @@ sub rentals(){ my $return = {}; foreach my $id (sort { $record->{$a}->{end_time} cmp $record->{$b}->{end_time} } keys (%$record)){ - $return->{$id} = $pri->sharee_pricing($record->{$id},"readonly"); + + #last + $return->{$id} = $pri->sharee_pricing($record->{$id},"readonly"); + + #new sharee_pricing + #my $return_counting->{$id} = $pri->counting_rental(\%varenv,$record->{$id},"readonly"); + #my $return_feed->{$id} = $pri->fetch_rentalfeed(\%varenv,$record->{$id}); + #$return->{$id} = { %{ $return_counting->{$id} }, %{ $return_feed->{$id} } }; + my $bike_id = $return->{$id}->{bike}; $bike_id = $1 if($bike_id =~ /(\d+)/); #generate always new ilockit keys. diff --git a/copri4/main/src/Mod/APIjsonserver.pm b/copri4/main/src/Mod/APIjsonserver.pm index c5c4b73..528b777 100755 --- a/copri4/main/src/Mod/APIjsonserver.pm +++ b/copri4/main/src/Mod/APIjsonserver.pm @@ -64,7 +64,7 @@ my $response = { apiserver => "$apiserver", response => "$respreq", uri_primary => "$dbt->{primary}->{sharee_primary}->{primaryApp}", - copri_version => "4.1.10.2", + copri_version => "4.1.11.3", user_id => "", authcookie => "", new_authcoo => "0", @@ -235,15 +235,15 @@ elsif($q->param('request') eq "booking_request"){ } my $response_book = {}; - #2022-04-07 refactored booking_request - #if($varenv{syshost} eq "shareeapp-sx"){ my $ct_bike = {}; my $ct_tariff = {}; ($ct_bike,$ct_tariff) = $apif->fetch_bike_tariff(\%varenv,$authraw,$bike,$aowner); if($ct_bike->{barcode} && $ct_tariff->{barcode}){ my $reserveid = ""; - if($ct_bike->{int11} == 3){ + #disabled + #TODO, check if we need prios revervation for rental. After work maybe enable + if(1==2 && $ct_bike->{int11} == 3){ my $sigo_book = $si->sigo_booking(\%varenv,$auth,$ct_bike,"reserve"); $reserveid = $sigo_book->{reservationId} if($sigo_book->{reservationId}); } @@ -255,10 +255,6 @@ elsif($q->param('request') eq "booking_request"){ $response->{response_state} = "Failure 2001: booking bike $bike fails, bike not available"; $response->{response_text} = "Fahrrad Nr. $bike ist leider nicht verfügbar. Ist die Mietrad Flotte für sie freigeschaltet? Bitte überprüfen Sie Ihre Profildaten auf Vollständigkeit"; } - #}else{ - #2022-04-05 should be obsolet, use booking_request @all - #$response_book = $tk->net_booking($authraw,$q->param('bike'),$aowner,$gps); - #} #just in time booking if(ref($response_book) eq "HASH" && $response_book->{response_state} =~ /OK/ && $q->param('state') && $q->param('state') =~ /occupied/){ @@ -267,7 +263,7 @@ elsif($q->param('request') eq "booking_request"){ table => "contenttranspos", fetch => "one", barcode => "$bike_id", - int10 => "IN::('2','3')", + int10 => "2", ca_id => "$authraw->{c_id}", }; my $dbh = ""; @@ -332,16 +328,27 @@ elsif($q->param('request') eq "booking_cancel" || $q->param('request') eq "booki if($q->param('request') eq "booking_update" && $q->param('state') && $q->param('state') =~ /canceled/){ - #TODO sigo request - ($rows, my $booking_values) = $apif->booking_update($q,\%varenv,$authraw,$aowner); + my $reserveid = ""; + if($ctpos->{int11} == 3){ + my $sigo_book = $si->sigo_booking(\%varenv,$auth,$ctpos,"reserve_end"); + $reserveid = $sigo_book->{reservationId} if($sigo_book->{reservationId}); + } + + ($rows, my $booking_values) = $apif->booking_update($q,\%varenv,$authraw,$aowner,$reserveid); $response = {%$response, %$booking_values}; }elsif($q->param('request') eq "booking_update" && (($q->param('state') && $q->param('state') =~ /occupied|available/) || ($q->param('lock_state') && $q->param('lock_state') =~ /locking|locked|unlocking|unlocked/))){ my $rentalid = ""; if($ctpos->{int11} == 3){ - my $sigo_book = $si->sigo_booking(\%varenv,$auth,$ctpos,"cancel"); + if($q->param('state') eq "occupied"){ + my $sigo_book = $si->sigo_booking(\%varenv,$auth,$ctpos,"rental"); $rentalid = $sigo_book->{rentalId} if($sigo_book->{rentalId}); + } + if($q->param('state') eq "available"){ + my $sigo_book = $si->sigo_booking(\%varenv,$auth,$ctpos,"rental_end"); + $rentalid = $sigo_book->{rentalId} if($sigo_book->{rentalId}); + } } ($rows, my $booking_values) = $apif->booking_update($q,\%varenv,$authraw,$aowner,$rentalid); @@ -425,24 +432,6 @@ elsif($q->param('request') eq "booking_cancel" || $q->param('request') eq "booki } } -#user_rental_history -elsif($q->param('request') eq "user_rentals_history"){ - ($aowner,my $return_merchant) = $apif->fetch_merchant($q,\%varenv,$coo,$q->param('merchant_id')); - $varenv{merchant_id} = $return_merchant->{merchant_id}; - $response = { %$response, %$return_merchant }; - - my ($auth,$authraw) = $apif->auth_verify($q); - $response = { %$response, %$auth }; - - if(ref($auth) eq "HASH" && $auth->{authcookie}){ - my ($record,$operator_hash) = $apif->user_rentals_history($q,$authraw); - $response->{rentals} = $apif->rentals($record,$authraw,"0"); - }else{ - $response->{response_state} = "Failure 1001: authcookie not defined"; - $response->{response_text} = "Entschuldigung, die Sitzung wurde unterbrochen"; - } -} - #user_bikes_occupied elsif($q->param('request') eq "user_bikes_occupied"){ if($varenv{syshost} eq "shareeapp-primary"){ diff --git a/copri4/main/src/Mod/APIsigoclient.pm b/copri4/main/src/Mod/APIsigoclient.pm index 74db7b2..bb6330c 100755 --- a/copri4/main/src/Mod/APIsigoclient.pm +++ b/copri4/main/src/Mod/APIsigoclient.pm @@ -257,18 +257,24 @@ sub sigo_booking { email => "r.guempelein\@sharee.bike" ); } - - if($todo eq "rental"){ + elsif($todo eq "rental"){ $endpoint .= "rental"; %json = ( bikeId => "$ct_bike->{txt22}", email => "r.guempelein\@sharee.bike" ); } + else{ + print "Failure, request $todo not defined\n"; - my $rest_json = encode_json(\%json); + } - my $ret_json = $self->post_sigo($endpoint,$rest_json); + print FILE "---> DATA $endpoint:\n" . Dumper(\%json) . "\n"; + + if(ref(\%json) eq "HASH" && $json{email}){ + my $rest_json = encode_json(\%json); + + my $ret_json = $self->post_sigo($endpoint,$rest_json); # eval { $sigo_book = decode_json($ret_json); @@ -281,6 +287,7 @@ sub sigo_booking { #warn $@; print FILE "warn:" . $@ . "\n"; } + } close(FILE); return $sigo_book; diff --git a/copri4/main/src/Mod/Callib.pm b/copri4/main/src/Mod/Callib.pm index e5fe13a..2d98edb 100755 --- a/copri4/main/src/Mod/Callib.pm +++ b/copri4/main/src/Mod/Callib.pm @@ -161,10 +161,8 @@ sub time4de(){ #Prepares contenttranspos start_time, end_time and count/Menge sub contenttranspos_dating() { my $self = shift; - my ($pos_id,$pos_start_time,$pos_end_time,$today4db,$hours,$ctt_start,$ctt_end,$owner) = @_; + my ($pos_id,$pos_start_time,$pos_end_time,$today4db,$hours) = @_; my $menge = 0; - my $s_up; - my $e_up; $bw->log("sub contenttranspos_dating call from Callib:",\@_,""); @@ -193,25 +191,13 @@ sub contenttranspos_dating() { #Count Menge in hours my $diff_time = $e_time - $s_time; $menge = $diff_time / 3600;#to get hours - #$menge = $lb->round($menge); - my $s_cttime; - my $e_cttime; - if($ctt_start && $ctt_end){ - my ($s_yy,$s_mo,$s_dd,$s_hh,$s_mi) = &split_date("",$ctt_start); - my ($e_yy,$e_mo,$e_dd,$e_hh,$e_mi) = &split_date("",$ctt_end); - $s_cttime = Mktime($s_yy,$s_mo,$s_dd,$s_hh,$s_mi,0); - $e_cttime = Mktime($e_yy,$e_mo,$e_dd,$e_hh,$e_mi,0); - } - #Never used calc of min max time - $s_up = 1 if(!$s_cttime || $s_time < $s_cttime); - $e_up = 1 if(!$e_cttime || $e_time > $e_cttime); } } - my @return_array = ($pos_id,$start_datetime,$end_datetime,$s_up,$e_up,$menge); + my @return_array = ($pos_id,$start_datetime,$end_datetime,$menge); $bw->log("sub contenttranspos_dating return from Callib:",\@return_array,""); - return ($start_datetime,$end_datetime,$s_up,$e_up,$menge); + return ($start_datetime,$end_datetime,$menge); } 1; diff --git a/copri4/main/src/Mod/DBtank.pm b/copri4/main/src/Mod/DBtank.pm index d126dc9..3618a86 100755 --- a/copri4/main/src/Mod/DBtank.pm +++ b/copri4/main/src/Mod/DBtank.pm @@ -1064,7 +1064,8 @@ sub collect_transpos { my $where = "where cp.ct_id=ct.c_id"; foreach my $key (keys (%$search)){ - $search->{$key} =~ s/\s//g if($key ne "start_time_interval"); + $search->{$key} =~ s/^\s//g; + $search->{$key} =~ s/\s$//g; $where .= " and cp.c_id = $search->{$key}" if($key eq "cttpos_id" && $search->{$key}); if($key eq "start_time_interval"){ $where .= " and cp.start_time <= $search->{$key}"; diff --git a/copri4/main/src/Mod/KMLout.pm b/copri4/main/src/Mod/KMLout.pm index 5ceb676..755622c 100755 --- a/copri4/main/src/Mod/KMLout.pm +++ b/copri4/main/src/Mod/KMLout.pm @@ -171,19 +171,19 @@ sub kmlGenerator { #if Lastenrad if($station_groupID == $lastenrad && $station_groupID == $bike_groupID && $station eq $response_bikes->{shareejson}->{bikes}->{$bike}->{station}){ $place_pin{$station} = $icon_green; - $place_desc{$station} .= "

• Lastenrad vorrätig: $response_bikes->{shareejson}->{bikes}->{$bike}->{description} $bike

"; + $place_desc{$station} .= "

• Verfügbar: $response_bikes->{shareejson}->{bikes}->{$bike}->{description} $bike

"; #print "($station) Lastenrad $bike\n"; } #if E-Lastenrad if($station_groupID == $e_lastenrad && $station_groupID == $bike_groupID && $station eq $response_bikes->{shareejson}->{bikes}->{$bike}->{station}){ $place_pin{$station} = $icon_green; - $place_desc{$station} .= "

• E-Lastenrad vorrätig: $response_bikes->{shareejson}->{bikes}->{$bike}->{description} $bike

"; + $place_desc{$station} .= "

• Verfügbar: $response_bikes->{shareejson}->{bikes}->{$bike}->{description} $bike

"; #print "($station) E-Lastenrad $bike\n"; } #if Stadtrad if($station_groupID == $stadtrad && $station_groupID == $bike_groupID && $station eq $response_bikes->{shareejson}->{bikes}->{$bike}->{station}){ $place_pin{$station} = $icon_green; - $place_desc{$station} .= "

• Stadtrad vorrätig: $response_bikes->{shareejson}->{bikes}->{$bike}->{description} $bike

"; + $place_desc{$station} .= "

• Verfügbar: $response_bikes->{shareejson}->{bikes}->{$bike}->{description} $bike

"; #print "($station) Stadtrad $bike\n"; } diff --git a/copri4/main/src/Mod/Prelogic.pm b/copri4/main/src/Mod/Prelogic.pm index aa63a55..59f6998 100755 --- a/copri4/main/src/Mod/Prelogic.pm +++ b/copri4/main/src/Mod/Prelogic.pm @@ -355,7 +355,7 @@ sub preinit(){ if($ib_key =~ /save_pos/){ my $pos_id = $R::c_idpos; - my ($start_datetime,$end_datetime,$s_up,$e_up,$menge) = $cb->contenttranspos_dating($pos_id,$start_time,$end_time,$today4db,""); + my ($start_datetime,$end_datetime,$menge) = $cb->contenttranspos_dating($pos_id,$start_time,$end_time,$today4db); my ($s_yy,$s_mo,$s_dd,$s_hh,$s_mi) = $cb->split_date($start_datetime); my $s_time = Mktime($s_yy,$s_mo,$s_dd,$s_hh,$s_mi,0); my ($e_yy,$e_mo,$e_dd,$e_hh,$e_mi) = $cb->split_date($end_datetime); diff --git a/copri4/main/src/Mod/Pricing.pm b/copri4/main/src/Mod/Pricing.pm index a5108b3..371c045 100755 --- a/copri4/main/src/Mod/Pricing.pm +++ b/copri4/main/src/Mod/Pricing.pm @@ -3,11 +3,18 @@ package Pricing; # SPDX-License-Identifier: AGPL-3.0-or-later # Copyright (c) Rainer Gümpelein, TeilRad GmbH # +#Rental counting and pricing methods +# +#perl -cw +use lib qw(/var/www/copri-bike/shareeapp-operator/src); +# use strict; use warnings; use POSIX; use CGI; # only for debugging use Scalar::Util qw(looks_like_number); +use DateTime; +use DateTime::Format::Pg; use Lib::Config; use Mod::Libenz; @@ -54,6 +61,163 @@ sub only_first_free(){ } +#new counting rental time in hours method (last sharee_pricing) +sub counting_rental { + my $self = shift; + my $varenv = shift; + my $ctpos = shift; + my $todo = shift; + my $today4db = strftime("%Y-%m-%d %H:%M:%S",localtime(time)); + + my $return = {}; + my $logging = {}; + $logging->{ID} = "c_id:$ctpos->{c_id}/ct_id:$ctpos->{ct_id}/ca_id:$ctpos->{ca_id}"; + + my $computed_end_time = $ctpos->{end_time} || $today4db; + $computed_end_time = $today4db if($ctpos->{int10} && $ctpos->{int10} == 3); + + + my $dt0 = DateTime::Format::Pg->parse_datetime($ctpos->{start_time}); + my $dt1 = DateTime::Format::Pg->parse_datetime($computed_end_time); + my $dur01 = $dt0->subtract_datetime($dt1); + my ($durhh,$durmm) = $dur01->in_units( 'hours','minutes' ); + $durhh = sprintf('%.2d',$durhh); + $durmm = sprintf('%.2d',$durmm); + + + #calculates rental time range in hours + my ($start_datetime,$end_datetime,$hours) = $cal->contenttranspos_dating($ctpos->{c_id},$ctpos->{start_time},"$computed_end_time","$today4db"); + $logging->{hours_input} = $hours; + $logging->{tariff} = "$ctpos->{txt04} - $ctpos->{int09}"; + + my $price = 2; #FIXME to real val. must be not 0 + $price = sprintf('%.2f',$ctpos->{int02}) if($ctpos->{int02} && $ctpos->{int02} > 0); + my $total = 0; + + my $days_pricemax = $ctpos->{int17} || 9; + $logging->{days_pricemax} = $days_pricemax; + #example my $days_pricemax = 5; #konrad max 15,- € bike/day depends on 3,- €/hour + + #calculate if rental hours greater than hours for max daily_price + my $days_hour4price = $days_pricemax / $price; + $logging->{days_hour4price} = $days_hour4price; + my $real_hours = $hours; + + if($ctpos->{int16} && $ctpos->{int16} > 0){#z.b. 30 Min/Gratis --> 0.5 + my $ctpos_freed = $self->only_first_free($ctpos); + #Bsp 1h = 60min , 60*0,02 = 1,2min + if(!$ctpos_freed->{c_id} || $real_hours <= 0.02){ + $hours -= $ctpos->{int16}; + $logging->{hours_freed} = $hours; + }else{ + $logging->{hours_freed} = "Not freed because of (!$ctpos_freed->{c_id} && $ctpos->{int16} || $real_hours <= 0.02)"; + } + } + + #If available then take saved hours + if($ctpos->{int10} && $ctpos->{int10} == 1 && $todo eq "readonly"){ + if($ctpos->{int03} && $ctpos->{int03} > 0){ + $hours = $ctpos->{int03}; + $total = $hours * $price if(looks_like_number($hours) && looks_like_number($price)); + }else{ + $hours = 0; + $total = 0; + } + } + #jede angebrochene Std. + elsif(looks_like_number($hours) && $hours > 0){ + if($days_hour4price > 0 && $hours >= $days_hour4price && $hours <= 24){ + $logging->{_hours_lower24} = "$days_hour4price > 0 && $hours >= $days_hour4price && $hours <= 24"; + $logging->{__hours_lower24} = $hours; + $hours = $days_hour4price; + $logging->{hours_lower24} = $hours; + } + elsif($days_hour4price > 0 && $hours >= 24){ + $logging->{hours_greate24} = "$days_hour4price > 0 && $hours >= 24"; + my $days = $hours / 24; + my $days_int = $days; + my $dez = 0; + ($days_int,$dez) = split(/\./, $days) if($days =~ /\.\d/); + my $days_hour = $days_int * 24; + my $rest = $hours - $days_hour; + $rest = $days_hour4price if($rest > $days_hour4price); + $hours = ($days_int * $days_hour4price) + $rest; + $logging->{hours_compute} = "$hours = ($days_int * $days_hour4price) + $rest"; + } + + $logging->{hours_preround} = $hours; + $hours = $lb->round_half($hours); + $logging->{hours_postround} = $hours; + $total = $hours * $price if(looks_like_number($hours) && looks_like_number($price)); + }else{ + $hours = 0; + } + $total = sprintf('%.2f', $total); + #Bsp 1h = 60min , 60*0,02 = 1,2min + $hours = "0" if($real_hours <= 0.02); + + $return->{start_time} = "$ctpos->{start_time}"; + $return->{end_time} = "$computed_end_time"; + $return->{real_hours} = "$real_hours"; + $return->{computed_hours} = "$hours"; + $return->{unit_price} = "$price"; + $return->{total_price} = "$total"; + + $bw->log("hour computed:",$logging,""); + return $return; +}#end counting_rental + +#all other values returned by user_bikes_occupied +sub fetch_rentalfeed { + my $self = shift; + my $varenv = shift; + my $ctpos = shift; + + my $bike_group = "$dbt->{operator}->{$varenv->{dbname}}->{oprefix}$ctpos->{int12}" || ""; + + my $return = {}; + $return->{bike_group} = ["$bike_group"]; + $return->{station} = "$dbt->{operator}->{$varenv->{dbname}}->{oprefix}$ctpos->{int04}";#TODO save with prefix + $return->{uri_operator} = "$varenv->{wwwhost}";#TODO, should be DB select + $return->{bike} = "$dbt->{operator}->{$varenv->{dbname}}->{oprefix}$ctpos->{barcode}"; + $return->{state} = "$dbt->{copri_conf}->{bike_state}->{$ctpos->{int10}}" || ""; + $return->{bike_charge} = "$ctpos->{int19}" if($ctpos->{int19}); + $return->{description} = "$ctpos->{txt01}"; + $return->{request_time} = "$ctpos->{itime}"; + $return->{system} = "Ilockit" if($ctpos->{int11} && $ctpos->{int11} == 2); + $return->{system} = "sigo" if($ctpos->{int11} && $ctpos->{int11} == 3); + + if($ctpos->{int11}){ + #$return->{gps} = "$ctpos->{txt06}";#end_gps + ($return->{gps}->{latitude},$return->{gps}->{longitude}) = split(/,/,$ctpos->{txt06}); + + #if($ctpos->{txt10} =~ /requested|occupied/) + if($ctpos->{int10} == 2 || $ctpos->{int10} == 3){ + $return->{tariff_description}->{name} = "$ctpos->{txt04}"; + $return->{tariff_description}->{number} = "$ctpos->{int09}"; + $return->{tariff_description}->{eur_per_hour} = "$ctpos->{int02}" || "0"; + $return->{tariff_description}->{max_eur_per_day} = "$ctpos->{int17}" || "0"; + $return->{tariff_description}->{free_hours} = "$ctpos->{int16}" if($ctpos->{int16} && $ctpos->{int16} > 0); + $return->{tariff_description}->{abo_eur_per_month} = "$ctpos->{int15}" if($ctpos->{int15} && $ctpos->{int15} > 0); + $return->{tariff_description}->{track_info} = "Ich stimme der Speicherung (Tracking) meiner Fahrstrecke zwecks wissenschaftlicher Auswertung und Berechnung der CO2-Einsparung zu!" if($ctpos->{int25}); + $return->{tariff_description}->{operator_agb} = "Mit der Mietrad Anmietung wird folgender Betreiber AGB zugestimmt (als Demo sharee AGB)." if($ctpos->{ca_id} == 1842 || $ctpos->{ca_id} == 5781); + + $return->{Ilockit_GUID} = "$ctpos->{txt17}" if($ctpos->{int11} == 2); + $return->{Ilockit_ID} = "$ctpos->{txt18}" if($ctpos->{int11} == 2); + #$return->{gps} = "$ctpos->{txt06}";#start_gps + ($return->{gps}->{latitude},$return->{gps}->{longitude}) = split(/,/,$ctpos->{txt06}); + $return->{lock_state} = "locked" if($ctpos->{int20} == 1); + $return->{lock_state} = "unlocked" if($ctpos->{int20} == 2); + $return->{lock_state} = "locking" if($ctpos->{int20} == 3); + $return->{lock_state} = "unlocking" if($ctpos->{int20} == 4); + } + } + return $return; +} + + +# +#last sub sharee_pricing(){ my $self = shift; my $ctpos = shift; @@ -68,10 +232,11 @@ sub sharee_pricing(){ my $computed_end_time = $ctpos->{end_time} || $today4db; $computed_end_time = $today4db if($ctpos->{int10} && $ctpos->{int10} == 3); - my ($start_datetime,$end_datetime,$s_up,$e_up,$hours) = $cal->contenttranspos_dating($ctpos->{c_id},$ctpos->{start_time},"$computed_end_time","$today4db",""); + #calculates rental time range in hours + my ($start_datetime,$end_datetime,$hours) = $cal->contenttranspos_dating($ctpos->{c_id},$ctpos->{start_time},"$computed_end_time","$today4db"); $logging->{hours_input} = $hours; $logging->{tariff} = "$ctpos->{txt04} - $ctpos->{int09}"; -; + my $bike_group = "$dbt->{operator}->{$varenv{dbname}}->{oprefix}$ctpos->{int12}" || ""; my $days_pricemax = $ctpos->{int17} || 9; $logging->{days_pricemax} = $days_pricemax; diff --git a/copri4/main/src/Tpl/BaseEdit.pm b/copri4/main/src/Tpl/BaseEdit.pm index fcdf877..32444a0 100755 --- a/copri4/main/src/Tpl/BaseEdit.pm +++ b/copri4/main/src/Tpl/BaseEdit.pm @@ -398,6 +398,15 @@ EOF print $q->td({-class=>'left_italic_cms'},"$des"),"\n"; print $q->td({-class=>'content1_cms',-colspan=>'2'},$but->selector_class("$key","eselect","",$ctrel->{$key},@_lock_valxx)); } + elsif($key =~ /int01/ && "$size" eq "select" && $node_meta->{tpl_id} == 210){#tariff_unit + my @_unit_valxx = (); + while (my ($key, $value) = each %{ $dbt->{copri_conf}->{tariff_unit} }) { + push @_unit_valxx, "$key:$value";#[0.5:0,5 Std] + } + print $q->Tr(); + print $q->td({-class=>'left_italic_cms'},"$des"),"\n"; + print $q->td({-class=>'content1_cms',-colspan=>'2'},$but->selector_class("$key","eselect","",$ctrel->{$key},@_unit_valxx)); + } elsif($key =~ /int/ && "$size" eq "select"){ my @_valxx; my $selsize="50px"; diff --git a/copri4/main/src/Tpl/Liste3.pm b/copri4/main/src/Tpl/Liste3.pm index 012dca6..231cf85 100755 --- a/copri4/main/src/Tpl/Liste3.pm +++ b/copri4/main/src/Tpl/Liste3.pm @@ -597,7 +597,7 @@ sub tpl(){ $s_hash = $dbt->{copri_conf}->{station_state} if($tpl_id == 225 && $key eq "int10"); $s_hash = $dbt->{copri_conf}->{lock_system} if($tpl_id == 205 && $key eq "int11"); $s_hash = $dbt->{copri_conf}->{sharing_type} if($tpl_id == 210 && $key eq "int18"); - #$s_hash = $dbt->{copri_conf}->{tariff_unit} if($tpl_id == 210 && $key eq "int01"); + $s_hash = $dbt->{copri_conf}->{tariff_unit} if($tpl_id == 210 && $key eq "int01"); $s_hash = { 1 => 1, 2 => 2, 3 => 3, 4 => 4 } if($tpl_id == 225 && $key eq "txt07"); #while (my ($key, $value) = each %{ $s_hash }) { foreach my $s_key (sort keys (%{ $s_hash })) { diff --git a/copri4/main/src/Tpl/MandantConf.pm b/copri4/main/src/Tpl/MandantConf.pm index 33bf964..f5e66cc 100755 --- a/copri4/main/src/Tpl/MandantConf.pm +++ b/copri4/main/src/Tpl/MandantConf.pm @@ -125,7 +125,7 @@ sub tpl(){ print $q->Tr(); if($key =~ /ct_name/){ print $q->td({-class=>'tdescr2'}, ""),"\n"; - print $q->td({-class=>'tdval2'},"Project: $dbt->{operator}->{$varenv{dbname}}->{project} | Prefix: $dbt->{operator}->{$varenv{dbname}}->{oprefix} | DB: $dbt->{operator}->{$varenv{dbname}}->{database}->{dbname}"),"\n"; + print $q->td({-class=>'tdval2'},"$dbt->{operator}->{$varenv{dbname}}->{title} | $dbt->{operator}->{$varenv{dbname}}->{oprefix} | $dbt->{operator}->{$varenv{dbname}}->{database}->{dbname}"),"\n"; }else{ print $q->td({-class=>'tdescr2'},"$des"),"\n"; print $q->td({-class=>'tdval2'}, "$value"),"\n"; diff --git a/copri4/main/src/scripts/tests/index.pl b/copri4/main/src/scripts/tests/index.pl index c673b1b..a0dd894 100755 --- a/copri4/main/src/scripts/tests/index.pl +++ b/copri4/main/src/scripts/tests/index.pl @@ -33,6 +33,7 @@ my %varenv = $cf->envonline(); die "no configuration available" if(!$varenv{wwwhost}); my $operator_key = $q->param('api_test'); + my $bike = $q->param('bike'); my $lang = "de"; my $dyn_js = " @@ -139,10 +140,6 @@ print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$statio my $user_bikes_occupied = "$uri?request=user_bikes_occupied&authcookie=$coo"; print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$user_bikes_occupied"},"[ user_bikes_occupied ]---> $user_bikes_occupied")),"\n"; -my $user_rentals_history = "$uri?request=user_rentals_history&authcookie=$coo"; -print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$user_rentals_history"},"[ user_rentals_history ]---> $user_rentals_history")),"\n"; - - my $user_minianswer = "$uri?request=user_minianswer&q1=opt5&q2=opt4&q3=iuwehfiolbev&authcookie=$coo"; print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$user_minianswer"},"[ user_minianswer ]---> $user_minianswer")),"\n"; @@ -151,10 +148,10 @@ print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$user_m print $q->div({-style=>'margin:15px;'}," "),"\n"; #config my $uriop = "$dbt->{operator}->{$operator_key}->{operatorApp}/APIjsonserver"; -my $bike = "FR1003"; + +#my $bike = "FR1003"; my $latitude = "47.927738"; my $longitude = "7.973855"; - #not used my $and_station_state_locking = ""; my $and_station_state_locked = ""; @@ -162,7 +159,7 @@ my $and_station_state_unlocked = ""; #system=sigo if($operator_key eq "sharee_sx"){ - $bike = "SX1150"; + #$bike = "SX1150"; $latitude = ""; $longitude = ""; #$and_station_state_locking = "&station_state=locking"; @@ -171,12 +168,12 @@ if($operator_key eq "sharee_sx"){ } if($operator_key eq "sharee_kn"){ - $bike = "KN259"; + #$bike = "KN259"; $latitude = "47.66267"; $longitude = "9.17262"; } if($operator_key eq "sharee_wue"){ - $bike = "WUE5529"; + #$bike = "WUE5529"; $latitude = "47.997930"; $longitude = "7.785428"; } diff --git a/copri4/shareeapp-operator/src/Tpl/FormEdit.pm b/copri4/shareeapp-operator/src/Tpl/FormEdit.pm index 366058f..b5466f4 100755 --- a/copri4/shareeapp-operator/src/Tpl/FormEdit.pm +++ b/copri4/shareeapp-operator/src/Tpl/FormEdit.pm @@ -369,7 +369,9 @@ Nach Abschluss der Registrierung erhalten Sie sowohl auf die von Ihnen hinterleg if($cttpos->{$id}->{int09}){#if Tarifnr then bike #print $q->td({-class=>'tdint', -style=>"$occupied_style"},"Station $cttpos->{$id}->{$key}"); print "\n"; - print $q->span("Station
→ $cttpos->{$id}->{txt12}$cttpos->{$id}->{int06}
← $cttpos->{$id}->{txt13}$cttpos->{$id}->{int04}"); + my $return_station = ""; + $return_station = "← $cttpos->{$id}->{txt13}$cttpos->{$id}->{int04}" if($cttpos->{$id}->{txt13} && $cttpos->{$id}->{int04}); + print $q->span("Station
→ $cttpos->{$id}->{txt12}$cttpos->{$id}->{int06}
$return_station"); print "\n"; }else{ print $q->td({-class=>'tdint', -style=>"$occupied_style"},"$cttpos->{$id}->{$key}"); diff --git a/copri4/shareedms-operator/src/Lib/Mlogic.pm b/copri4/shareedms-operator/src/Lib/Mlogic.pm index aa6b111..db0001a 100755 --- a/copri4/shareedms-operator/src/Lib/Mlogic.pm +++ b/copri4/shareedms-operator/src/Lib/Mlogic.pm @@ -58,7 +58,7 @@ sub tpl(){ my $title = ""; $title .= $dbt->{primary}->{$varenv->{dbname}}->{title} if($dbt->{primary}->{$varenv->{dbname}}->{title}); $title .= $dbt->{operator}->{$varenv->{dbname}}->{title} if($dbt->{operator}->{$varenv->{dbname}}->{title}); - $title .= " " . $dbt->{operator}->{$varenv->{dbname}}->{oprefix} if($dbt->{operator}->{$varenv->{dbname}}->{oprefix}); + $title .= " | " . $dbt->{operator}->{$varenv->{dbname}}->{oprefix} if($dbt->{operator}->{$varenv->{dbname}}->{oprefix}); $title .= $dbt->{website}->{$varenv->{syshost}}->{title} if($dbt->{website}->{$varenv->{syshost}}->{title}); $title .= " (devel $varenv->{dbname})" if($dbt->{copri_conf}->{stage} eq "test"); @@ -113,7 +113,7 @@ sub tpl(){ print "
\n"; #Login - print $q->div({-class=>'content2'}, "Zugang zum $title"),"\n"; + print $q->div({-class=>'content2', -nowrap=>1}, $q->img({ -style=>"height:25px",-src=>"$varenv->{head_logo}"}),"Operator Login – $title"),"\n"; print $q->div({-style=>'color:#c83434'},"Login failure"),"\n" if("$R::login_dms" eq "Login" && !$users_dms->{u_id}); print $q->label({-for=>'Userid'},""),"\n"; print $q->textfield(-class=>'form-control', -name=>'user_id', -value=>'', -override=>1, -type=>'email',-class=>'form-control', -id=>'Userid', -placeholder=>'NutzerIn', -required=>1, -autofocus=>1),"\n"; diff --git a/copri4/shareeweb-project/src/Lib/Mlogic.pm b/copri4/shareeweb-project/src/Lib/Mlogic.pm index 07f89fe..ecc1a1c 100755 --- a/copri4/shareeweb-project/src/Lib/Mlogic.pm +++ b/copri4/shareeweb-project/src/Lib/Mlogic.pm @@ -46,12 +46,13 @@ sub tpl(){ ($node,$rows) = $dbt->collect_noderel($dbh,$dbt->{website}->{$varenv->{syshost}}->{parent_id}); if($users_sharee->{c_id} eq $varenv->{superu_id} || $dbt->{copri_conf}->{stage} eq "test"){ - my $coo = $q->cookie('domcookie') || $q->param('sessionid') || ""; + my $coo = $q->cookie('domcookie') || $q->param('sessionid') || $dbt->{website}->{$varenv->{syshost}}->{merchant_id}; #my $api_test = "sharee_kn"; #my $api_test = "sharee_fr01"; #my $api_test = "sharee_wue"; - my $api_test = "sharee_sx"; - print $q->div({-style=>'float:right;text-align:right;height:25px;padding:6px 15px;background-color:white'},$q->a({-style=>"background-color:#ffffff;color:#$bgcolor1;", -href=>"$varenv->{metahost}/src/scripts/tests/index.pl?sessionid=$coo\&api_test=$api_test", -target=>'_blank'}," [ tests --> $api_test ] ")),"\n"; + #my $api_test = "sharee_sx"; my $bike="SX1150"; + my $api_test = "sharee_ren"; my $bike="REN2"; + print $q->div({-style=>'float:right;text-align:right;height:25px;padding:6px 15px;background-color:white'},$q->a({-style=>"background-color:#ffffff;color:#$bgcolor1;", -href=>"$varenv->{metahost}/src/scripts/tests/index.pl?sessionid=$coo\&api_test=$api_test\&bike=$bike", -target=>'_blank'}," [ tests --> $api_test ] ")),"\n"; } my $site_padding = "20px 0"; @@ -119,7 +120,7 @@ sub tpl(){ print ""; print ""; print ""; - print ""; + print ""; if($users_sharee->{c_id} && $R::sharee_edit ne "delete_account2"){ print " | $users_sharee->{txt08} logout\n";