VK Terminal with tariff_description2

This commit is contained in:
ragu 2022-04-26 20:57:13 +02:00
parent 4108673ef1
commit e6ca75a66a
10 changed files with 338 additions and 176 deletions

View file

@ -1167,9 +1167,12 @@ sub booking_update(){
#return after booking_update
#my $pricing = $pri->sharee_pricing($record_pos,"calc_price");
#new sharee_pricing
my $pricing = $pri->counting_rental(\%varenv,$record_pos,"calc_price");
my ($pricing,$counting) = $pri->counting_rental(\%varenv,$record_pos,"calc_price");
$update_pos->{int03} = "$pricing->{computed_hours}" if(looks_like_number($pricing->{computed_hours}));
$update_pos->{int38} = "$counting->{int38}" if(looks_like_number($counting->{int38}));
$update_pos->{int39} = "$counting->{int39}" if(looks_like_number($counting->{int39}));
$update_pos->{int40} = "$counting->{int40}" if(looks_like_number($counting->{int40}));
$update_pos->{int41} = "$counting->{int41}" if(looks_like_number($counting->{int41}));
$update_pos->{int10} = "$state_key";
$update_pos->{txt11} = "$rentalid";
@ -1222,9 +1225,13 @@ sub booking_update(){
#return after booking_update
#my $pricing = $pri->sharee_pricing($record_pos,"calc_price");
#new sharee_pricing
my $pricing = $pri->counting_rental(\%varenv,$record_pos,"calc_price");
my ($pricing,$counting) = $pri->counting_rental(\%varenv,$record_pos,"calc_price");
$update_pos->{int03} = "$pricing->{computed_hours}" if(looks_like_number($pricing->{computed_hours}));
$update_pos->{int38} = "$counting->{int38}" if(looks_like_number($counting->{int38}));
$update_pos->{int39} = "$counting->{int39}" if(looks_like_number($counting->{int39}));
$update_pos->{int40} = "$counting->{int40}" if(looks_like_number($counting->{int40}));
$update_pos->{int41} = "$counting->{int41}" if(looks_like_number($counting->{int41}));
$rows = $dbt->update_record($dbh,$update_pos,$record_pos);
if($rows > 0){
@ -1254,9 +1261,13 @@ sub booking_update(){
#return after booking_update
#my $pricing = $pri->sharee_pricing($record_pos,"calc_price");
#new sharee_pricing
my $pricing = $pri->counting_rental(\%varenv,$record_pos,"calc_price");
my ($pricing,$counting) = $pri->counting_rental(\%varenv,$record_pos,"calc_price");
$update_pos->{int03} = "$pricing->{computed_hours}" if(looks_like_number($pricing->{computed_hours}));
$update_pos->{int38} = "$counting->{int38}" if(looks_like_number($counting->{int38}));
$update_pos->{int39} = "$counting->{int39}" if(looks_like_number($counting->{int39}));
$update_pos->{int40} = "$counting->{int40}" if(looks_like_number($counting->{int40}));
$update_pos->{int41} = "$counting->{int41}" if(looks_like_number($counting->{int41}));
$rows = $dbt->update_record($dbh,$update_pos,$record_pos);
$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";
@ -1665,8 +1676,8 @@ sub rentals(){
#$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});
(my $return_counting->{$id}, my $counting) = $pri->counting_rental(\%varenv,$record->{$id},"readonly");
my $return_feed->{$id} = $pri->fetch_rentalfeed(\%varenv,$record->{$id},$return_counting->{$id});
$return->{$id} = { %{ $return_counting->{$id} }, %{ $return_feed->{$id} } };
my $bike_id = $return->{$id}->{bike};
@ -1794,24 +1805,24 @@ sub bikes_available(){
$return->{$id}->{tariff_description2}->{operator_agb} = "Mit der Mietrad Anmietung wird folgender Betreiber <a href='$varenv->{wwwhost}/site/agb.html' target='_blank'>AGB</a> zugestimmt (als Demo sharee AGB)." if($auth->{c_id} && ($auth->{c_id} == 1842 || $auth->{c_id} == 5781 || $auth->{c_id} == 22262));
my $i = 0;
foreach my $td (keys (%$td_template)){
foreach my $td (sort keys (%$td_template)){
my $time_unit = "";
$tariff_content->{$tid}->{$td} =~ s/\./,/ if($td =~ /int\d+/);
if($td eq "int02" && $tariff_content->{$tid}->{int02} && $tariff_content->{$tid}->{int02} > 0){
$i++;
$time_unit = $dbt->time_format($tariff_content->{$tid}->{time01});
$return->{$id}->{tariff_description2}->{$i} = ["$td_template->{$td}","$tariff_content->{$tid}->{$td} € / $time_unit"];
}elsif($td eq "int15" && $tariff_content->{$tid}->{int15} && $tariff_content->{$tid}->{int15} > 0){
$i++;
$return->{$id}->{tariff_description2}->{$i} = ["$td_template->{$td}", "$tariff_content->{$tid}->{$td} € / Std"];
}elsif($td eq "int17" && $tariff_content->{$tid}->{int17} && $tariff_content->{$tid}->{int17} > 0){
$i++;
$return->{$id}->{tariff_description2}->{$i} = ["$td_template->{$td}","$tariff_content->{$tid}->{$td} € / Tag"];
}elsif($td eq "time02" && $tariff_content->{$tid}->{time02}){
$i++;
$time_unit = $dbt->time_format($tariff_content->{$tid}->{time02});
$return->{$id}->{tariff_description2}->{$i} = ["$td_template->{$td}","$time_unit / Tag"];
}
if($td_template->{$td}->{int35} && $tariff_content->{$tid}->{int35} && $tariff_content->{$tid}->{int35} > 0){
$tariff_content->{$tid}->{int35} =~ s/\./,/;
$time_unit = $dbt->time_format($tariff_content->{$tid}->{time01});
$return->{$id}->{tariff_description2}->{$td} = ["$td_template->{$td}->{int35}","$tariff_content->{$tid}->{int35} € / $time_unit"];
}elsif($td_template->{$td}->{int36} && $tariff_content->{$tid}->{int36} && $tariff_content->{$tid}->{int36} > 0){
$tariff_content->{$tid}->{int36} =~ s/\./,/;
$time_unit = $dbt->time_format($tariff_content->{$tid}->{time01});
$return->{$id}->{tariff_description2}->{$td} = ["$td_template->{$td}->{int36}", "$tariff_content->{$tid}->{int36} € / $time_unit"];
}elsif($td_template->{$td}->{int17} && $tariff_content->{$tid}->{int17} && $tariff_content->{$tid}->{int17} > 0){
$tariff_content->{$tid}->{int17} =~ s/\./,/;
$return->{$id}->{tariff_description2}->{$td} = ["$td_template->{$td}->{int17}","$tariff_content->{$tid}->{int17} € / Tag"];
}elsif($td_template->{$td}->{time02} && $tariff_content->{$tid}->{time02} =~ /[1-9]/){
$time_unit = $dbt->time_format($tariff_content->{$tid}->{time02});
$return->{$id}->{tariff_description2}->{$td} = ["$td_template->{$td}->{time02}","$time_unit / Tag"];
}
}#end new tariff_description2
}

View file

@ -132,14 +132,24 @@ sub handler {
$ctt = $dbt->fetch_tablerecord($dbh,$fetch_ctt) if($txid);
$ctadr->{c_id} = $ctt->{int10} if($ctt->{int10});
my $fetch_ctadr = {
table => "contentadr",
fetch => "one",
c_id => $ctadr->{c_id},
};
$ctadr = $dbt->fetch_tablerecord($dbh,$fetch_ctadr) if($ctadr->{c_id});
my $vde_on_fail = $ctadr->{int12} || 1;#keep last or set 1
if($ctt->{c_id} > 0){
#balance > 0 then payment fails
if($update_ctt->{int16} && $update_ctt->{int16} > 0){
$update_adr->{int12} = $vde_on_fail;
$update_ctt->{int14} = 1;
$update_ctt->{txt23} = "$now_dt $txaction\nSaldo > 0 Meldung, Rücklastschrift oder Mahnung?\n" . $ctt->{txt23} if($ctt->{txt23} !~ /0 Meldung,/);#only once;
$update_ctt->{txt23} = "$now_dt $txaction\nSaldo > 0 Meldung\n" . $ctt->{txt23} if($ctt->{txt23} !~ /0 Meldung,/);#only once;
}else{
$update_ctt->{int14} = "=::null";
$update_adr->{int12} = "null";
$update_ctt->{int14} = "null";
$update_ctt->{txt23} = "$now_dt $txaction\n" . $ctt->{txt23};
}
@ -147,7 +157,7 @@ sub handler {
print FILE Dumper($update_ctt) . "\n";
#set cardexpiredate
if($update_adr->{int24} && $update_adr->{int24} > 0 && $ctadr->{c_id} > 0){
if(($update_adr->{int24} && $update_adr->{int24} > 0 || $ctadr->{int12} ne $update_adr->{int12}) && $ctadr->{c_id} > 0){
$dbt->update_record($dbh,$update_adr,$ctadr);
}
}

View file

@ -204,23 +204,22 @@ sub sigo_available {
$response_out->{$bike}->{tariff_description2}->{operator_agb} = "Mit der Mietrad Anmietung wird folgender Betreiber <a href='$varenv->{wwwhost}/site/agb.html' target='_blank'>AGB</a> zugestimmt (als Demo sharee AGB)." if($auth->{c_id} && ($auth->{c_id} == 1842 || $auth->{c_id} == 5781 || $auth->{c_id} == 22262));
my $i = 0;
foreach my $td (keys (%$td_template)){
foreach my $td (sort keys (%$td_template)){
my $time_unit = "";
$tariff_content->{$tid}->{$td} =~ s/\./,/ if($td =~ /int\d+/);
if($td eq "int02" && $tariff_content->{$tid}->{int02} && $tariff_content->{$tid}->{int02} > 0){
$i++;
if($td_template->{$td}->{int35} && $tariff_content->{$tid}->{int35} && $tariff_content->{$tid}->{int35} > 0){
$tariff_content->{$tid}->{int35} =~ s/\./,/;
$time_unit = $dbt->time_format($tariff_content->{$tid}->{time01});
$response_out->{$bike}->{tariff_description2}->{$i} = ["$td_template->{$td}","$tariff_content->{$tid}->{$td} € / $time_unit"];
}elsif($td eq "int15" && $tariff_content->{$tid}->{int15} && $tariff_content->{$tid}->{int15} > 0){
$i++;
$response_out->{$bike}->{tariff_description2}->{$i} = ["$td_template->{$td}", "$tariff_content->{$tid}->{$td} € / Std"];
}elsif($td eq "int17" && $tariff_content->{$tid}->{int17} && $tariff_content->{$tid}->{int17} > 0){
$i++;
$response_out->{$bike}->{tariff_description2}->{$i} = ["$td_template->{$td}","$tariff_content->{$tid}->{$td} € / Tag"];
}elsif($td eq "time02" && $tariff_content->{$tid}->{time02}){
$i++;
$response_out->{$bike}->{tariff_description2}->{$td} = ["$td_template->{$td}->{int35}","$tariff_content->{$tid}->{int35} € / $time_unit"];
}elsif($td_template->{$td}->{int36} && $tariff_content->{$tid}->{int36} && $tariff_content->{$tid}->{int36} > 0){
$tariff_content->{$tid}->{int36} =~ s/\./,/;
$time_unit = $dbt->time_format($tariff_content->{$tid}->{time01});
$response_out->{$bike}->{tariff_description2}->{$td} = ["$td_template->{$td}->{int36}", "$tariff_content->{$tid}->{int36} € / $time_unit"];
}elsif($td_template->{$td}->{int17} && $tariff_content->{$tid}->{int17} && $tariff_content->{$tid}->{int17} > 0){
$tariff_content->{$tid}->{int17} =~ s/\./,/;
$response_out->{$bike}->{tariff_description2}->{$td} = ["$td_template->{$td}->{int17}","$tariff_content->{$tid}->{int17} € / Tag"];
}elsif($td_template->{$td}->{time02} && $tariff_content->{$tid}->{time02} =~ /[1-9]/){
$time_unit = $dbt->time_format($tariff_content->{$tid}->{time02});
$response_out->{$bike}->{tariff_description2}->{$i} = ["$td_template->{$td}","$time_unit / Tag"];
$response_out->{$bike}->{tariff_description2}->{$td} = ["$td_template->{$td}->{time02}","$time_unit / Tag"];
}
}#end new tariff_description2

View file

@ -528,6 +528,28 @@ sub select_worktime {
return $record;
}
#all position of contenttrans
sub collect_contentpos(){
my $self = shift;
my $dbh = shift || $dbh_intern;
my ($table,$c_id) = @_;
my $tb = "contenttrans";
my $tbpos = "contenttranspos";
my $where = "where ctt.c_id=pos.ct_id and ctt.c_id='$c_id'";
if($c_id){
my $sth = $dbh->prepare("SELECT pos.* FROM $tbpos pos, $tb ctt $where");
my $rc = $sth->execute();
my $cpos = $sth->fetchall_hashref("c_id");
my $rows = $sth->rows;
return ($cpos,$rows);
}else{
my $cpos = { c_id => 0 };
my $rows = 0;
return ($cpos,$rows);
}
}
#Collect table ...post
sub collect_post(){
my $self = shift;
@ -1220,12 +1242,14 @@ sub get_freetpl(){
sub tariff_description2_template {
my $self = shift;
my $tpl_order = {
int02 => "Mietgebühr",
int15 => "Mietgebühr ab 2. Tag",
#int16 => "Grundgebühr",
int17 => "Max Gebühr",
time01 => "Zeiteinheit",
time02 => "Gratis Mietzeit",
1 => {int35 => "Mietgebühr"},#unit_price1
2 => {int36 => "Mietgebühr ab 2. Tag"},#unit_price2
#3 => {int37 => "Grundgebühr"},#startup_price
4 => {int17 => "Max. Gebühr"},#max_fee/day
5 => {time01 => "Zeiteinheit"},#unit_time
6 => {time02 => "Gratis Mietzeit"},#free_time
7 => {xduration => "Aktuelle Mietzeit"},
8 => {xprice => "Aktuelle Mietkosten"},
};
return $tpl_order;
}
@ -1234,11 +1258,22 @@ sub time_format {
my $self = shift;
my $time = shift;
my $time_unit = "";
my $day = "";
if($time =~ /(\d+) day/){
$day = $1;
if($1 > 0 && $1 <= 1){
$day .= " Tag ";
}else{
$day .= " Tage ";
}
$time_unit .= $day;
$time =~ s/\d+ day //;
}
my ($std,$min,$sec) = split(/:/,$time);
$std =~ s/^0//;
$min =~ s/^0//;
$time_unit = "$std Std " if($std > 0);
$time_unit .= "$min Min" if($min > 0);
$time_unit .= "$std Std " if($std > 0);
$time_unit .= "$min Min " if($min > 0);
return $time_unit;
}
@ -1294,33 +1329,40 @@ sub insert_pos(){
my $from_main_id = $ct->{main_id} || 0;
my $station = $ct->{int04} || 0;
my $rabatt = 0;
my $unit_price1 = 0;
my $unit_price1 = $ct->{int02} || 0;
my $unit_price2 = 0;
my $start_price = 0;
my $daymax_price = 0;
my $startup_price = 0;
my $abo_price = 0;#not used
my $unit_time = "00:00";
my $free_time = "00:00";
my $tariff_nr = 0;
my $tariff_desc;
my $unit_time = "00:00";
my $fee_time = "00:00";
my $free_hours = 0;#old
my $sharing_type = 0;
my $menge = 0;
if(ref($ct_tariff) eq "HASH" && $ct_tariff->{barcode}){
$rabatt = $ctadr->{int07} || 0;
$unit_price1 = $ct_tariff->{int02} || 0;
$unit_price2 = $ct_tariff->{int15} || 0;
$startup_price = $ct_tariff->{int16} || 0;#not yet implemented (OLD Gratis Std/Rad --> migrate to time02)
$unit_price1 = $ct_tariff->{int35} || 0;
$unit_price2 = $ct_tariff->{int36} || 0;
$start_price = $ct_tariff->{int37} || 0;
$abo_price = $ct_tariff->{int15} || 0;#not used
$free_hours = $ct_tariff->{int16} || 0;#old
$daymax_price = $ct_tariff->{int17} || 0;
$tariff_nr = $ct_tariff->{barcode} || 0;
$tariff_desc = $ct_tariff->{ct_name};
$unit_time = $ct_tariff->{time01} || "00:00";
$fee_time = $ct_tariff->{time02} || "00:00";
$free_time = $ct_tariff->{time02} || "00:00";
$sharing_type = $ct_tariff->{int18} || 0;
}
my $sth;
#Verleihräder
if($ct->{template_id} && $ct->{template_id} == 205){#Leihrad_list
$sth = $dbh->prepare("INSERT INTO contenttranspos (ct_id,cc_id,ca_id,ct_name,barcode,txt01,txt08,txt02,txt09,itime,start_time,end_time,int02,int03,int06,int04,txt05,txt06,txt07,int10,int12,int13,owner,int07,txt04,int09,int15,int16,int17,int11,int18,int19,txt17,txt18,int20,int25,int34,txt22,txt10,time01,time02) VALUES ('$ctt_id','$ct->{c_id}','$ctadr->{c_id}','$ct_name','$ct->{barcode}','$ct->{txt01}','$user_name','$ct->{txt02}','$ctadr->{txt09}',now(),now(),'$endRental','$unit_price1','$menge','$station','$station','$ct->{txt06}','$ct->{txt06}','$ct->{txt07}','$status','$from_main_id','$deviceId','$owner','$rabatt','$tariff_desc','$tariff_nr','$unit_price2','$startup_price','$daymax_price','$ct->{int11}','$sharing_type','$bike_charge','$ct->{txt17}','$ct->{txt18}','$ct->{int20}','$trackon','$staff','$ct->{txt22}','$reserveid','$unit_time','$fee_time') RETURNING c_id");
$sth = $dbh->prepare("INSERT INTO contenttranspos (ct_id,cc_id,ca_id,ct_name,barcode,txt01,txt08,txt02,txt09,itime,start_time,end_time,int02,int03,int06,int04,txt05,txt06,txt07,int10,int12,int13,owner,int07,txt04,int09,int17,int15,int16,int11,int18,int19,txt17,txt18,int20,int25,int34,txt22,txt10,int35,int36,int37,time01,time02) VALUES ('$ctt_id','$ct->{c_id}','$ctadr->{c_id}','$ct_name','$ct->{barcode}','$ct->{txt01}','$user_name','$ct->{txt02}','$ctadr->{txt09}',now(),now(),'$endRental','$unit_price1','$menge','$station','$station','$ct->{txt06}','$ct->{txt06}','$ct->{txt07}','$status','$from_main_id','$deviceId','$owner','$rabatt','$tariff_desc','$tariff_nr','$daymax_price','$abo_price','$free_hours','$ct->{int11}','$sharing_type','$bike_charge','$ct->{txt17}','$ct->{txt18}','$ct->{int20}','$trackon','$staff','$ct->{txt22}','$reserveid','$unit_price1','$unit_price2','$start_price','$unit_time','$free_time') RETURNING c_id");
}else{
$sth = $dbh->prepare("INSERT INTO contenttranspos (ct_id,cc_id,ca_id,ct_name,barcode,txt08,txt09,itime,int02,int03,txt01,txt06,txt07,int10,int12,owner) VALUES ('$ctt_id','$ct->{c_id}','$ctadr->{c_id}','$ct_name','0','$user_name','$ctadr->{txt09}',now(),'$unit_price1','1','$ct->{txt01}','$ct->{txt06}','$ct->{txt07}','0','$from_main_id','$owner') RETURNING c_id");
}

View file

@ -96,11 +96,12 @@ sub counting_rental {
my $todo = shift;
my $today4db = strftime("%Y-%m-%d %H:%M:%S",localtime(time));
my $return = {};
my $counting = { c_id => $ctpos->{c_id} };
my $computed_end_time = $ctpos->{end_time} || $today4db;
$computed_end_time = $today4db if($ctpos->{int10} && $ctpos->{int10} == 3);
#main counting rental time and convert it to minute
my $dt0 = DateTime::Format::Pg->parse_datetime($ctpos->{start_time});
my $dt1 = DateTime::Format::Pg->parse_datetime($computed_end_time);
my $dur10 = $dt1->subtract_datetime($dt0);
@ -116,13 +117,13 @@ sub counting_rental {
my $total_price = 0;
my $ctpos_freed = { c_id => 0 };
#Tariff unit by time
#convert tariff unit by minute time
my $tariff_unitbyminute = 60;#defaults to Stundentarif
if($ctpos->{time01} && $ctpos->{time01} =~ /[1-9]/){
$tariff_unitbyminute = $self->clock_minutes($ctpos->{time01});
}
#fee if ex. 00:30 Min/Gratis
#substract free time from rental time ex. 00:30 Min/Gratis
if($ctpos->{time02} && $ctpos->{time02} =~ /[1-9]/){
$ctpos_freed = $self->only_first_free($ctpos);
if(!$ctpos_freed->{c_id}){
@ -140,89 +141,121 @@ sub counting_rental {
}
}
my $hours = "";#old
my $rental_units = 0;
my $price_by_allunits = 0;
my $rental_unit = 0;
my $price_by_allunit = 0;
my $max_daily_unit = 0;#how many rental_minute is one daily_unit
my $fee_daily_minute = 0;
my $max_fee_daily_minute = 0;
my $rental_day_price = 0;
my $restal_minute = 0;
my $rental_time_price = 0;
my $rental_units_rounded = 0;
my $rental_unit_rounded = 0;
my $used_max_fee = "off";
my $used_methode = "";
#readonly if bike available then take saved $total_price
if($ctpos->{int10} && $ctpos->{int10} == 1 && $todo eq "readonly"){
if($ctpos->{int03} && $ctpos->{int03} > 0 && $ctpos->{int02} && $ctpos->{int02} > 0){
$total_price = $ctpos->{int03} * $ctpos->{int02};
}
#if($ctpos->{int38} && $ctpos->{int38} > 0 && $ctpos->{int35} && $ctpos->{int35} > 0){
# $total_price = $ctpos->{int38} * $ctpos->{int35};
# $used_methode = "readonly $ctpos->{int38} pos.int38 * $ctpos->{int35} pos.int35";
#}
}
#on time unit
elsif($rental_minute && $rental_minute > 0 && $ctpos->{int02} && $ctpos->{int02} > 0){
$rental_units = $rental_minute / $tariff_unitbyminute;
$price_by_allunits = $rental_units * $ctpos->{int02};
#on time unit (int35 keeps unit_price1)
elsif($rental_minute && $rental_minute > 0 && $ctpos->{int35} && $ctpos->{int35} > 0){
$rental_unit = $rental_minute / $tariff_unitbyminute;
$price_by_allunit = $rental_unit * $ctpos->{int35};
#max fee per day (day = 1440 minutes)
if($ctpos->{int17} && $price_by_allunits >= $ctpos->{int17}){
$used_max_fee = "on";
$max_daily_unit = $ctpos->{int17} / $ctpos->{int02};
$fee_daily_minute = $max_daily_unit * $tariff_unitbyminute;
#max_fee/day (day = 1440 minutes)
#useless if time01 unit is set to 24:00
if($ctpos->{int17} && $ctpos->{int17} > 0 && $price_by_allunit >= $ctpos->{int17} && $tariff_unitbyminute < 1440){
$used_methode .= "max_fee/day";
$used_max_fee = "ON $ctpos->{int17}";
$max_daily_unit = $ctpos->{int17} / $ctpos->{int35};
$max_fee_daily_minute = $max_daily_unit * $tariff_unitbyminute;
my $days_dec = $rental_minute / 1440;
my ($days,$ddec) = split(/\./, $days_dec) if($days_dec =~ /\.\d/);
$rental_day_price = $days * $ctpos->{int17} if($days > 0);
if($days > 0){
$rental_day_price = $days * $ctpos->{int17};
$counting->{int39} = $days;#by day
$used_methode .= " | rental_day_price: $days days * $ctpos->{int17} pos.int17";
}
$restal_minute = $rental_minute - $days * 1440;
if($restal_minute >= $fee_daily_minute){
if($restal_minute >= $max_fee_daily_minute){
$rental_day_price += $ctpos->{int17};
$counting->{int39} += 1;#by day
$used_methode .= " | += $ctpos->{int17} pos.int17";
}else{
$rental_units = $rental_minute / $tariff_unitbyminute;
$rental_units_rounded = $rental_units;
if($rental_units =~ /(\d+)\.(\d+)/){
$rental_units_rounded = $1 + 1;
$rental_unit = $restal_minute / $tariff_unitbyminute;
#
$rental_unit = sprintf('%.2f', $rental_unit);
$rental_unit_rounded = $rental_unit;
if($rental_unit =~ /(\d+)\.(\d+)$/){
$rental_unit_rounded = $1 + 1 if($2 != 0);
}
$rental_time_price = $rental_units_rounded * $ctpos->{int02};
$rental_time_price = $rental_unit_rounded * $ctpos->{int35};
$counting->{int38} = $rental_unit_rounded;#by time
$used_methode .= " | $rental_unit_rounded rental_unit_rounded * $ctpos->{int35} int35";
}
#else if price by all unit < max_fee/day
}else{
$rental_units = $rental_minute / $tariff_unitbyminute;
$rental_units_rounded = $rental_units;
if($rental_units =~ /(\d+)\.(\d+)/){
$rental_units_rounded = $1 + 1;
$rental_unit = $rental_minute / $tariff_unitbyminute;
$rental_unit = sprintf('%.2f', $rental_unit);
$rental_unit_rounded = $rental_unit;
if($rental_unit =~ /(\d+)\.(\d+)/){
$rental_unit_rounded = $1 + 1 if($2 != 0);
}
if(!$ctpos->{int36} && $ctpos->{int17} && $ctpos->{int17} > 0){
$counting->{int38} = $rental_unit_rounded;#count by time
$rental_time_price = $rental_unit_rounded * $ctpos->{int35};
$used_methode .= " | $rental_unit_rounded rental_unit_rounded * $ctpos->{int35} int35";
}elsif($ctpos->{int36}){#if second unit_price2 defined
$counting->{int40} = 1;#by day
$rental_time_price = 1 * $ctpos->{int35};
$used_methode .= " | 1 rental_unit_rounded * $ctpos->{int35} int35";
if($rental_unit_rounded >= 2 && $ctpos->{int36} && $ctpos->{int36} > 0){
my $rental_unit_rounded2 = $rental_unit_rounded - 1;#by day
$counting->{int41} = $rental_unit_rounded2;
$rental_time_price += $rental_unit_rounded2 * $ctpos->{int36};
$used_methode .= " | $rental_unit_rounded2 rental_unit_rounded * $ctpos->{int36} int36";
}
}
$rental_time_price = $rental_units_rounded * $ctpos->{int02};
}
}
my $computed_hours = $rental_minute / 60;
$total_price = $rental_day_price + $rental_time_price;
$used_methode .= " --> $total_price total_price = $rental_day_price rental_day_price + $rental_time_price rental_time_price";
$total_price = sprintf('%.2f', $total_price);
$return->{start_time} = "$ctpos->{start_time}";
$return->{end_time} = "$computed_end_time";
#$return->{real_clock} = "$real_clock";
#$return->{computed_clock} = "$computed_clock";
$return->{computed_hours} = "$computed_hours";
$return->{unit_price} = "$ctpos->{int02}";
$return->{unit_price} = "$ctpos->{int35}";
$return->{real_clock} = "$real_clock";
$return->{total_price} = "$total_price";
$return->{rentalog}->{real_clock} = "$real_clock";
$return->{rentalog}->{computed_clock} = "$computed_clock";
$return->{rentalog}->{computed_hours} = "$computed_hours";
$return->{rentalog}->{rental_minute} = "$rental_minute";
$return->{rentalog}->{fee_daily_minute} = "$fee_daily_minute";
$return->{rentalog}->{max_fee_daily_minute} = "$max_fee_daily_minute";
$return->{rentalog}->{tariff_unitbyminute} = "$tariff_unitbyminute";
$return->{rentalog}->{restal_minute} = "$restal_minute";
$return->{rentalog}->{rental_units_rounded} = "$rental_units_rounded";
$return->{rentalog}->{rental_units} = "$rental_units";
$return->{rentalog}->{price_by_allunits} = "$price_by_allunits";
$return->{rentalog}->{rental_unit_rounded} = "$rental_unit_rounded";
$return->{rentalog}->{rental_unit} = "$rental_unit";
$return->{rentalog}->{price_by_allunit} = "$price_by_allunit";
$return->{rentalog}->{rental_day_price} = "$rental_day_price";
$return->{rentalog}->{total_price} = "$total_price";
$return->{rentalog}->{rental_time_price} = "$rental_time_price";
$return->{rentalog}->{ctpos_freed} = "$ctpos_freed->{c_id}";
$return->{rentalog}->{used_max_fee} = "$used_max_fee";
$return->{rentalog}->{used_methode} = "$used_methode";
$return->{rentalog}->{counting} = $counting;
$bw->log("Pricing counting_rental return:",$return,"");
return $return;
return ($return,$counting);
}#end counting_rental
#all other values returned by user_bikes_occupied
@ -230,6 +263,7 @@ sub fetch_rentalfeed {
my $self = shift;
my $varenv = shift;
my $ctpos = shift;
my $returned_counting = shift || {};
my $td_template = $dbt->tariff_description2_template();
my $bike_group = "$dbt->{operator}->{$varenv->{dbname}}->{oprefix}$ctpos->{int12}" || "";
@ -250,8 +284,9 @@ sub fetch_rentalfeed {
($return->{gps}->{latitude},$return->{gps}->{longitude}) = split(/,/,$ctpos->{txt06});
#if($ctpos->{txt10} =~ /requested|occupied/)
if($ctpos->{int10} == 2 || $ctpos->{int10} == 3){
#if($ctpos->{int10} == 2 || $ctpos->{int10} == 3){
#2022-04-26 disabled condition
if(1==1){
#deprecated
$return->{tariff_description}->{name} = "$ctpos->{txt04}";
$return->{tariff_description}->{number} = "$ctpos->{int09}";
@ -259,33 +294,33 @@ sub fetch_rentalfeed {
$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 <a href='$varenv->{wwwhost}/site/agb.html' target='_blank'>AGB</a> zugestimmt (als Demo sharee AGB)." if($ctpos->{ca_id} == 1842 || $ctpos->{ca_id} == 5781);
#new tariff_description2
$return->{tariff_description2}->{name} = "$ctpos->{txt04}";
$return->{tariff_description2}->{number} = "$ctpos->{int09}";
$return->{tariff_description2}->{track_info} = "Ich stimme der Speicherung (Tracking) meiner Fahrstrecke zwecks wissenschaftlicher Auswertung und Berechnung der CO2-Einsparung zu!" if($ctpos->{int25});
$return->{tariff_description2}->{operator_agb} = "Mit der Mietrad Anmietung wird folgender Betreiber <a href='$varenv->{wwwhost}/site/agb.html' target='_blank'>AGB</a> zugestimmt (als Demo sharee AGB)." if($ctpos->{ca_id} == 1842 || $ctpos->{ca_id} == 5781);
my $i = 0;
foreach my $td (keys (%$td_template)){
foreach my $td (sort keys (%$td_template)){
my $time_unit = "";
$ctpos->{$td} =~ s/\./,/ if($td =~ /int\d+/);
if($td eq "int02" && $ctpos->{int02} && $ctpos->{int02} > 0){
$i++;
if($td_template->{$td}->{int35} && $ctpos->{int35} && $ctpos->{int35} > 0){
$ctpos->{int35} =~ s/\./,/;
$time_unit = $dbt->time_format($ctpos->{time01});
$return->{tariff_description2}->{$i} = ["$td_template->{$td}","$ctpos->{$td} € / $time_unit"];
}elsif($td eq "int15" && $ctpos->{int15} && $ctpos->{int15} > 0){
$i++;
$return->{tariff_description2}->{$i} = ["$td_template->{$td}", "$ctpos->{$td} € / Std"];
}elsif($td eq "int17" && $ctpos->{int17} && $ctpos->{int17} > 0){
$i++;
$return->{tariff_description2}->{$i} = ["$td_template->{$td}","$ctpos->{$td} € / Tag"];
}elsif($td eq "time02" && $ctpos->{time02}){
$i++;
$return->{tariff_description2}->{$td} = ["$td_template->{$td}->{int35}","$ctpos->{int35} € / $time_unit"];
}elsif($td_template->{$td}->{int36} && $ctpos->{int36} && $ctpos->{int36} > 0){
$ctpos->{int36} =~ s/\./,/;
$time_unit = $dbt->time_format($ctpos->{time01});
$return->{tariff_description2}->{$td} = ["$td_template->{$td}->{int36}", "$ctpos->{int36} € / $time_unit"];
}elsif($td_template->{$td}->{int17} && $ctpos->{int17} && $ctpos->{int17} > 0){
$ctpos->{int17} =~ s/\./,/;
$return->{tariff_description2}->{$td} = ["$td_template->{$td}->{int17}","$ctpos->{int17} € / Tag"];
}elsif($td_template->{$td}->{time02} && $ctpos->{time02} =~ /[1-9]/){
$time_unit = $dbt->time_format($ctpos->{time02});
$return->{tariff_description2}->{$i} = ["$td_template->{$td}","$time_unit / Tag"];
$return->{tariff_description2}->{$td} = ["$td_template->{$td}->{time02}","$time_unit / Tag"];
}elsif($td_template->{$td}->{xduration} && $returned_counting->{real_clock} =~ /[1-9]/){
$time_unit = $dbt->time_format($returned_counting->{real_clock});
$return->{tariff_description2}->{$td} = ["$td_template->{$td}->{xduration}","$time_unit"];
}elsif($td_template->{$td}->{xprice} && $returned_counting->{total_price} && $returned_counting->{total_price} > 0){
$returned_counting->{total_price} =~ s/\./,/;
$return->{tariff_description2}->{$td} = ["$td_template->{$td}->{xprice}","$returned_counting->{total_price} €"];
}
}#end new tariff_description2
@ -472,19 +507,19 @@ sub sprit2calc {
my $einzel = $ctpos->{int02};
my $menge = $ctpos->{int03};
my $rabatt_val = $ctpos->{int07} || 0;
my $gesamt = 0;
my $total = 0;
if($rabatt_val != 0 && $einzel && $menge){
my $rabatt_eur = $rabatt_val;
#if int08 != 1 alias €
$rabatt_eur = $einzel * $menge * $rabatt_val/100 if($ctpos->{int08} != 1);
$gesamt = $einzel * $menge - $rabatt_eur;
$total = $einzel * $menge - $rabatt_eur;
}elsif($einzel && $menge){
$gesamt = $einzel * $menge;
$total = $einzel * $menge;
}
my $sprit_price = 0;
$sprit_price = $ctpos->{int26} * 0.3 if($ctpos->{int26} != 0);
$sprit_price -= $gesamt;
$sprit_price -= $total;
$sprit_price = sprintf('%.2f',$sprit_price);
$sprit_price =~ s/\./,/;
@ -497,7 +532,7 @@ sub price2calc {
my $self = shift;
my $ctpos = shift;
my $gesamt = 0;
my $total = 0;
my $rabatt = "";
my $einzel = $ctpos->{int02};
my $menge = $ctpos->{int03};
@ -506,9 +541,9 @@ sub price2calc {
my $rabatt_eur = $rabatt_val;
#if int08 != 1 alias €
$rabatt_eur = $einzel * $menge * $rabatt_val/100 if($ctpos->{int08} != 1);
$gesamt = $einzel * $menge - $rabatt_eur;
$total = $einzel * $menge - $rabatt_eur;
}elsif($einzel && $menge){
$gesamt = $einzel * $menge;
$total = $einzel * $menge;
}
if($ctpos->{int07} && $ctpos->{int07} > 0 && $menge > 0){
@ -521,6 +556,6 @@ sub price2calc {
}
}
return ($gesamt,$rabatt);
return ($total,$rabatt);
}
1;

View file

@ -45,7 +45,8 @@ sub tpl(){
#get Firma
my $ctf = $db->get_content1("contentuser",$dbt->{shareedms_conf}->{parent_id});
my $rel4tpl = $db->get_rel4tpl("",$lang,$users_dms->{c_id4trans},$node_meta->{tpl_id});
#my $rel4tpl = $db->get_rel4tpl("",$lang,$users_dms->{c_id4trans},$node_meta->{tpl_id});
my $rel4tpl = $db->get_rel4tpl("",$lang,$users_dms->{c_id4trans},$users_dms->{tpl_id4trans});
my @tpl_order = split /,/,$rel4tpl->{tpl_order};
my $ctx = { c_id => 0 };

View file

@ -69,7 +69,7 @@ sub tpl(){
my $vibuchen_mtime = "";
$vibuchen_mtime = "Payone post " . $lb->time4de($ctt->{pay_time},1) . " . " if($ctt->{pay_time});
my @tpl_order = ("txt01=Beschreibung","ct_name=Nummer","date_time=Mietzeit","int03=Menge","int02=Preis","int07=Rabatt","int04=Gesamt");
my @tpl_order = ("txt01=Beschreibung","ct_name=Nummer","date_time=timerange","int03=Menge","int02=Tarif/Preis","int07=Rabatt","int04=Gesamt");
my $tplf = $db->get_tpl("201");#Firma tpl
my @tplf_order = split /,/,$tplf->{tpl_order};
@ -84,15 +84,20 @@ sub tpl(){
my $max_sum = 1000;
my $cttpos = { c_id => 0 };
my $rows = 0;
($cttpos,$rows) = $db->collect_contentpos("contenttrans",$rel4tpl->{content_id});
($cttpos,$rows) = $dbt->collect_contentpos($dbh,"contenttrans",$rel4tpl->{content_id});
foreach my $id (keys(%$cttpos)){
if(ref($cttpos->{$id}) eq "HASH"){
if($cttpos->{$id}->{int26}){
@tpl_order = ("txt01=Beschreibung","ct_name=Nummer","date_time=Mietzeit","int26=Einsparung","int03=Menge","int02=Preis","int07=Rabatt","int04=Gesamt");
@tpl_order = ("txt01=Beschreibung","ct_name=Nummer","date_time=timerange","int26=Einsparung","int03=Menge","int02=Tarif/Preis","int07=Rabatt","int04=Gesamt");
}
#enhanced tariff
#if($cttpos->{$id}->{int35}){
# @tpl_order = ("txt01=Beschreibung","ct_name=Nummer","date_time=timerange","int26=Einsparung","int35=Mietzeit Menge","int03=Artikel Menge","int02=Preis","int07=Rabatt","int04=Gesamt");
#}
}else{
$lb->failure3("Der selekt einer Verkaufsposition ist fehlgeschlagen, errocode ($rel4tpl->{content_id} | $users_dms->{c_id4trans} | $node_meta->{tpl_id}). Bitte admin kontaktieren");
exit;
}
}
@ -146,7 +151,7 @@ EOF
$k++ if($val);
if($key eq "ct_name"){
print $q->th($q->textfield(-class=>'etxt',-style=>'height:19px;width:140px;font-size:1.3em;text-align:right;',-id=>"json_select",-name=>"json_select",-value=>"", -override=>'1',-size=>"25",-maxlength=>50, -placeholder=>'Nummer',-autofocus=>1),"");
}elsif($key =~ /int|txt/){
}elsif($key =~ /int|txt|time\d+/){
print $q->th("$val");
}
}
@ -168,6 +173,15 @@ EOF
#foreach my $id (sort { $cttpos->{$b}->{$scol} <=> $cttpos->{$a}->{$scol} } keys(%$cttpos)){
foreach my $id (sort { $cttpos->{$b}->{$scol} cmp $cttpos->{$a}->{$scol} } keys(%$cttpos)){
my $pricing = {};
my $counting = {};
my $rental_feed = {};
if($cttpos->{$id}->{int35} && $cttpos->{$id}->{start_time} && $cttpos->{$id}->{end_time}){
($pricing,$counting) = $pri->counting_rental(\%varenv,$cttpos->{$id},"calc_price");
$rental_feed = $pri->fetch_rentalfeed(\%varenv,$cttpos->{$id},$counting);
}
my $set_style="";
my $occupied_style = "";
my $time_style = "";
@ -227,10 +241,12 @@ EOF
my $txtstyle = "text-align:left;min-width:150px;";
my $isize = "30";
$isize = $inputsize if($inputsize);
if($key =~ /int|txt03/){ #für zahlen etwas kleiner
if($key =~ /int\d+/){
$txtstyle = "text-align:right;min-width:50px;";
$isize = "5";
}
#edit position
if(($c_idpos == $cttpos->{$id}->{c_id}) && ($R::trans2edit && $R::trans2edit =~ /transpos/)){
if($key =~ /ct_name/){
print $q->td({-class=>'element',-style=>"$set_style text-align:right;"}, $q->textfield(-class=>'etxt',-style=>"text-align:right;min-width:120px;",-name=>"ct_name",-default=>"$ct_pos", -override=>'1',-size=>10,-readonly=>'1')),"\n";
@ -248,16 +264,36 @@ EOF
print $q->td({-class=>'tdint'},"$co2saving");
}elsif($key =~ /int03/){
#TODO, autocalc Menge Preis by time-range
#Menge
print $q->td({-colspan=>'1',-class=>'element',-style=>"$txtstyle $set_style"},$q->textfield(-class=>'etxt',-style=>"$txtstyle",-name=>"col_$key",-default=>"$cttpos->{$id}->{$key}", -override=>'1',-size=>"$isize",-maxlength=>10, -autofocus=>1)),"\n";
if($cttpos->{$id}->{int35} && $cttpos->{$id}->{start_time} && $cttpos->{$id}->{end_time}){
print $q->td({-class=>'tdint'},"$pricing->{real_clock}"),"\n";
}else{
print $q->td({-colspan=>'1',-class=>'element',-style=>"$txtstyle $set_style"},$q->textfield(-class=>'etxt',-style=>"$txtstyle",-name=>"col_$key",-default=>"$cttpos->{$id}->{$key}", -override=>'1',-size=>"$isize",-maxlength=>10, -autofocus=>1)),"\n";
}
}elsif($key =~ /int02/){
#Einzelpreis
print $q->td({-class=>'element',-style=>"$txtstyle $set_style"},$q->textfield(-class=>'etxt',-style=>"$txtstyle",-name=>"col_$key",-default=>"$cttpos->{$id}->{$key}", -override=>'1',-size=>"$isize",-maxlength=>100),"\n");
if($cttpos->{$id}->{int35} && $cttpos->{$id}->{start_time} && $cttpos->{$id}->{end_time}){
print "<td class='tdint'>\n";
print "Tarif: $rental_feed->{tariff_description2}->{number} $rental_feed->{tariff_description2}->{name}<br />\n";
foreach my $fid (sort keys(%{ $rental_feed->{tariff_description2} })){
if(ref($rental_feed->{tariff_description2}->{$fid}) eq "ARRAY"){
print "$rental_feed->{tariff_description2}->{$fid}[0]: $rental_feed->{tariff_description2}->{$fid}[1]<br />\n";
}
}
print "</td>\n";
}else{
print $q->td({-class=>'element',-style=>"$txtstyle $set_style"},$q->textfield(-class=>'etxt',-style=>"$txtstyle",-name=>"col_$key",-default=>"$cttpos->{$id}->{$key}", -override=>'1',-size=>"$isize",-maxlength=>100),"\n");
}
}elsif($key =~ /int07/){
print $q->td({-class=>'element',-style=>"$txtstyle $set_style",-nowrap=>'1'},$q->textfield(-class=>'etxt',-style=>"$txtstyle",-name=>"col_$key",-default=>"$cttpos->{$id}->{$key}", -override=>'1',-size=>"$isize",-maxlength=>100),$but->selector("int08","40px","$cttpos->{$id}->{int08}",("0.00:%","1.00:€"))),"\n";
if(!$cttpos->{$id}->{int35}){
print $q->td({-class=>'element',-style=>"$txtstyle $set_style",-nowrap=>'1'},$q->textfield(-class=>'etxt',-style=>"$txtstyle",-name=>"col_$key",-default=>"$cttpos->{$id}->{$key}", -override=>'1',-size=>"$isize",-maxlength=>100),$but->selector("int08","40px","$cttpos->{$id}->{int08}",("0.00:%","1.00:€"))),"\n";
}else{
print $q->td({-class=>'tdint'},""),"\n";
}
}elsif($key =~ /int04/){
print $q->td({-class=>'element',-style=>'text-align:right;padding:0.1em 0.5em;',-nowrap=>"1"},"$gesamt €");
if($pricing->{total_price}){
print $q->td({-class=>'tdint',-nowrap=>1},"$pricing->{total_price} €"),"\n";
}else{
print $q->td({-class=>'tdint',-nowrap=>"1"},"$gesamt €");
}
}elsif($key =~ /txt01/){
if($cttpos->{$id}->{int09} && $cttpos->{$id}->{$key} !~ /Manuell/){
$cttpos->{$id}->{$key} .= "\nManuell bearbeitet\n";
@ -270,21 +306,21 @@ EOF
print $q->textarea(-class=>'autos',-style=>"border: 1px solid #ededed;background-color: #ededed;",-name=>"col_$key",-default=>"$cttpos->{$id}->{$key}", -override=>'1',-rows=>"1",-cols=>65),"<br />\n";
if($cttpos->{$id}->{int09}){#2020-12-07 Verleihräder werden anhand der TarifNr als solches erkannt
print $q->span({-style=>"$txtstyle $set_style"},
"Tarif Nr.: ", $q->textfield(-class=>'etxt',-name=>"int09",-default=>"$cttpos->{$id}->{int09}",-size=>"5",-maxlength=>5),
"Tarif Text", $q->textfield(-class=>'etxt',-name=>"txt04",-default=>"$cttpos->{$id}->{txt04}",-size=>"30",-maxlength=>50)),"<br />\n";
#print $q->span({-style=>"$txtstyle $set_style"},
#"Tarif Nr.: ", $q->textfield(-class=>'etxt',-name=>"int09",-default=>"$cttpos->{$id}->{int09}",-size=>"5",-maxlength=>5),
#"Tarif Text", $q->textfield(-class=>'etxt',-name=>"txt04",-default=>"$cttpos->{$id}->{txt04}",-size=>"30",-maxlength=>50)),"<br />\n";
print $q->span({-style=>"$txtstyle $set_style"},
"Endstation: ", $q->textfield(-class=>'etxt',-name=>"int04",-default=>"$cttpos->{$id}->{int04}",-size=>"5",-maxlength=>40),
"GPS: ", $q->textfield(-class=>'etxt',-name=>"txt06",-default=>"$cttpos->{$id}->{txt06}",-size=>"35",-maxlength=>40)),"<br />\n";
print $q->span({-style=>"$txtstyle $set_style"},"Mietzeit: ",
$q->textfield(-id=>'datepicker1',-class=>'etxt',-name=>"start_date",-default=>"$s_dd.$s_mo.$s_yy",-size=>"10",-maxlength=>10),
$q->textfield(-class=>'etxt',-name=>"s_hh",-default=>"$s_hh",-size=>"2",-maxlength=>2),":",
$q->textfield(-class=>'etxt',-name=>"s_mi",-default=>"$s_mi",-size=>"2",-maxlength=>2)," ",
$q->textfield(-id=>'datepicker2',-class=>'etxt',-name=>"end_date",-default=>"$e_dd.$e_mo.$e_yy",-size=>"10",-maxlength=>10),
$q->textfield(-class=>'etxt',-name=>"e_hh",-default=>"$e_hh",-size=>"2",-maxlength=>2),":",
$q->textfield(-class=>'etxt',-name=>"e_mi",-default=>"$e_mi",-size=>"2",-maxlength=>2)),"\n";
$q->textfield(-id=>'datepicker1',-class=>'etxt',-name=>"start_date",-default=>"$s_dd.$s_mo.$s_yy",-size=>"8",-maxlength=>10),
$q->textfield(-class=>'etxt',-name=>"s_hh",-default=>"$s_hh",-size=>"1",-maxlength=>2),":",
$q->textfield(-class=>'etxt',-name=>"s_mi",-default=>"$s_mi",-size=>"1",-maxlength=>2)," ",
$q->textfield(-id=>'datepicker2',-class=>'etxt',-name=>"end_date",-default=>"$e_dd.$e_mo.$e_yy",-size=>"8",-maxlength=>10),
$q->textfield(-class=>'etxt',-name=>"e_hh",-default=>"$e_hh",-size=>"1",-maxlength=>2),":",
$q->textfield(-class=>'etxt',-name=>"e_mi",-default=>"$e_mi",-size=>"1",-maxlength=>2)),"\n";
}
print "</td>\n";
@ -295,7 +331,11 @@ EOF
}elsif($key =~ /int/){
print $q->td({-class=>'tdint',-nowrap=>"1"},"&nbsp;\n");
}
}else{
}
#end edit position
#
#start view position
else{
if($key =~ /ct_name/){
#print $q->td({-class=>'tdint',-style=>"min-width:60px;"},"$ct_pos");
my $stamm_style = "background-color:#98c13b;padding:2px;";
@ -318,22 +358,45 @@ EOF
}
print $q->td({-class=>'tdint'},"$co2saving");
}elsif($key =~ /int02/){
$cttpos->{$id}->{$key} =~ s/\./,/;
print $q->td({-class=>'tdint'},"$cttpos->{$id}->{$key}"),"\n";
}elsif($key =~ /int03/){
$cttpos->{$id}->{$key} =~ s/\./,/;
print $q->td({-colspan=>'1',-class=>'tdint'},"$cttpos->{$id}->{$key}"),"\n";
}
#int03 on parts, int35 on rental
elsif($key =~ /int03/){
if($cttpos->{$id}->{int35} && $cttpos->{$id}->{start_time} && $cttpos->{$id}->{end_time}){
print $q->td({-class=>'tdint'},"$pricing->{real_clock}"),"\n";
}else{
$cttpos->{$id}->{$key} =~ s/\./,/;
print $q->td({-class=>'tdint'},"$cttpos->{$id}->{$key}"),"\n";
}
}elsif($key =~ /int02/){
if($cttpos->{$id}->{int35} && $cttpos->{$id}->{start_time} && $cttpos->{$id}->{end_time}){
print "<td class='tdint'>\n";
print "Tarif: $rental_feed->{tariff_description2}->{number} $rental_feed->{tariff_description2}->{name}<br />\n";
foreach my $fid (sort keys(%{ $rental_feed->{tariff_description2} })){
if(ref($rental_feed->{tariff_description2}->{$fid}) eq "ARRAY"){
print "$rental_feed->{tariff_description2}->{$fid}[0]: $rental_feed->{tariff_description2}->{$fid}[1]<br />\n";
}
}
print "</td>\n";
}else{
$cttpos->{$id}->{$key} =~ s/\./,/;
print $q->td({-class=>'tdint'},"$cttpos->{$id}->{$key} €"),"\n";
}
}elsif($key =~ /int04/){
$gesamt =~ s/\./,/;
print $q->td({-class=>'tdint',-nowrap=>"1"},"$gesamt €"),"\n";
if($pricing->{total_price}){
print $q->td({-class=>'tdint'},"$pricing->{total_price} €"),"\n";
}else{
$gesamt =~ s/\./,/;
print $q->td({-class=>'tdint',-nowrap=>"1"},"$gesamt €"),"\n";
}
}elsif($key =~ /int07/){
my $proz="";
$proz = "%" if($cttpos->{$id}->{$key} && $cttpos->{$id}->{$key} != 0);
$proz = "€" if($cttpos->{$id}->{$key} && $cttpos->{$id}->{$key} != 0 && $cttpos->{$id}->{int08} && $cttpos->{$id}->{int08} == 1);
print $q->td({-class=>'tdint',-nowrap=>"1"},"$cttpos->{$id}->{$key} $proz"),"\n";
}elsif($key =~ /txt03/){
print $q->td({-class=>'tdint'},"$cttpos->{$id}->{$key}"),"\n";
if(!$cttpos->{$id}->{int35}){
my $proz="";
$proz = "%" if($cttpos->{$id}->{$key} && $cttpos->{$id}->{$key} != 0);
$proz = "€" if($cttpos->{$id}->{$key} && $cttpos->{$id}->{$key} != 0 && $cttpos->{$id}->{int08} && $cttpos->{$id}->{int08} == 1);
print $q->td({-class=>'tdint',-nowrap=>"1"},"$cttpos->{$id}->{$key} $proz"),"\n";
}else{
print $q->td({-class=>'tdint',-nowrap=>"1"},""),"\n";
}
}elsif($key =~ /txt01/){
$cttpos->{$id}->{$key} = $q->unescapeHTML("$cttpos->{$id}->{$key}");
$cttpos->{$id}->{$key} = $lb->newline($cttpos->{$id}->{$key},"","");
@ -365,17 +428,18 @@ EOF
my $bike="";
my $tariff = "";
$bike = "$cttpos->{$id}->{$key}" if($cttpos->{$id}->{$key});
$tariff = ", Tarif: $cttpos->{$id}->{int09} $cttpos->{$id}->{txt04}" if($cttpos->{$id}->{txt04});
print $q->span("$bike $tariff<br />"),"\n";
#$tariff = ", Tarif: $cttpos->{$id}->{int09} $cttpos->{$id}->{txt04}" if($cttpos->{$id}->{txt04});
#print $q->span("$bike $tariff<br />"),"\n";
print $q->span("$bike<br />"),"\n";
}
if($cttpos->{$id}->{int06} || $cttpos->{$id}->{int04}){
print $q->span("Start/End Station: $cttpos->{$id}->{int06} / $cttpos->{$id}->{int04}, GPS: $cttpos->{$id}->{txt06}"),"\n";
}
if($cttpos->{$id}->{start_time} && $cttpos->{$id}->{end_time}){
$cttpos->{$id}->{start_time} = $lb->time4de($cttpos->{$id}->{start_time},"1");
$cttpos->{$id}->{end_time} = $lb->time4de($cttpos->{$id}->{end_time},"1");
my $start_time = $lb->time4de($cttpos->{$id}->{start_time},"1");
my $end_time = $lb->time4de($cttpos->{$id}->{end_time},"1");
print "<br />\n";
print $q->span({-style=>"$time_style"}, "Mietzeit: $cttpos->{$id}->{start_time} $cttpos->{$id}->{end_time}"),"\n";
print $q->span({-style=>"$time_style"}, "Mietzeit: $start_time $end_time"),"\n";
}
print "</td>\n";
}elsif($key =~ /txt/){
@ -383,7 +447,8 @@ EOF
}elsif($key =~ /int/){
print $q->td({-class=>'tdint',-nowrap=>"1"},"&nbsp;\n");
}
}
}#end view position
}
}
}#foreach end

View file

@ -97,7 +97,6 @@ sub utctime {
#'deviceTime' => '2021-10-14T08:19:35.000+0000',
#'serverTime' => '2021-10-14T07:19:37.000+0000',
#TODO
$utc_epoch -= 2*60*60;# -2 std (Sommerzeit)
#$utc_epoch -= 1*60*60;# -1 std (Winterzeit)

View file

@ -93,7 +93,6 @@ sub utctime {
my $time = Time::Piece->strptime($date, "%Y-%m-%dT%H:%M:%S");
print FILE "localtime: " . $time->datetime . "\n";#localtime
my $utc_epoch = $time->epoch;
#TODO
$utc_epoch -= 2*60*60;# -2 std (Sommerzeit)
#$utc_epoch -= 1*60*60;# -1 std (Winterzeit)
$utc_epoch += $latency;

View file

@ -34,7 +34,8 @@ my %varenv = $cf->envonline();
my $operator_key = $q->param('api_test');
my $bike = $q->param('bike');
#my $bike = "FR4781";
#$bike = "FR4781";
#$bike = "FR1002";
my $lang = "de";
my $dyn_js = "
@ -116,11 +117,11 @@ my %varenv = $cf->envonline();
##
my $uri = "$dbt->{primary}->{sharee_primary}->{primaryApp}/APIjsonserver";
print $q->div({-style=>'margin:15px;'},$q->a({-href=>"/src/scripts/tests/index.pl"},"[ index ]")),"\n";
#print $q->div({-style=>'margin:15px;'},$q->a({-href=>"/src/scripts/tests/index.pl"},"[ index ]")),"\n";
print $q->div({-style=>'margin:15px;'},"sharee API tests", $q->b("operator_key: $operator_key | bike: $bike")),"\n";
print $q->div({-style=>'margin:15px;'},"&nbsp;"),"\n";
print $q->div({-style=>'margin:15px;'},"-------------- $uri --------------------"),"\n";
my $authorization = "$uri?request=authorization&user_id=ragu\@gnu-systems.de&user_pw=mabel321&merchant_id=oiF2kahH&hw_id=g89g8o7goguzuzug";
my $authorization = "$uri?request=authorization&user_id=ragu\@sharee.bike&user_pw=xxxxxx&merchant_id=oiF2kahH&hw_id=g89g8o7goguzuzug";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$authorization"},"[ authorization ]---> $authorization")),"\n";
my $authout = "$uri?request=authout&authcookie=$coo";