mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-02-22 19:56:29 +01:00
deliver bikes_occupied by stations_available request
This commit is contained in:
parent
a638aad485
commit
be17c401cc
6 changed files with 57 additions and 50 deletions
|
@ -2224,8 +2224,6 @@ sub stations_available(){
|
|||
}
|
||||
$return->{$id}->{bike_count} = "$bike_count";
|
||||
|
||||
$return->{$id}->{uri_operator} = "$varenv->{wwwhost}";
|
||||
|
||||
$return->{$id}->{authed} = "$authed";
|
||||
$return->{$id}->{capacity} = "$record->{$id}->{int05}" || "1";
|
||||
|
||||
|
@ -3000,15 +2998,6 @@ sub auth_verify(){
|
|||
print FILE "users_serviceapp: $users_serviceapp->{u_id} | $return->{authcookie}\n" if($debug);
|
||||
}
|
||||
|
||||
#if any no public user on request, then don't generate cache
|
||||
#my $public_user = 1;
|
||||
#if(ref($adrtarif_hash) eq "HASH"){
|
||||
# foreach my $atid (keys (%$adrtarif_hash)){
|
||||
# $public_user = 0 if($adrtarif_hash->{$atid} == 1);
|
||||
# }
|
||||
#}
|
||||
#$return->{public_user} = "$public_user";
|
||||
|
||||
print FILE "final return: $return->{authcookie}\n" if($debug);
|
||||
|
||||
close(FILE) if($debug);
|
||||
|
|
|
@ -42,6 +42,7 @@ sub loop_sharees {
|
|||
my $auth = shift;
|
||||
my $authraw = shift;
|
||||
my $return_merchant = shift || "";
|
||||
my $last_used_operator = shift || "";
|
||||
my @keywords = $q->param;
|
||||
|
||||
#only request keys which initated by sharee primary requests to operator
|
||||
|
@ -85,9 +86,9 @@ sub loop_sharees {
|
|||
#every sharee client must have a merchant_id which associate a project
|
||||
if($op_name->{operatorApp} && ($users_serviceapp->{u_id} || $return_merchant->{merchant_id} eq $globalconf{website}->{'shareeweb-sharee'}->{merchant_id} || ($return_merchant->{project_id} eq $op_name->{project}))){
|
||||
$o++;
|
||||
#stations_available with optional caching
|
||||
if($rest_hash->{request} eq "stations_available"){
|
||||
push(@uri_operator_array, $op_name->{operatorApp});
|
||||
#station caching (empty user_group)
|
||||
#if disabled, reads DB
|
||||
if($op_name->{cache_station} == 1){
|
||||
#primary authraw
|
||||
|
@ -175,13 +176,21 @@ sub loop_sharees {
|
|||
}
|
||||
}
|
||||
|
||||
}#end caching_stations
|
||||
}#end cache_station
|
||||
else{
|
||||
$ret_json = $self->fetch_operator_json("$op_name->{operatorApp}/APIjsonserver",$rest);
|
||||
$bw->log("$o $key) Caching disabled, No reading json-caching, taking: $op_name->{operatorApp}/APIjsonserver?$rest",$ret_json,"");
|
||||
}
|
||||
|
||||
}#end stations_available
|
||||
#user_bike_occupied by $last_used_operator
|
||||
elsif($last_used_operator && $rest_hash->{request} eq "user_bikes_occupied"){
|
||||
if($last_used_operator eq $op_name->{database}->{dbname}){
|
||||
#$bw->log("fetch_operator_json >> user_bikes_occupied by last_used_operator:$last_used_operator ","","");
|
||||
$ret_json = $self->fetch_operator_json("$op_name->{operatorApp}/APIjsonserver","$rest&withoutkey=1");
|
||||
}
|
||||
}
|
||||
#all other operator requests
|
||||
else{
|
||||
$ret_json = $self->fetch_operator_json("$op_name->{operatorApp}/APIjsonserver",$rest);
|
||||
}
|
||||
|
@ -245,8 +254,7 @@ sub fetch_operator_json {
|
|||
my $rest = shift || "";
|
||||
my $operator_request = "$operator_server?$rest";
|
||||
|
||||
#$bw->log("fetch_operator_json >> ","$operator_request","");
|
||||
|
||||
#$bw->log("fetch_operator_json >> $operator_request","$operator_request","");
|
||||
my $req = HTTP::Request->new(GET => "$operator_request");
|
||||
$req->content_type('application/x-www-form-urlencoded');
|
||||
$req->content($rest);
|
||||
|
|
|
@ -431,7 +431,7 @@ elsif($q->param('request') eq "user_bikes_occupied"){
|
|||
my ($auth,$authraw) = $apif->auth_verify($q);
|
||||
if(ref($auth) eq "HASH" && $auth->{authcookie}){
|
||||
$response = { %$response, %$auth };
|
||||
($response->{bikes_occupied},$response->{uri_operator_array},$response->{user_group},$response->{user_tour}) = $jsc->loop_sharees($q,$auth,$authraw,$return_merchant);
|
||||
($response->{bikes_occupied},$response->{uri_operator_array},$response->{user_group},$response->{user_tour}) = $jsc->loop_sharees($q,$auth,$authraw,$return_merchant,"");
|
||||
}else{
|
||||
$response->{response_state} = "Failure 1001: authcookie not defined";
|
||||
$response->{response_text} = "Entschuldigung, die Sitzung wurde unterbrochen";
|
||||
|
@ -443,7 +443,11 @@ elsif($q->param('request') eq "user_bikes_occupied"){
|
|||
if(ref($auth) eq "HASH" && $auth->{authcookie}){
|
||||
$response = { %$response, %$auth };
|
||||
my $record = $apif->user_bikes_occupied($dbh,$authraw,"show_dialog");
|
||||
$response->{bikes_occupied} = $apif->rentals($record,$authraw,"1");
|
||||
if($R::withoutkey){
|
||||
$response->{bikes_occupied} = $apif->rentals($record,$authraw,"");
|
||||
}else{
|
||||
$response->{bikes_occupied} = $apif->rentals($record,$authraw,"1");
|
||||
}
|
||||
}else{
|
||||
$response->{response_state} = "Failure 1001: authcookie not defined";
|
||||
$response->{response_text} = "Entschuldigung, die Sitzung wurde unterbrochen";
|
||||
|
@ -463,7 +467,7 @@ elsif($q->param('request') eq "bikes_available"){
|
|||
my $authraw = {};
|
||||
($auth,$authraw) = $apif->auth_verify($q);
|
||||
$response = { %$response, %$auth };
|
||||
($response->{bikes},$response->{uri_operator_array},$response->{user_group},$response->{user_tour}) = $jsc->loop_sharees($q,$auth,$authraw,$return_merchant);
|
||||
($response->{bikes},$response->{uri_operator_array},$response->{user_group},$response->{user_tour}) = $jsc->loop_sharees($q,$auth,$authraw,$return_merchant,"");
|
||||
#$bw->log("X bikes_available $varenv{syshost} $stamp: $response->{user_group}",$response,"");
|
||||
}else{
|
||||
($aowner,my $return_merchant) = $apif->fetch_merchant($q,\%varenv,$coo,$q->param('merchant_id'));
|
||||
|
@ -499,7 +503,7 @@ elsif($q->param('request') eq "bikes_all"){
|
|||
|
||||
my ($auth,$authraw) = $apif->auth_verify($q);
|
||||
$response = { %$response, %$auth };
|
||||
($response->{bikes},$response->{uri_operator_array},$response->{user_group},$response->{user_tour}) = $jsc->loop_sharees($q,$auth,$authraw,$return_merchant);
|
||||
($response->{bikes},$response->{uri_operator_array},$response->{user_group},$response->{user_tour}) = $jsc->loop_sharees($q,$auth,$authraw,$return_merchant,"");
|
||||
}else{
|
||||
($aowner,my $return_merchant) = $apif->fetch_merchant($q,\%varenv,$coo,$q->param('merchant_id'));
|
||||
$varenv{merchant_id} = $return_merchant->{merchant_id};
|
||||
|
@ -640,7 +644,7 @@ elsif($q->param('request') eq "stations_all"){
|
|||
|
||||
my ($auth,$authraw) = $apif->auth_verify($q);
|
||||
$response = { %$response, %$auth };
|
||||
($response->{stations},$response->{uri_operator_array},$response->{user_group},$response->{user_tour}) = $jsc->loop_sharees($q,$auth,$authraw,$return_merchant);
|
||||
($response->{stations},$response->{uri_operator_array},$response->{user_group},$response->{user_tour}) = $jsc->loop_sharees($q,$auth,$authraw,$return_merchant,"");
|
||||
}else{
|
||||
($aowner,my $return_merchant) = $apif->fetch_merchant($q,\%varenv,$coo,$q->param('merchant_id'));
|
||||
$varenv{merchant_id} = $return_merchant->{merchant_id};
|
||||
|
@ -686,38 +690,23 @@ elsif($q->param('request') eq "stations_available"){
|
|||
};
|
||||
my $uadr = { c_id => 0 };
|
||||
$uadr = $dbt->fetch_tablerecord($dbh,$pref_ctu);
|
||||
$response->{merchant_message} = $uadr->{txt01} . $user_agent;
|
||||
$response->{merchant_message} = $uadr->{txt01};
|
||||
$response->{merchant_message} = $uadr->{txt02} if($q->param('lang') eq "en");
|
||||
}else{
|
||||
$apif->authout($q,$coo);
|
||||
}
|
||||
}
|
||||
|
||||
#user_rental
|
||||
$response->{user_rental} = {};
|
||||
if($authraw->{txt19} && $authraw->{txt19} =~ /sharee_/){
|
||||
my $last_used_operator = $authraw->{txt19};
|
||||
my $dbh_operator = $dbt->dbconnect_extern("$last_used_operator");
|
||||
my $record_rentals = {};
|
||||
$record_rentals = $apif->user_bikes_occupied($dbh_operator,$authraw,"");
|
||||
foreach my $r_id (keys (%$record_rentals)){
|
||||
if($record_rentals->{$r_id}->{c_id}){
|
||||
my $prefix = $record_rentals->{$r_id}->{txt12};
|
||||
my $station_type = "A-B";
|
||||
$station_type = "A-A" if($record_rentals->{$r_id}->{int41});
|
||||
$response->{user_rental} = { $record_rentals->{$r_id}->{c_id} => {
|
||||
bike_id => "$prefix$record_rentals->{$r_id}->{barcode}",
|
||||
station_id => "$prefix$record_rentals->{$r_id}->{int06}",
|
||||
station_group => "$prefix$record_rentals->{$r_id}->{int29}",
|
||||
station_type => "$station_type",
|
||||
}};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$response = { %$response, %$auth };
|
||||
($response->{stations},$response->{uri_operator_array},$response->{user_group},$response->{user_tour}) = $jsc->loop_sharees($q,$auth,$authraw,$return_merchant);
|
||||
($response->{stations},$response->{uri_operator_array},$response->{user_group},$response->{user_tour}) = $jsc->loop_sharees($q,$auth,$authraw,$return_merchant,"");
|
||||
|
||||
#user_rental
|
||||
if($authraw->{txt19} && $authraw->{txt19} =~ /sharee_/){
|
||||
my $last_used_operator = $authraw->{txt19};
|
||||
$q->param(-name=>'request',-value=>"user_bikes_occupied");
|
||||
($response->{bikes_occupied},my $uri_operator_array,my $user_group,my $user_tour) = $jsc->loop_sharees($q,$auth,$authraw,$return_merchant,$last_used_operator);
|
||||
}
|
||||
|
||||
}else{
|
||||
($aowner,my $return_merchant) = $apif->fetch_merchant($q,\%varenv,$coo,$q->param('merchant_id'));
|
||||
$varenv{merchant_id} = $return_merchant->{merchant_id};
|
||||
|
|
|
@ -349,7 +349,7 @@ EOF
|
|||
print $q->td({-class=>'tdescr4'},"Payone Zahlungsart"),"\n";
|
||||
print $q->td({-class=>'tdval4'},"$kind_of_payment"),"\n";
|
||||
print $q->Tr(),"\n";
|
||||
print $q->td({-class=>'tdescr4'},"Payone last log"),"\n";
|
||||
print $q->td({-class=>'tdescr4'},"Payone log Kunde"),"\n";
|
||||
print $q->td({-class=>'tdval4'},"$payteaser"),"\n";
|
||||
print $q->Tr(),"\n";
|
||||
print $q->td({-class=>'tdescr4'},"Payone TXID"),"\n";
|
||||
|
|
|
@ -717,7 +717,7 @@ EOF
|
|||
print $q->td({-style=>"font-size:0.71em;padding:0;border:0px solid green;",-colspan=>"$tdcal",-nowrap=>"1"},"$day4month"),"\n";
|
||||
}
|
||||
|
||||
my $sum_saldo="0";my $sum_opos="0";my $sum_abb="0";my $sum_ueb="0";my $sum_success="0";my $sum_SEPApayone="0";my $sum_CCpayone="0";my $sum_ausfall="0";my $sum_entgelt="0";my $sum_abr="0";my $close_time="";my $payment_time="";
|
||||
my $sum_saldo="0";my $sum_opos="0";my $sum_abb="0";my $sum_ueb="0";my $sum_success="0";my $sum_SEPApayone="0";my $sum_CCpayone="0";my $sum_ausfall="0";my $sum_gutschrift="0";my $sum_einzugfail="0";my $sum_entgelt="0";my $sum_abr="0";my $close_time="";my $payment_time="";
|
||||
my $nr=0;my $nx=0;
|
||||
|
||||
#BIG LOOP loop content table
|
||||
|
@ -796,12 +796,14 @@ EOF
|
|||
$payment_time = $lb->time4de($payment_time,"1");
|
||||
}
|
||||
$sum_saldo += $ct4rel->{$id}->{int16} if($ct4rel->{$id}->{state});
|
||||
$sum_opos += $ct4rel->{$id}->{int01} if($ct4rel->{$id}->{state} && $ct4rel->{$id}->{state} ne "Zahlungsausfall" && $ct4rel->{$id}->{int14} >= 1);
|
||||
$sum_opos += $ct4rel->{$id}->{int01} if($ct4rel->{$id}->{state} && $ct4rel->{$id}->{int14} >= 1 && ($ct4rel->{$id}->{state} !~ /ausfall|fehlgeschlagen/i));
|
||||
$sum_abb += $ct4rel->{$id}->{int01} if($ct4rel->{$id}->{state} && $ct4rel->{$id}->{state} =~ /Abbuchung/);
|
||||
$sum_ueb += $ct4rel->{$id}->{int01} if($ct4rel->{$id}->{state} && $ct4rel->{$id}->{state} =~ /Überweisung/);
|
||||
$sum_SEPApayone += $ct4rel->{$id}->{int01} if($ct4rel->{$id}->{state} && $ct4rel->{$id}->{state} =~ /SEPA.*payone|Zahlungseingang.*payone/);
|
||||
$sum_CCpayone += $ct4rel->{$id}->{int01} if($ct4rel->{$id}->{state} && $ct4rel->{$id}->{state} =~ /Kreditkarte.*payone/);
|
||||
$sum_ausfall += $ct4rel->{$id}->{int01} if($ct4rel->{$id}->{state} && $ct4rel->{$id}->{state} =~ /Zahlungsausfall/);
|
||||
$sum_gutschrift += $ct4rel->{$id}->{int01} if($ct4rel->{$id}->{state} && $ct4rel->{$id}->{state} =~ /Gutschrift/);
|
||||
$sum_einzugfail += $ct4rel->{$id}->{int01} if($ct4rel->{$id}->{state} && $ct4rel->{$id}->{state} =~ /fehlgeschlagen/i);
|
||||
$sum_entgelt += $ct4rel->{$id}->{int01} if($ct4rel->{$id}->{state} && $ct4rel->{$id}->{state} =~ /Entgelt/);
|
||||
$sum_abr -= $ct4rel->{$id}->{int02} if($ct4rel->{$id}->{state} && $ct4rel->{$id}->{state} =~ /Abrechnung/);
|
||||
$c_id4csv .= "$ct4rel->{$id}->{c_id},";
|
||||
|
@ -1205,6 +1207,25 @@ EOF
|
|||
print $q->td({-class=>'tdint',-colspan=>"$m"},"Kreditkarte (payone) Summe");
|
||||
print $q->td({-class=>'tdint',-colspan=>"1",-nowrap=>"1"},"$sum_CCpayone €");
|
||||
}
|
||||
if($sum_gutschrift != 0){
|
||||
$sum_gutschrift *= -1;
|
||||
$sum_gutschrift = sprintf('%.2f',$sum_gutschrift);
|
||||
$sum_gutschrift += $sum_gutschrift;
|
||||
$sum_success += $sum_gutschrift;
|
||||
print $q->Tr();
|
||||
print $q->td({-style=>"background-color:silver;"},""),"\n";
|
||||
print $q->td({-class=>'tdint',-colspan=>"$m"},"Gutschrift Summe");
|
||||
print $q->td({-class=>'tdint',-colspan=>"1",-nowrap=>"1"},"$sum_gutschrift €");
|
||||
}
|
||||
if($sum_einzugfail != 0){
|
||||
$sum_einzugfail *= -1;
|
||||
$sum_einzugfail = sprintf('%.2f',$sum_einzugfail);
|
||||
$sum_success += $sum_einzugfail;
|
||||
print $q->Tr();
|
||||
print $q->td({-style=>"background-color:silver;"},""),"\n";
|
||||
print $q->td({-class=>'tdint',-colspan=>"$m"},"fehlgeschlagener Einzug Summe");
|
||||
print $q->td({-class=>'tdint',-colspan=>"1",-nowrap=>"1"},"$sum_einzugfail €");
|
||||
}
|
||||
if($sum_ausfall != 0){
|
||||
$sum_ausfall *= -1;
|
||||
$sum_ausfall = sprintf('%.2f',$sum_ausfall);
|
||||
|
@ -1218,7 +1239,7 @@ EOF
|
|||
$sum_success = sprintf('%.2f',$sum_success);
|
||||
print $q->Tr();
|
||||
print $q->td({-style=>"background-color:silver;"},""),"\n";
|
||||
print $q->td({-class=>'tdsum',-colspan=>"$m"},"Erfolgreiche Zahlungen Summe");
|
||||
print $q->td({-class=>'tdsum',-colspan=>"$m"},"Gesamtsumme");
|
||||
print $q->td({-class=>'tdsum',-colspan=>"1",-nowrap=>"1"},"$sum_success €");
|
||||
}
|
||||
#disabled, only useful by timerange
|
||||
|
|
|
@ -575,7 +575,7 @@ EOF
|
|||
print $q->div({-class=>'element6',-style=>'float:right;background-color:silver;'}, $q->b("$ctt->{txt00}"),
|
||||
": PDF drucken ",$but->checkbox("print_pdf","ct_trans","1","PDF drucken",""),
|
||||
" – eMail senden ",$but->checkbox("1","send_invoice","$send_invoice_checkbox","eMail $ctt->{txt00}",""),
|
||||
" – Zahlungart ",
|
||||
" – Zahlungsart/Status ",
|
||||
$but->selector("state","250px",$kind_of_payment,@_paymentstate),
|
||||
$but->singlesubmit1("set_state","buchen")),
|
||||
"\n";
|
||||
|
|
Loading…
Add table
Reference in a new issue