mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-02-22 11:46:27 +01:00
clocktime minutes fix
This commit is contained in:
parent
89e28f308f
commit
50b695117a
4 changed files with 13 additions and 154 deletions
|
@ -488,8 +488,13 @@ sub save_service_desc {
|
|||
my $valxx = $q->escapeHTML("@val");
|
||||
$valxx =~ s/\s/=/g;
|
||||
print FILE $_ . ":" . $valxx . "<br>\n";
|
||||
|
||||
my $count = 0;
|
||||
++$count while $valxx =~ /=/g;
|
||||
return "failure::Abbruch. Die Wartungsnamen dienen als Schlüsselwerte und dürfen somit keine Leer- oder Sonderzeichen enthalten ($valxx). Das Speichern wurde abgebrochen!" if($count > 4);
|
||||
|
||||
#txt01:int01=Reifen-Bremse-Lampe=checkbox=10=2
|
||||
if($_ =~ /txt\d+/ && $valxx =~ /int\d+=\w+/){
|
||||
if($_ =~ /txt\d+/ && $valxx =~ /int\d+=[a-z-]+=checkbox=\d+=\d/i){
|
||||
$update_ctuser->{$_} = "$valxx";
|
||||
$tpl_order_desc .= ",$valxx";
|
||||
}
|
||||
|
|
|
@ -77,21 +77,11 @@ sub clock_minutes {
|
|||
my $hour = 0;
|
||||
my $min = 0;
|
||||
|
||||
if($clockfloat =~ /(\d+)\sday\s(\d+):(\d+)/){
|
||||
$day = $1;
|
||||
$hour = $2;
|
||||
$min = $3;
|
||||
}elsif($clockfloat =~ /(\d+):(\d+)/){
|
||||
$hour = $1;
|
||||
$min = $2;
|
||||
}
|
||||
|
||||
my $hours = 0;
|
||||
$hours = $hour if($hour && $hour > 0);
|
||||
$hours += 24 * $day if($day && $day > 0);
|
||||
|
||||
($hour,$min) = split(/:/, $clockfloat);
|
||||
($day,$hour) = split(/\sday\s/, $hour) if($hour =~ /\sday\s/);
|
||||
$hour += 24 * $day if($day && $day > 0);
|
||||
my $minutes = $min;
|
||||
$minutes = ($hours * 60) + $min if($hours && $hours > 0);
|
||||
$minutes = ($hour * 60) + $min if($hour && $hour > 0);
|
||||
|
||||
return $minutes;
|
||||
}
|
||||
|
@ -148,6 +138,7 @@ sub counting_rental {
|
|||
$computed_clock = "$durhh:$durmm";
|
||||
$computed_clock = "$durdd day $durhh:$durmm" if($durdd);
|
||||
$rental_minute = $self->clock_minutes($computed_clock);
|
||||
#print "$computed_clock|$rental_minute";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -365,143 +356,6 @@ sub fetch_rentalfeed {
|
|||
return $return;
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
#last
|
||||
sub sharee_pricing(){
|
||||
my $self = shift;
|
||||
my $ctpos = shift;
|
||||
my $todo = shift;
|
||||
my %varenv = $cf->envonline();
|
||||
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);
|
||||
|
||||
#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;
|
||||
|
||||
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 = "4.5";#TINK max 9,- € bike/day depends on 2,- €/hour
|
||||
#my $days_pricemax = 5; #KonRad max 15,- € bike/day depends on 3,- €/hour
|
||||
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->{real_hours} = "$real_hours";
|
||||
$return->{computed_hours} = "$hours";
|
||||
$return->{unit_price} = "$price";
|
||||
$return->{total_price} = "$total";
|
||||
$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->{start_time} = "$ctpos->{start_time}";
|
||||
$return->{end_time} = "$computed_end_time";
|
||||
$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 <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);
|
||||
|
||||
$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);
|
||||
}
|
||||
}
|
||||
$bw->log("hour computed:",$logging,"");
|
||||
return $return;
|
||||
}
|
||||
|
||||
#CO2 calculator
|
||||
#Bsp Berechnungen:
|
||||
# Pkw:
|
||||
|
|
|
@ -329,7 +329,7 @@ EOF
|
|||
|
||||
print $q->Tr(),"\n";
|
||||
print $q->td({-class=>'tdval4',-colspan=>"2"},$q->span({-style=>'font-weight:bold;'},"Internas und Bearbeitungstatus")),"\n";
|
||||
print $q->td({-class=>'tdval4',-colspan=>"2"},$q->span({-style=>'font-weight:bold;'},"PDF Formular Texte "),$q->span({-style=>'color:silver;font-weight:normal;'}," ( z.T. Definitionen aus Einstellung/Firma )")),"\n";
|
||||
print $q->td({-class=>'tdval4',-colspan=>"2"},$q->span({-style=>'font-weight:bold;'},"PDF Formular Texte "),$q->span({-style=>'color:silver;font-weight:normal;'}," ( für den Kunden sichtbar )")),"\n";
|
||||
if($varenv{order_state}){
|
||||
print $q->Tr(),"\n";
|
||||
my @_orderstate = split(/\|/,$varenv{order_state});
|
||||
|
|
|
@ -404,8 +404,8 @@ EOF
|
|||
}
|
||||
#$pos_details = Dumper($pricing->{rentalog});
|
||||
$pos_raw = $q->div({-class=>"popup",-onclick=>"toggle_box('$id')"},"$cttpos->{$id}->{c_id}", $q->span({-class=>"popuptext",-id=>"$id"},"$pos_details"));
|
||||
print "(raw $pos_raw)<br />\n";
|
||||
}
|
||||
print "(raw $pos_raw)<br />\n";
|
||||
}
|
||||
}
|
||||
if($cttpos->{$id}->{txt01} || $cttpos->{$id}->{int09}){
|
||||
|
|
Loading…
Add table
Reference in a new issue