beta App api extension with bikes-occupied on bikes-available request. Rental freed-time without rental-count restriction on TR.

This commit is contained in:
ragu 2023-10-24 07:26:06 +02:00
parent 60f21a4f85
commit 44d47011af
5 changed files with 85 additions and 38 deletions

View file

@ -1641,7 +1641,10 @@ sub user_rentals_history(){
my $self = shift;
my $q = shift || "";
my $auth = shift;
my $daily = shift || 0;
my %varenv = $cf->envonline();
my $today = strftime("%Y-%m-%d",localtime(time));
my $record_all = {};
my $pref = {
@ -1652,7 +1655,9 @@ sub user_rentals_history(){
ca_id => "$auth->{c_id}",
};
if(looks_like_number($q->param('month')) && $q->param('month') > 0){
if($daily > 0){
$pref->{start_time} = ">=::$today";
}elsif(looks_like_number($q->param('month')) && $q->param('month') > 0){
my $month = $q->param('month');
$pref->{mtime} = ">=::(now() - interval '$month month')";
}else{
@ -1884,11 +1889,12 @@ sub bikes_available(){
my $td_template = $dbt->rental_description_template($varenv_prim);
#return list of occupied/requested bikes
my $rentals_record = {};
my $rentals_response = {};
$rentals_record = $self->user_bikes_occupied($dbh,$auth,"");
$rentals_response = $self->rentals($varenv_prim,$rentals_record,$auth,"");#returns JSON rental values
$rentals_response->{further_freedtime_available} = 1 if(!keys (%$rentals_response));
my $adjust_freedtime = 0;
my $further_freedtime_available = 1;
my ($cttpos,$operator_hash) = $self->user_rentals_history($q,$auth,1);
foreach my $id (sort { lc($cttpos->{$b}->{itime}) cmp lc($cttpos->{$a}->{itime}) } keys(%$cttpos)){
$further_freedtime_available = $pri->count_freedrental("rentals by bikes_available",$varenv,$auth->{c_id},$cttpos->{$id},$adjust_freedtime);
}
foreach my $id (sort { $record->{$a}->{barcode} <=> $record->{$b}->{barcode} } keys (%$record)){
$return->{$id}->{authed} = "$authed";
@ -1984,7 +1990,7 @@ sub bikes_available(){
$tariff_content->{$tid}->{int17} =~ s/\./,/ if($lang eq "de");
$return->{$id}->{rental_description}->{tarif_elements}->{$td} = ["$td_template->{$td}->{int17}","$tariff_content->{$tid}->{int17} € / 24 $varenv_prim->{cms}->{'unit-hour'}->{txt}"];
}elsif($td_template->{$td}->{time02} && $tariff_content->{$tid}->{time02} =~ /[1-9]/){
if($rentals_response->{further_freedtime_available} == 1 || !$auth->{c_id}){
if($further_freedtime_available == 1 || !$auth->{c_id}){
$time_unit = $dbt->time_format($varenv_prim,$tariff_content->{$tid}->{time02});
$time_unit .= " / $varenv_prim->{cms}->{'unit-day'}->{txt}" if($dbt->{operator}->{$varenv->{dbname}}->{project} ne "Konstanz");
$return->{$id}->{rental_description}->{tarif_elements}->{$td} = ["$td_template->{$td}->{time02}","$time_unit"];