diff --git a/copri4/main/src/Mod/APIfunc.pm b/copri4/main/src/Mod/APIfunc.pm
index 0d78afd..c66741a 100755
--- a/copri4/main/src/Mod/APIfunc.pm
+++ b/copri4/main/src/Mod/APIfunc.pm
@@ -12,6 +12,7 @@ use strict;
use warnings;
use POSIX;
use CGI; # only for debugging
+use JSON;
use Digest::MD5 qw(md5 md5_hex);
use Scalar::Util qw(looks_like_number);
use DateTime;
@@ -28,8 +29,7 @@ use Mod::Pricing;
#use Mod::APIsigclient;#no!
use Data::Dumper;
use Sys::Hostname;
-my $hostname = hostname;
-
+my $json = JSON->new->allow_nonref;
my $cf = new Config;
my $lb = new Libenz;
my $dbt = new DBtank;
@@ -1786,9 +1786,9 @@ sub rental_to_feedback{
#user bikes occupied
-sub user_bikes_occupied(){
+sub user_bikes_occupied {
my $self = shift;
- my $q = shift;
+ my $dbh = shift;
my $auth = shift;
my $show_dialog = shift || "";
@@ -1807,7 +1807,8 @@ sub user_bikes_occupied(){
##selects also int28 > 0 bikes to view once miniquery
#it will only defined on booking_request, because there must be available
#$pref->{show_dialog} = "1" if($show_dialog);
- my $record = $dbt->collect_post($dbh,$pref);
+ my $record = {};
+ $record = $dbt->collect_post($dbh,$pref) if($auth->{c_id});
return $record;
}#end user_bikes_occupied
@@ -1827,6 +1828,8 @@ sub rentals(){
#new sharee_pricing
(my $return_counting->{$id}, my $counting) = $pri->counting_rental(\%varenv,$record->{$id},"");
+ #$bw->log("rentals-rentalog",$return_counting->{$id}->{rentalog},"");
+ $return_counting->{$id}->{rentalog} = "";#just for debuggiog, removed to reduce data in json
my $return_feed->{$id} = $pri->fetch_rentalfeed(\%varenv,$record->{$id},$return_counting->{$id});
$return->{$id} = { %{ $return_counting->{$id} }, %{ $return_feed->{$id} } };
@@ -2142,11 +2145,13 @@ sub bikes_all(){
$return->{$id}->{system} = "Ilockit";
$return->{$id}->{Ilockit_GUID} = "$record->{$id}->{txt17}";
$return->{$id}->{Ilockit_ID} = "$record->{$id}->{txt18}";
- #shareetool
- if($q->param('authcookie') && $dbt->{merchant_ids}->{$varenv->{merchant_id}}->{id} && $dbt->{merchant_ids}->{$varenv->{merchant_id}}->{id} == 187 && scalar(@{$user_tour} >= 1)){
+ #shareetool servicetool
+ #if($q->param('authcookie') && $dbt->{merchant_ids}->{$varenv->{merchant_id}}->{id} && $dbt->{merchant_ids}->{$varenv->{merchant_id}}->{id} == 187 && scalar(@{$user_tour} >= 1)){
+ if($q->param('authcookie') && $varenv->{merchant_id} && $varenv->{merchant_id} eq $dbt->{appsframe}->{shareetool}->{merchant_id} && scalar(@{$user_tour} >= 1)){
+ #2023-01-18 temporarly for Konstanz deactivated
if(${$user_tour}[0] !~ /KN\d/){
- my @service_code = split(/\s/,$record->{$id}->{txt23});
- $return->{$id}->{service_code} = [@service_code];
+ my @service_code = split(/\s/,$record->{$id}->{txt23});
+ $return->{$id}->{service_code} = [@service_code];
}
}
}elsif($record->{$id}->{int11} eq "3"){
@@ -2176,6 +2181,8 @@ sub stations_available(){
$authed = 1 if(ref($auth) eq "HASH" && $auth->{c_id});
my ($bike_group,$bike_node,$user_tour,$tariff_content,$adrtarif_hash) = $self->fetch_tariff($varenv->{dbname},$auth,$q->param('authcookie'));
+ $bw->log("fetch_tariff adrtarif_hash from $varenv->{dbname}\n",$adrtarif_hash,"");
+
#station_group and bike_group alias bike nodes.type_id
my $station_group = "";
$station_group = $record_pos->{int29} if(ref($record_pos) eq "HASH" && $record_pos->{int29});
@@ -2273,7 +2280,7 @@ sub stations_available(){
#user_rental_count
my $record_rentals = {};
- $record_rentals = $self->user_bikes_occupied($q,$auth,"") if($auth->{c_id});
+ $record_rentals = $self->user_bikes_occupied($dbh,$auth,"") if($auth->{c_id});
my $hotline_hash = {
table => "contentuser",
@@ -2286,6 +2293,8 @@ sub stations_available(){
my $op_return = {};
foreach my $id (sort { $record->{$a}->{barcode} <=> $record->{$b}->{barcode} } keys (%$record)){
+ $record->{$id}->{txt06} =~ s/\s//g if($record->{$id}->{txt06});
+ if($record->{$id}->{txt06} && $record->{$id}->{txt06} =~ /\d+\.\d+\,\d+\.\d+/){
my $bike_count = 0;
foreach my $b_id (keys (%$record_bikes)){
if($record->{$id}->{int04} == $record_bikes->{$b_id}->{int04}){
@@ -2295,12 +2304,13 @@ sub stations_available(){
$return->{$id}->{bike_count} = "$bike_count";
my $user_rental_count = 0;
- foreach my $r_id (keys (%$record_rentals)){
- if($record->{$id}->{int04} == $record_rentals->{$r_id}->{int06}){
- $user_rental_count++;
- }
- }
- $return->{$id}->{user_rental_count} = "$user_rental_count";
+ foreach my $r_id (keys (%$record_rentals)){
+ if($record->{$id}->{int04} == $record_rentals->{$r_id}->{int06}){
+ $user_rental_count++;
+ }
+ }
+ $return->{$id}->{user_rental_count} = "$user_rental_count";
+
$return->{$id}->{uri_operator} = "$varenv->{wwwhost}";
$return->{$id}->{authed} = "$authed";
@@ -2308,7 +2318,6 @@ sub stations_available(){
$return->{$id}->{station} = "$dbt->{operator}->{$varenv->{dbname}}->{oprefix}$record->{$id}->{int04}";
$return->{$id}->{uri_operator} = "$varenv->{wwwhost}";
- $record->{$id}->{txt06} =~ s/\s//g;
($return->{$id}->{gps}->{latitude},$return->{$id}->{gps}->{longitude}) = split(/,/,$record->{$id}->{txt06});
my $description = $q->unescapeHTML($record->{$id}->{txt01}) || "";
$return->{$id}->{description} = "$description";
@@ -2324,20 +2333,32 @@ sub stations_available(){
$return->{$id}->{operator_data} = {
"operator_name" => "",
"operator_hours" => "",
- "operator_color" => "",
- "operator_logo" => "",
"operator_phone" => "",
"operator_email" => "",
};
$return->{$id}->{operator_data}->{operator_name} = Encode::encode('utf-8', Encode::decode('iso-8859-1',$hotline_data->{txt01})) if($hotline_data->{txt01});
$return->{$id}->{operator_data}->{operator_hours} = Encode::encode('utf-8', Encode::decode('iso-8859-1',$hotline_data->{txt84})) if($hotline_data->{txt84});
- $return->{$id}->{operator_data}->{operator_color} = $hotline_data->{txt85} if($hotline_data->{txt85});
- $return->{$id}->{operator_data}->{operator_logo} = $hotline_data->{img01} if($hotline_data->{img01});
$return->{$id}->{operator_data}->{operator_phone} = $hotline_data->{txt07} if($hotline_data->{txt07});
$return->{$id}->{operator_data}->{operator_email} = $hotline_data->{txt08} if($hotline_data->{txt08});
$op_return->{$dbt->{operator}->{$varenv->{dbname}}->{oprefix} . $id} = $return->{$id};
+ }
}
+
+ #json caching
+ #call "stations_available" after each station state change
+ my $public_user = 1;
+ foreach my $atid (keys (%$adrtarif_hash)){
+ $public_user = 0 if($adrtarif_hash->{$atid} == 1);
+ }
+
+ if($dbt->{operator}->{$varenv->{dbname}}->{cache_station} == 1 && $public_user == 1){
+ my $stationsout = $json->pretty->encode({ shareejson => { stations => $op_return } });
+ open(CACHE,">$dbt->{copri_conf}->{basedir}/$dbt->{primary}->{sharee_primary}->{dir_app}/json/stations-$dbt->{operator}->{$varenv->{dbname}}->{oprefix}.json");
+ print CACHE $stationsout;
+ close(CACHE);
+ }
+
return ($op_return, $record);
}#end stations_available
@@ -2575,7 +2596,10 @@ sub fetch_tariff(){
}
if(ref($tariff_content) eq "HASH"){
foreach my $tid (keys (%$tariff_content)){
- $adrtarif_hash{$tariff_content->{$tid}->{barcode}} = 1 if($tariff_content->{$tid}->{int18} eq 2);
+ #public or public-bonus tarifs are public viewable stations
+ if($tariff_content->{$tid}->{int18} && ($tariff_content->{$tid}->{int18} == 2 || $tariff_content->{$tid}->{int18} == 5)){
+ $adrtarif_hash{$tariff_content->{$tid}->{barcode}} = 2;
+ }
}
}
@@ -2604,7 +2628,7 @@ sub fetch_tariff(){
@bike_node = keys %bike_node;
@bike_group = keys %bike_group;
- $bw->log("FETCHED_Tarif by dbname:$dbname with merchant $merchant_id | bike_node:@bike_node | bike_group:@bike_group | user_tour:@user_tour | tarifnr: @tarifnr",\@tarifnr,"");
+ $bw->log("FETCHED_Tarif by dbname:$dbname with merchant $merchant_id and optional userID $adr->{c_id} | bike_node:@bike_node | bike_group:@bike_group | user_tour:@user_tour | tarifnr: @tarifnr",\%adrtarif_hash,"");
return (\@bike_group,\@bike_node,\@user_tour,$tariff_content,\%adrtarif_hash);
}
@@ -2901,15 +2925,11 @@ sub auth_verify(){
$return->{last_used_operator} = {
"operator_name" => "",
"operator_hours" => "",
- "operator_color" => "",
- "operator_logo" => "",
"operator_phone" => "",
"operator_email" => "",
};
$return->{last_used_operator}->{operator_name} = $hotline_data->{txt01} if($hotline_data->{txt01});
$return->{last_used_operator}->{operator_hours} = $hotline_data->{txt84} if($hotline_data->{txt84});
- $return->{last_used_operator}->{operator_color} = $hotline_data->{txt85} if($hotline_data->{txt85});
- $return->{last_used_operator}->{operator_logo} = $hotline_data->{img01} if($hotline_data->{img01});
$return->{last_used_operator}->{operator_phone} = $hotline_data->{txt07} if($hotline_data->{txt07});
$return->{last_used_operator}->{operator_email} = $hotline_data->{txt08} if($hotline_data->{txt08});
}
@@ -2931,6 +2951,15 @@ 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);
diff --git a/copri4/main/src/Mod/APIjsonclient.pm b/copri4/main/src/Mod/APIjsonclient.pm
index 5b8d3c5..55fb8f1 100755
--- a/copri4/main/src/Mod/APIjsonclient.pm
+++ b/copri4/main/src/Mod/APIjsonclient.pm
@@ -39,6 +39,7 @@ my $json = JSON->new->allow_nonref;
sub loop_sharees {
my $self = shift;
my $q = shift || "";
+ my $auth = shift;
my $authraw = shift;
my $return_merchant = shift || "";
my @keywords = $q->param;
@@ -77,15 +78,27 @@ sub loop_sharees {
$bw->log("shareetool select_users $return_merchant->{aowner} on $op_name->{database}->{dbname} $authraw->{c_id} $authraw->{txt17}",$users_serviceapp->{u_id},"");
}
#every sharee client must have a merchant_id which associate a project
- #if($op_name->{operatorApp} && ($users_serviceapp->{u_id} || ($return_merchant->{project_id} eq $op_name->{project}))){
-
- #to reduce request time by ($return_merchant->{project_id} eq "Freiburg") we do it only for shareeweb-sharee.copri.eu
- #if($op_name->{operatorApp} && ($users_serviceapp->{u_id} || $return_merchant->{project_id} eq "Freiburg" || ($return_merchant->{project_id} eq $op_name->{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}))){
- #$bw->log("--> LOOP-start ($return_merchant->{merchant_id}) jsonclient loop_sharees $key by operatorApp: $op_name->{operatorApp}, netloc: $netloc if($return_merchant->{project_id} eq $op_name->{project} || $users_serviceapp->{u_id} > 0)\n","","");
+ #station caching (empty user_group)
+ ##TODO check private public hidden ....
+ #FIXME $auth->{public_user}
+ if(1==2 && $op_name->{cache_station} == 1 && $auth->{public_user} == 1 && $rest_hash->{request} eq "stations_available"){
+ my $primary_cache = "$globalconf{primary}->{sharee_primary}->{primaryApp}/json/stations-$op_name->{oprefix}.json";
+ $ret_json = $self->fetch_operator_json("$primary_cache","");
+ #print "$primary_cache" . "\n" . Dumper($ret_json);
+
+ eval {
+ my $response_in = "";
+ $response_in = decode_json($ret_json);
+ };
+ if ($@){
+ $ret_json = $self->fetch_operator_json("$op_name->{operatorApp}/APIjsonserver",$rest);
+ #print "$op_name->{operatorApp}/APIjsonserver?$rest" . "\n" . Dumper($ret_json);
+ }
+ }
+
$ret_json = $self->fetch_operator_json("$op_name->{operatorApp}/APIjsonserver",$rest);
- #print Dumper($ret_json);
if($ret_json){
push(@uri_operator_array, $op_name->{operatorApp});
diff --git a/copri4/main/src/Mod/APIjsonserver.pm b/copri4/main/src/Mod/APIjsonserver.pm
index 9f25cc3..fd3cd10 100755
--- a/copri4/main/src/Mod/APIjsonserver.pm
+++ b/copri4/main/src/Mod/APIjsonserver.pm
@@ -67,7 +67,7 @@ my $response = {
apiserver => "$apiserver",
response => "$respreq",
uri_primary => "$dbt->{primary}->{sharee_primary}->{primaryApp}",
- copri_version => "4.1.22.19",
+ copri_version => "4.1.23.03",
user_id => "",
authcookie => "",
new_authcoo => "0",
@@ -84,7 +84,6 @@ my $response = {
lang => "de",
last_used_operator => {
operator_name => "sharee.bike | TeilRad GmbH",
- operator_color => "#009699",
operator_email => "hotline\@sharee.bike",
operator_phone => "+49 761 45370097",
operator_hours => "Bürozeiten: Montag, Mittwoch, Freitag 9-12 Uhr",
@@ -157,8 +156,8 @@ if($q->param('request') eq "auth_verify"){
my ($auth,$authraw) = $apif->auth_verify($q);
$response = { %$response, %$auth };
if(ref($auth) eq "HASH" && $auth->{authcookie}){
- $response = { %$response, %$auth };
- }else{
+ $response = { %$response, %$auth };
+ }else{
$response->{response_state} = "Failure 1001: authcookie not defined";
$response->{response_text} = "Entschuldigung, die Sitzung wurde unterbrochen";
}
@@ -214,7 +213,7 @@ elsif($q->param('request') eq "booking_request"){
$bike_id = $1 if($bike_id =~ /(\d+)/);
#check count of occcupied/requested bikes
- my $record = $apif->user_bikes_occupied($q,$authraw,"");
+ my $record = $apif->user_bikes_occupied($dbh,$authraw,"");
my $count=0;
my $still_requested = 0;
foreach my $id (keys(%$record)){
@@ -311,7 +310,7 @@ elsif($q->param('request') eq "booking_request"){
}
#return list of occupied/requested bikes
- $record = $apif->user_bikes_occupied($q,$authraw,"");
+ $record = $apif->user_bikes_occupied($dbh,$authraw,"");
$response->{bikes_occupied} = $apif->rentals($record,$authraw,"1");#returns JSON rental values
}#end still_requested
@@ -392,7 +391,7 @@ elsif($q->param('request') eq "booking_cancel" || $q->param('request') eq "booki
($rows, $booking_values) = $apif->booking_update($q,\%varenv,$authraw,$aowner,$sig_book);
$response = {%$response, %$booking_values};
- my $record = $apif->user_bikes_occupied($q,$authraw,"show_dialog");
+ my $record = $apif->user_bikes_occupied($dbh,$authraw,"show_dialog");
$response->{bikes_occupied} = $apif->rentals($record,$authraw,"1");
#update on Ilockit
@@ -400,12 +399,12 @@ elsif($q->param('request') eq "booking_cancel" || $q->param('request') eq "booki
($rows, $booking_values) = $apif->booking_update($q,\%varenv,$authraw,$aowner,$sig_book);
$response = {%$response, %$booking_values};
- my $record = $apif->user_bikes_occupied($q,$authraw,"");
+ my $record = $apif->user_bikes_occupied($dbh,$authraw,"");
$response->{bikes_occupied} = $apif->rentals($record,$authraw,"1");
}
}#end occupied|available
else{
- my $record = $apif->user_bikes_occupied($q,$authraw,"");
+ my $record = $apif->user_bikes_occupied($dbh,$authraw,"");
$response->{bikes_occupied} = $apif->rentals($record,$authraw,"1");
}
@@ -429,7 +428,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,$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";
@@ -440,7 +439,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 };
- my $record = $apif->user_bikes_occupied($q,$authraw,"show_dialog");
+ my $record = $apif->user_bikes_occupied($dbh,$authraw,"show_dialog");
$response->{bikes_occupied} = $apif->rentals($record,$authraw,"1");
}else{
$response->{response_state} = "Failure 1001: authcookie not defined";
@@ -461,7 +460,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,$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'));
@@ -497,7 +496,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,$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};
@@ -638,7 +637,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,$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};
@@ -662,41 +661,60 @@ elsif($q->param('request') eq "stations_available"){
my ($auth,$authraw) = $apif->auth_verify($q);
my $user_agent_subversion = 1000;
- $user_agent_subversion = $3 if($user_agent =~ /3\.0\.(\d+)/);
+ #$user_agent = "3.0.348";#test
+ $user_agent_subversion = $1 if($user_agent =~ /3\.0\.(\d+)/);
- #for tests only contributors with service-tour defined
- if(1==2 && $user_agent_subversion <= 398 && $authraw->{txt18} && $authraw->{c_id} =~ /$dbt->{copri_conf}->{contributors}/){
- my $pref_ctu = {
- table => "contentuser",
- fetch => "one",
- ct_name => "App-update-message",
- };
- my $uadr = { c_id => 0 };
- $uadr = $dbt->fetch_tablerecord($dbh,$pref_ctu);
- $response->{merchant_message} = $uadr->{txt01};
- $response->{merchant_message} = $uadr->{txt02} if($q->param('lang') eq "en");
- }
- #bayern-maintanance-message
+ #merchant_message timerange
my $lnow = strftime("%Y-%m-%d %H:%M:%S", localtime(time));
my $localtime = Time::Piece->strptime($lnow, "%Y-%m-%d %H:%M:%S");
my $epoch_now = $localtime->epoch;
- my $maintanance_start = Time::Piece->strptime("2023-02-16 21:00:00", "%Y-%m-%d %H:%M:%S");
- my $maintanance_end = Time::Piece->strptime("2023-02-17 03:00:00", "%Y-%m-%d %H:%M:%S");
+ my $maintanance_start = Time::Piece->strptime("2023-03-06 00:00:00", "%Y-%m-%d %H:%M:%S");
+ my $maintanance_end = Time::Piece->strptime("2023-04-01 01:00:00", "%Y-%m-%d %H:%M:%S");
my $epoch_start = $maintanance_start->epoch;
my $epoch_end = $maintanance_end->epoch;
- if(1==1 && $return_merchant->{merchant_id} eq $dbt->{appsframe}->{LastenradBayern}->{merchant_id} && $epoch_now >= $epoch_start && $epoch_now <= $epoch_end){
- my $pref_ctu = {
- table => "contentuser",
- fetch => "one",
- ct_name => "bayern-maintanance-message",
- };
- my $uadr = { c_id => 0 };
- $uadr = $dbt->fetch_tablerecord($dbh,$pref_ctu);
- $response->{merchant_message} = $uadr->{txt01};
+
+ #App update message
+ if($user_agent_subversion <= 348){
+ if($epoch_now >= $epoch_start && $epoch_now <= $epoch_end){
+ my $pref_ctu = {
+ table => "contentuser",
+ fetch => "one",
+ ct_name => "App-update-message",
+ };
+ my $uadr = { c_id => 0 };
+ $uadr = $dbt->fetch_tablerecord($dbh,$pref_ctu);
+ $response->{merchant_message} = $uadr->{txt01} . $user_agent;
+ $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,$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};
diff --git a/copri4/main/src/Mod/APIxmlserver.pm b/copri4/main/src/Mod/APIxmlserver.pm
index 52f2b96..09422ca 100755
--- a/copri4/main/src/Mod/APIxmlserver.pm
+++ b/copri4/main/src/Mod/APIxmlserver.pm
@@ -136,12 +136,12 @@ sub handler {
txt08 => $q->escapeHTML($xmlref->{emailID}),
txt11 => "$pwmd5",
txt17 => "sharee_lv",
+ txt19 => "sharee_lv",
int03 => "1",
txt22 => "DE11111111111111111111",
txt23 => "FRSPDE11111",
int04 => "1",
int13 => "1",
- txt30 => "5511",
int05 => "1",
int14 => "1",
int16 => "null",
@@ -150,21 +150,38 @@ sub handler {
txt06 => "79999 freiburg",
txt07 => "$teltime",
ct_name => "LV-12345678",
+ txt30 => "LV5511",#Prim hidden Tarif
};
$c_id = $dbt->insert_contentoid($dbh,$insert);
+ $dbt->update_operatorsloop($varenv{dbname},$c_id,"update");
+
+ #set lv tarif
+ my $update = {
+ table => "contentadr",
+ txt15 => "LV2sharee",#Fcode
+ txt30 => "5511",#Tarif
+ };
+ my $dbh_operator = $dbt->dbconnect_extern("sharee_lv");
+ my $record->{c_id} = $c_id;
+ my $rows = $dbt->update_record($dbh_operator,$update,$record);
}elsif($xmlref->{todo} eq "update_LVuser" && $record_e->{c_id}){
#keep all and add only LV userID if user email still exist
my $update = {
table => "contentadr",
- txt17 => "sharee_lv",
- txt30 => "5511",
mtime => 'now()',
owner => "$owner",
int01 => $q->escapeHTML($xmlref->{userID}),
};
my $rows = $dbt->update_record($dbh,$update,$record_e);
+ $dbt->update_operatorsloop($varenv{dbname},$record_e->{c_id},"update");
+
+ #set lv tarif
+ my $dbh_operator = $dbt->dbconnect_extern("sharee_lv");
+ $update->{txt15} = "LV2sharee";
+ $update->{txt30} = "5511";
+ my $rows = $dbt->update_record($dbh_operator,$update,$record_e);
}elsif($xmlref->{todo} eq "update_LVuser" && $record->{c_id}){
@@ -181,8 +198,16 @@ sub handler {
int14 => "1",
};
my $rows = $dbt->update_record($dbh,$update,$record);
+ $dbt->update_operatorsloop($varenv{dbname},$record->{c_id},"update");
+
+ #set lv tarif
+ my $dbh_operator = $dbt->dbconnect_extern("sharee_lv");
+ $update->{txt15} = "LV2sharee";
+ $update->{txt30} = "5511";
+ my $rows = $dbt->update_record($dbh_operator,$update,$record);
}elsif($xmlref->{todo} eq "delete_LVuser"){
+ #xml deleting deletes only on operator
$dbt->delete_content($dbh,"contentadr",$record->{c_id});
}
diff --git a/copri4/main/src/Mod/DBtank.pm b/copri4/main/src/Mod/DBtank.pm
index b0bbe9b..69fa080 100755
--- a/copri4/main/src/Mod/DBtank.pm
+++ b/copri4/main/src/Mod/DBtank.pm
@@ -147,10 +147,8 @@ sub update_operatorsloop {
my $dbh_operator = $self->dbconnect_extern("$sharee_operator");
if($todo eq "update"){
- #this will be saved by operator DMS and have to keep intividual
- $bw->log("disabled condition: if($sharee_operator ne $dbname || $record_primary->{owner} == 197 || $dbname","","");
delete $record_primary->{txt17};#operators
- delete $record_primary->{txt30} if($dbname ne "sharee_lv" && $record_primary->{txt30} ne "5511");#Tarif, exception sharee_lv;#Tarif
+ delete $record_primary->{txt30};#tarifs
delete $record_primary->{txt15};#Bonusnr
delete $record_primary->{int07};#Rabatt
delete $record_primary->{txt18};#Service tour
@@ -161,7 +159,6 @@ sub update_operatorsloop {
delete $record_primary->{int23};#mini_answer count will be saved on operator
delete $record_primary->{txt29};#Sonstiges
delete $record_primary->{txt35};#Umfragelink
- #}
my $update = {
%$record_primary,
@@ -178,33 +175,9 @@ sub update_operatorsloop {
table => "contentadr",
mtime => 'now()',
};
- #owner => "198",
my $c_id = $self->insert_contentoid($dbh_operator,$insert,"");
$rows = 1 if($c_id);
- #pseudo code copied fom net_booking. have to be done elsewehre because of $apif
- if(1==2){
- my $ctadr = { c_id => $c_id };
- my ($bike_group,$bike_node,$user_tour,$tariff_content,$adrtarif_hash);# = $apif->fetch_tariff($ctadr,"");
- foreach my $id (keys (%$tariff_content)){
- # #int18
- #
";
- if($record_bonus->{int22} == $tf_id && $varenv{syshost} ne "shareedms-kn"){
- $postdes = "Tarif: $record_bonus->{int21} - $record_bonus->{int22} (public - bonus)";
- $postdes .= $q->span({-style=>'color:red;padding-left:10px;'},"Fehler: Bonusnummer") if(!$ctrel->{$key});
+ my $sharing_type = "public-bonus";
+ $sharing_type = $dbt->{copri_conf}->{sharing_type}->{$tariff_all->{$tf_id}->{int18}};
+ if($bonus_record->{int22} && $tf_id && $bonus_record->{int22} == $tf_id){
+ $postdes .= "*code aktiviert $sharing_type Tarif Nr. $bonus_record->{int22}. ";
}
+ if((!$ctrel->{txt15} || $bonus_record->{ct_name} ne $ctrel->{txt15}) && $tf_id && $tariff_all->{$tf_id}->{int18} != 2){
+ $postdes .= $q->span({-style=>'color:red;padding-left:10px;'},"Achtung, $sharing_type Tarif $tf_id ohne *code aktiviert. ");
+ }
+ }
+ if($ctrel->{txt15} && $bonus_record->{ct_name} ne $ctrel->{txt15}){
+ $postdes .= $q->span({-style=>'color:red;padding-left:10px;'},"*code ist nicht vorhanden! ");
+ }elsif($ctrel->{txt15} && $bonus_record->{ct_name} eq $ctrel->{txt15}){
+ my $sharing_type = "public-bonus";
+ $sharing_type = $dbt->{copri_conf}->{sharing_type}->{$tariff_all->{$bonus_record->{int22}}->{int18}} if($bonus_record->{int22});
+ $postdes .= "Ok, $sharing_type *code vorhanden. Trotzdem Tarif Einstellung prüfen.";
}
print $q->Tr();
print $q->td({-class=>'left_italic_cms'},"$des"),"\n";
@@ -840,7 +857,7 @@ EOF
print $q->td({-class=>'content1_cms',-colspan=>'2'},$q->textfield(-class=>'etxt', -style=>"width:$w;",-name=>"$key", -override=>'1', -default=>"$ctrel->{$key}"), $postdes),"\n";
}
}
- elsif($key =~ /txt/ && $key ne "txt12"){
+ elsif($key =~ /txt/ && $key !~ /txt12|txt15/){
print $q->Tr();
print $q->td({-class=>'left_italic_cms'},"$des"),"\n";
print $q->td({-class=>'content1_cms',-colspan=>'2'},$q->textfield(-class=>'etxt', -style=>"width:$w;",-name=>"$key", -override=>'1', -default=>"$ctrel->{$key}"), $postdes),"\n";
diff --git a/copri4/main/src/Tpl/Liste3.pm b/copri4/main/src/Tpl/Liste3.pm
index 45ca10a..28c1d75 100755
--- a/copri4/main/src/Tpl/Liste3.pm
+++ b/copri4/main/src/Tpl/Liste3.pm
@@ -155,6 +155,9 @@ sub tpl(){
$node_meta->{tpl_order} =~ s/txt17=[\w\s=]+,//;
$node_meta->{tpl_order} =~ s/txt19=[\w\s=]+,//;
}
+ if($table eq "contentadr" && $varenv{dbname} eq $dbt->{primary}->{sharee_primary}->{database}->{dbname}){
+ $node_meta->{tpl_order} =~ s/Tarife/private Tarife/;
+ }
$node_meta->{tpl_order} =~ s/c_id=raw=[\w\s=]+// if($users_dms->{u_id} != $dbt->{copri_conf}->{superu_id});
my @tpl_order = split /,/,$node_meta->{tpl_order};
diff --git a/copri4/main/src/Tpl/TransPositionen.pm b/copri4/main/src/Tpl/TransPositionen.pm
index 9a1f4ea..6b97b6a 100755
--- a/copri4/main/src/Tpl/TransPositionen.pm
+++ b/copri4/main/src/Tpl/TransPositionen.pm
@@ -75,8 +75,7 @@ sub tpl(){
$ctf = $dbt->fetch_tablerecord($dbh,$pref_cu);
my $ctadr = $db->get_content1("contentadr",$ctt->{int10});
- my $buchen_mtime = $lb->time4de($ctt->{mtime});
- my $vibuchen_mtime = $lb->time4de($ctt->{mtime},1);
+ my $vibuchen_mtime = "(nicht verfügbar, siehe Internas und log)";
my @tpl_order = ("txt01=Beschreibung","ct_name=Nummer","date_time=timerange","int03=Menge (Miet - Gratis Zeit)","int02=Preis","int07=Rabatt","int04=Gesamt");
my $tplf = $db->get_tpl("201");#Kunden-Faktura, ex Firma
diff --git a/copri4/mkaccess.sh b/copri4/mkaccess.sh
index bc83c32..cef0335 100755
--- a/copri4/mkaccess.sh
+++ b/copri4/mkaccess.sh
@@ -18,6 +18,7 @@ for i in $(find . -type d -and -name cache); do chmod -R ug+rwx $i;done
for i in $(find . -type d -and -name pdf); do chmod -R ug+rwx $i;done
for i in $(find . -type d -and -name xml); do chmod -R ug+rwx $i;done
for i in $(find . -type d -and -name site); do chmod -R ug+rwx $i;done
+for i in $(find . -type d -and -name json); do chmod -R ug+rwx $i;done
for i in $(find . -type d -and -name shareeconf); do chmod -R go-rwx $i;done
for i in $(find . -type d -and -name shareeconf); do chmod -R ug+rx $i;done
for i in $(find . -type d -and -name sql); do chmod -R go-rwx $i;done
diff --git a/copri4/shareeapp-operator/json b/copri4/shareeapp-operator/json
new file mode 120000
index 0000000..036930f
--- /dev/null
+++ b/copri4/shareeapp-operator/json
@@ -0,0 +1 @@
+../shareedms-operator/json
\ No newline at end of file
diff --git a/copri4/shareeapp-operator/src/Tpl/Anmelden.pm b/copri4/shareeapp-operator/src/Tpl/Anmelden.pm
index 05f1ba5..e26a716 100755
--- a/copri4/shareeapp-operator/src/Tpl/Anmelden.pm
+++ b/copri4/shareeapp-operator/src/Tpl/Anmelden.pm
@@ -76,13 +76,7 @@ sub tpl(){
print "