diff --git a/copri4/main/src/Mod/APIfunc.pm b/copri4/main/src/Mod/APIfunc.pm index 7aeeffa..b931ed4 100755 --- a/copri4/main/src/Mod/APIfunc.pm +++ b/copri4/main/src/Mod/APIfunc.pm @@ -1794,6 +1794,7 @@ sub user_bikes_occupied { #called by user_bikes_occupied (bikes_occupied object) sub rentals(){ my $self = shift; + my $varenv_prim = shift; my $record = shift; my $auth = shift || ""; my $withkey = shift || 0; @@ -1810,7 +1811,7 @@ sub rentals(){ #$bw->log("rentals-rentalog",$pricing->{$id}->{rentalog},""); $pricing->{$id}->{rentalog} = "";#just for debuggiog, removed to reduce data in json - my $return_feed->{$id} = $pri->fetch_rentalfeed(\%varenv,$record->{$id},$pricing->{$id}); + my $return_feed->{$id} = $pri->fetch_rentalfeed($varenv_prim,\%varenv,$record->{$id},$pricing->{$id}); $return->{$id} = { %{ $pricing->{$id} }, %{ $return_feed->{$id} } }; my $bike_id = $return->{$id}->{bike}; @@ -1839,6 +1840,7 @@ sub rentals(){ sub bikes_available(){ my $self = shift; my $q = shift; + my $varenv_prim = shift; my $varenv = shift; my $auth = shift; my $authed = 0; @@ -1897,7 +1899,7 @@ sub bikes_available(){ $record = $dbt->fetch_record($dbh,$pref) if(ref($bike_node) eq "ARRAY" && @{$bike_node}[0]); my $op_return = {}; - my $td_template = $dbt->rental_description_template($varenv); + my $td_template = $dbt->rental_description_template($varenv_prim); foreach my $id (sort { $record->{$a}->{barcode} <=> $record->{$b}->{barcode} } keys (%$record)){ $return->{$id}->{authed} = "$authed"; diff --git a/copri4/main/src/Mod/APIjsonserver.pm b/copri4/main/src/Mod/APIjsonserver.pm index 5519ff6..5f3baaa 100755 --- a/copri4/main/src/Mod/APIjsonserver.pm +++ b/copri4/main/src/Mod/APIjsonserver.pm @@ -95,8 +95,10 @@ my $response = { } }; + my %varenv_prim = (); if($varenv{dbname} eq $dbt->{primary}->{sharee_primary}->{database}->{dbname}){ $varenv{cms} = $dbt->fetch_cms($dbh,{ lang => $q->escapeHTML($lang) }); + $varenv_prim{cms} = $varenv{cms}; if($lang eq "de"){ $response->{faq_app_fullurl} = $dbt->{project_conf}->{faq_app_fullurl_de}; }else{ @@ -105,6 +107,7 @@ my $response = { }else{ my $dbh_primary = $dbt->dbconnect_extern($dbt->{primary}->{sharee_primary}->{database}->{dbname}); $varenv{cms} = $dbt->fetch_cms($dbh_primary,{ lang => $q->escapeHTML($lang) }); + $varenv_prim{cms} = $varenv{cms}; } my $aowner = 0; @@ -329,7 +332,7 @@ elsif($q->param('request') eq "booking_request"){ #return list of occupied/requested bikes $record = $apif->user_bikes_occupied($dbh,$authraw,""); - $response->{bikes_occupied} = $apif->rentals($record,$authraw,"1");#returns JSON rental values + $response->{bikes_occupied} = $apif->rentals(\%varenv_prim,$record,$authraw,"1");#returns JSON rental values }#end still_requested }else{ @@ -413,7 +416,7 @@ elsif($q->param('request') eq "booking_cancel" || $q->param('request') eq "booki $response = {%$response, %$booking_values}; my $record = $apif->user_bikes_occupied($dbh,$authraw,"show_dialog"); - $response->{bikes_occupied} = $apif->rentals($record,$authraw,"1"); + $response->{bikes_occupied} = $apif->rentals(\%varenv_prim,$record,$authraw,"1"); #update on Ilockit }else{ @@ -422,12 +425,12 @@ elsif($q->param('request') eq "booking_cancel" || $q->param('request') eq "booki $response = {%$response, %$booking_values}; my $record = $apif->user_bikes_occupied($dbh,$authraw,""); - $response->{bikes_occupied} = $apif->rentals($record,$authraw,"1"); + $response->{bikes_occupied} = $apif->rentals(\%varenv_prim,$record,$authraw,"1"); } }#end occupied|available else{ my $record = $apif->user_bikes_occupied($dbh,$authraw,""); - $response->{bikes_occupied} = $apif->rentals($record,$authraw,"1"); + $response->{bikes_occupied} = $apif->rentals(\%varenv_prim,$record,$authraw,"1"); } }else{ @@ -466,9 +469,9 @@ elsif($q->param('request') eq "user_bikes_occupied"){ $response = { %$response, %$auth }; my $record = $apif->user_bikes_occupied($dbh,$authraw,"show_dialog"); if($R::withoutkey){ - $response->{bikes_occupied} = $apif->rentals($record,$authraw,""); + $response->{bikes_occupied} = $apif->rentals(\%varenv_prim,$record,$authraw,""); }else{ - $response->{bikes_occupied} = $apif->rentals($record,$authraw,"1"); + $response->{bikes_occupied} = $apif->rentals(\%varenv_prim,$record,$authraw,"1"); } }else{ $response->{response_state} = "Failure 1001: authcookie not defined"; @@ -503,10 +506,10 @@ elsif($q->param('request') eq "bikes_available"){ #$bw->log("Y bikes_available $varenv{dbname} by c_id $authraw->{c_id}, Tarif: $authraw->{txt30}",$authraw->{txt30},""); if($varenv{syshost} eq "shareeapp-sx"){ - ($response->{bikes},my $return2copri->{bikes}) = $si->sig_available($q,\%varenv,$authraw); + ($response->{bikes},my $return2copri->{bikes}) = $si->sig_available($q,\%varenv_prim,\%varenv,$authraw); $tk->sigbike_cupdate($return2copri->{bikes}); }else{ - $response->{bikes} = $apif->bikes_available($q,\%varenv,$authraw); + $response->{bikes} = $apif->bikes_available($q,\%varenv_prim,\%varenv,$authraw); } } if(ref($response->{bikes}) ne "HASH"){ @@ -757,7 +760,7 @@ elsif($q->param('request') eq "stations_available"){ #sig first save if($varenv{syshost} eq "shareeapp-sx"){ - ($response->{stations},my $return2copri->{stations}) = $si->sig_available($q,\%varenv,$authraw); + ($response->{stations},my $return2copri->{stations}) = $si->sig_available($q,\%varenv_prim,\%varenv,$authraw); $tk->sigstation_cupdate($return2copri->{stations}); }else{ my $cachme = $R::cachme || ""; diff --git a/copri4/main/src/Mod/APIsigclient.pm b/copri4/main/src/Mod/APIsigclient.pm index a586e1d..440fc88 100755 --- a/copri4/main/src/Mod/APIsigclient.pm +++ b/copri4/main/src/Mod/APIsigclient.pm @@ -59,6 +59,7 @@ sub new { sub sig_available { my $self = shift; my $q = shift; + my $varenv_prim = shift || {}; my $varenv = shift || {}; my $ctadr = shift || {}; @@ -84,7 +85,7 @@ sub sig_available { c_id => "1", }; my $hotline_data = $dbt->fetch_record($dbh,$hotline_hash); - my $td_template = $dbt->rental_description_template($varenv); + my $td_template = $dbt->rental_description_template($varenv_prim); open(FILE,">>$varenv->{logdir}/APIsigclient.log"); print FILE "\n0. *** $now_dt 'sig_available' ctadr: $ctadr->{c_id}\n"; diff --git a/copri4/main/src/Mod/Pricing.pm b/copri4/main/src/Mod/Pricing.pm index dc86126..58dcef2 100755 --- a/copri4/main/src/Mod/Pricing.pm +++ b/copri4/main/src/Mod/Pricing.pm @@ -314,12 +314,13 @@ sub counting_rental { #all other values returned by user_bikes_occupied sub fetch_rentalfeed { my $self = shift; + my $varenv_prim = shift; my $varenv = shift; my $ctpos = shift; my $returned_counting = shift || {}; my $lang = "de"; - my $td_template = $dbt->rental_description_template($varenv); + my $td_template = $dbt->rental_description_template($varenv_prim); my $bike_group = "$dbt->{operator}->{$varenv->{dbname}}->{oprefix}$ctpos->{int29}" || ""; my $return = {}; @@ -376,7 +377,7 @@ sub fetch_rentalfeed { $return->{aa_ride} = "0"; if($ctpos->{int42}){ - $return->{rental_description}->{rental_info}->{2} = ["AAFahrten","$varenv->{cms}->{'info-aa-ride'}->{txt}"]; + $return->{rental_description}->{rental_info}->{2} = ["AAFahrten","$varenv_prim->{cms}->{'info-aa-ride'}->{txt}"]; $return->{aa_ride} = "1"; } @@ -392,10 +393,10 @@ sub fetch_rentalfeed { $return->{rental_description}->{tarif_elements}->{$td} = ["$td_template->{$td}->{int36}", "$ctpos->{int36} € / $time_unit"]; }elsif($td_template->{$td}->{int17} && $ctpos->{int17} && $ctpos->{int17} > 0){ $ctpos->{int17} =~ s/\./,/ if($lang eq "de"); - $return->{rental_description}->{tarif_elements}->{$td} = ["$td_template->{$td}->{int17}","$ctpos->{int17} € / 24 $varenv->{cms}->{'unit-hour'}->{txt}"]; + $return->{rental_description}->{tarif_elements}->{$td} = ["$td_template->{$td}->{int17}","$ctpos->{int17} € / 24 $varenv_prim->{cms}->{'unit-hour'}->{txt}"]; }elsif($td_template->{$td}->{time02} && $ctpos->{time02} =~ /[1-9]/){ $time_unit = $dbt->time_format($varenv,$ctpos->{time02}); - $time_unit .= " / $varenv->{cms}->{'unit-day'}->{txt}" if($dbt->{operator}->{$varenv->{dbname}}->{project} ne "Konstanz"); + $time_unit .= " / $varenv_prim->{cms}->{'unit-day'}->{txt}" if($dbt->{operator}->{$varenv->{dbname}}->{project} ne "Konstanz"); $return->{rental_description}->{tarif_elements}->{$td} = ["$td_template->{$td}->{time02}","$time_unit"]; }elsif($td_template->{$td}->{xduration} && $returned_counting->{real_clock} && $returned_counting->{real_clock} =~ /[1-9]/){ $time_unit = $dbt->time_format($varenv,$returned_counting->{real_clock}); diff --git a/copri4/main/src/Mod/Printpreview.pm b/copri4/main/src/Mod/Printpreview.pm index 6245507..fc93b3b 100755 --- a/copri4/main/src/Mod/Printpreview.pm +++ b/copri4/main/src/Mod/Printpreview.pm @@ -701,7 +701,7 @@ td { if($cttpos->{$id}->{int35} && $cttpos->{$id}->{start_time} && $cttpos->{$id}->{end_time}){ $pri->count_freedrental("Printpreview",\%varenv,$ctt->{int10},$cttpos->{$id}); ($pricing,$counting) = $pri->counting_rental($varenv,$cttpos->{$id}); - $rental_feed = $pri->fetch_rentalfeed($varenv,$cttpos->{$id},$counting); + $rental_feed = $pri->fetch_rentalfeed($varenv,$varenv,$cttpos->{$id},$counting); $rabatt = $pricing->{discount}; $sum_parts19 += $pricing->{total_price}; $gesamt = $pri->round($pricing->{total_price}); diff --git a/copri4/main/src/Tpl/BaseEdit.pm b/copri4/main/src/Tpl/BaseEdit.pm index 96b24a6..8d355bc 100755 --- a/copri4/main/src/Tpl/BaseEdit.pm +++ b/copri4/main/src/Tpl/BaseEdit.pm @@ -191,7 +191,12 @@ sub tpl(){ if($cttpos->{int35} && $cttpos->{start_time} && $cttpos->{end_time}){ ($pricing,$counting) = $pri->counting_rental(\%varenv,$cttpos); - $rental_feed = $pri->fetch_rentalfeed(\%varenv,$cttpos,$counting); + + my $dbh_primary = $dbt->dbconnect_extern($dbt->{primary}->{sharee_primary}->{database}->{dbname}); + my %varenv_prim = (); + $varenv_prim{cms} = $dbt->fetch_cms($dbh_primary,{ lang => $q->escapeHTML($lang) }); + + $rental_feed = $pri->fetch_rentalfeed(\%varenv_prim,\%varenv,$cttpos,$counting); $gesamt = $pri->round($pricing->{total_price}); $gesamt = sprintf('%.2f', $gesamt); }else{ diff --git a/copri4/main/src/Tpl/TransPositionen.pm b/copri4/main/src/Tpl/TransPositionen.pm index 56b127b..658e2ac 100755 --- a/copri4/main/src/Tpl/TransPositionen.pm +++ b/copri4/main/src/Tpl/TransPositionen.pm @@ -54,6 +54,7 @@ sub tpl(){ my $channel_map = $dbt->channel_map(); my $coo = $q->cookie(-name=>'domcookie') || ""; my $dbh = ""; + my $lang = "de"; my $mapref = {}; my $ct_users = $dbt->users_map($dbh,$mapref);#get serviceAPP and DMS users from contentadr @@ -179,7 +180,12 @@ EOF if($cttpos->{$id}->{int35} && $cttpos->{$id}->{start_time} && $cttpos->{$id}->{end_time}){ $pri->count_freedrental($q,\%varenv,$ctadr->{c_id},$cttpos->{$id}); ($pricing,$counting) = $pri->counting_rental(\%varenv,$cttpos->{$id}); - $rental_feed = $pri->fetch_rentalfeed(\%varenv,$cttpos->{$id},$counting); + + my $dbh_primary = $dbt->dbconnect_extern($dbt->{primary}->{sharee_primary}->{database}->{dbname}); + my %varenv_prim = (); + $varenv_prim{cms} = $dbt->fetch_cms($dbh_primary,{ lang => $q->escapeHTML($lang) }); + + $rental_feed = $pri->fetch_rentalfeed(\%varenv_prim,\%varenv,$cttpos->{$id},$counting); $sum_parts19 += $pricing->{total_price}; $gesamt = $pri->round($pricing->{total_price}); $gesamt = sprintf('%.2f', $gesamt);