diff --git a/copri4/main/src/Mod/APIfunc.pm b/copri4/main/src/Mod/APIfunc.pm
index ec89400..2fac867 100755
--- a/copri4/main/src/Mod/APIfunc.pm
+++ b/copri4/main/src/Mod/APIfunc.pm
@@ -1394,7 +1394,7 @@ sub rentals(){
$return->{$id} = $pri->sharee_pricing($record->{$id},"readonly");
my $bike_id = $return->{$id}->{bike};
$bike_id = $1 if($bike_id =~ /(\d+)/);
- #generate always new keys. keep in mind, keys saved in contenttranspos are overwritten
+ #generate always new ilockit keys.
if($withkey && $record->{$id}->{int11} && $record->{$id}->{int11} == 2){
my @K_select = ();
@K_select = `cd /var/www/copri4/main/src/scripts && export CLASSPATH='.:/usr/share/java:/usr/share/java/postgresql.jar' && java Ilockauth $varenv{dbname} $bike_id`;
@@ -1432,15 +1432,11 @@ sub bikes_available(){
int10 => "1",#1 = "available"
};
my $tariff_content = {};
- #have to be also used without auth!, because of public bikes and stations
- #if(ref($auth) eq "HASH" && $auth->{c_id} > 0){
- $authed = 1 if(ref($auth) eq "HASH" && $auth->{c_id} > 0);
- (my $bike_group,my $user_group,$tariff_content,my $user_tour) = $self->fetch_tariff($auth,$q->param('authcookie'));
- my $main_ids = join(",",@{$bike_group});
- $main_ids =~ s/[a-z_-]+//ig;#should work also without Trenner
- $pref = { %$pref, main_id => "IN::($main_ids)" };
- #}
- #print Dumper($tariff_content);
+ $authed = 1 if(ref($auth) eq "HASH" && $auth->{c_id} > 0);
+ (my $bike_group,my $user_group,$tariff_content,my $user_tour) = $self->fetch_tariff($varenv->{dbname},$auth,$q->param('authcookie'));
+ my $main_ids = join(",",@{$bike_group});
+ $main_ids =~ s/[a-z_-]+//ig;#should work also without Trenner
+ $pref = { %$pref, main_id => "IN::($main_ids)" };
if($q->param('station')){
my $station_id = $1 if($q->param('station') =~ /(\d+)/);
@@ -1508,7 +1504,7 @@ sub bikes_available(){
$return->{$id}->{tariff_description}->{free_hours} = "$tariff_content->{$tid}->{int16}" if($tariff_content->{$tid}->{int16});
$return->{$id}->{tariff_description}->{abo_eur_per_month} = "$tariff_content->{$tid}->{int15}" if($tariff_content->{$tid}->{int15});
#TODO, have to be set on Tarif table
- $return->{$id}->{tariff_description}->{operator_agb} = "Mit der Mietrad Anmietung wird folgender Betreiber AGB zugestimmt (als Demo sharee AGB)." if($auth->{c_id} == 1842 || $auth->{c_id} == 5781 || $auth->{c_id} == 22262);
+ $return->{$id}->{tariff_description}->{operator_agb} = "Mit der Mietrad Anmietung wird folgender Betreiber AGB zugestimmt (als Demo sharee AGB)." if($auth->{c_id} && ($auth->{c_id} == 1842 || $auth->{c_id} == 5781 || $auth->{c_id} == 22262));
}
}
}
@@ -1536,7 +1532,7 @@ sub bikes_all(){
int10 => "!=::3",
};
- my ($bike_group,$user_group,$tariff_content,$user_tour) = $self->fetch_tariff($auth,$q->param('authcookie'));
+ my ($bike_group,$user_group,$tariff_content,$user_tour) = $self->fetch_tariff($varenv->{dbname},$auth,$q->param('authcookie'));
my $main_ids = join(",",@{$bike_group});
$main_ids =~ s/[a-z_]+//ig;
$pref = { %$pref, main_id => "IN::($main_ids)" };
@@ -1617,7 +1613,7 @@ sub stations_available(){
my $authed = 0;
$authed = 1 if(ref($auth) eq "HASH" && $auth->{c_id});
- my ($bike_group,$user_group,$tariff_content,$user_tour) = $self->fetch_tariff($auth,$q->param('authcookie'));
+ my ($bike_group,$user_group,$tariff_content,$user_tour) = $self->fetch_tariff($varenv->{dbname},$auth,$q->param('authcookie'));
my $return = {};
my $pref = {
@@ -1699,7 +1695,7 @@ sub stations_all(){
my $authed = 0;
$authed = 1 if(ref($auth) eq "HASH" && $auth->{c_id});
- my ($bike_group,$user_group,$tariff_content,$user_tour) = $self->fetch_tariff($auth,$q->param('authcookie'));
+ my ($bike_group,$user_group,$tariff_content,$user_tour) = $self->fetch_tariff($varenv->{dbname},$auth,$q->param('authcookie'));
my $return={};
my $pref = {
@@ -1842,6 +1838,7 @@ sub bikes_soll(){
#Collect Tariff to get user_group----------------------
sub fetch_tariff(){
my $self = shift;
+ my $dbname = shift;
my $adr = shift || {};
my $authcookie = shift || "";
@@ -1849,7 +1846,6 @@ sub fetch_tariff(){
$merchant_id = $1 if($authcookie && $authcookie =~ /\w+_(\w+)$/);
my $tariff_content = {};
my @user_tour = ();
- my %varenv = $cf->envonline();
my $auth_operator = {};
#int18
@@ -1867,10 +1863,10 @@ sub fetch_tariff(){
};
#if no primary address then only 2=public
- if((ref($adr) ne "HASH" || !$adr->{c_id}) && ($varenv{dbname} ne "sharee_lv")){
+ if((ref($adr) ne "HASH" || !$adr->{c_id}) && ($dbname ne "sharee_lv")){
$tariff->{int18} = 2;
$tariff_content = $dbt->fetch_record($dbh,$tariff);
- $bw->log("1. Tariff type $tariff->{int18} select on",$varenv{dbname},"");
+ $bw->log("1. Tariff type $tariff->{int18} select on",$dbname,"");
}elsif(ref($adr) eq "HASH" && $adr->{c_id}){
#select operators address to get users tarifnr array in txt30
delete $tariff->{int18} if($tariff->{int18});
@@ -1886,25 +1882,25 @@ sub fetch_tariff(){
if($merchant_id && $dbt->{merchant_ids}->{$merchant_id}->{id} && $dbt->{merchant_ids}->{$merchant_id}->{id} == 187){
my $users_serviceapp = $dbt->select_users($dbh,$auth_operator->{c_id},"and int09=1");
if($users_serviceapp->{int09}){
- $auth_operator->{txt18} =~ s/(\d+)/$dbt->{operator}->{$varenv{dbname}}->{oprefix}$1/g;
+ $auth_operator->{txt18} =~ s/(\d+)/$dbt->{operator}->{$dbname}->{oprefix}$1/g;
@user_tour = ($auth_operator->{txt18});
@user_tour = split(/\s/,$auth_operator->{txt18}) if($auth_operator->{txt18} =~ /\s/);
}
}
#$tariff->{int18} = 2;#disabled because wee need all
- $tariff->{int18} = 4 if($varenv{dbname} eq "sharee_lv");
+ $tariff->{int18} = 4 if($dbname eq "sharee_lv");
#FIXME user tarif select have to be fetched like in net_booking
#$tariff_content must contain tariff_description in App bikes_available listing
$tariff_content = $dbt->fetch_record($dbh,$tariff);
- $bw->log("2. Tariff type $tariff->{int18} select on",$varenv{dbname},"");
+ $bw->log("2. Tariff type $tariff->{int18} select on",$dbname,"");
#
}else{
- $bw->log("3. NO tariff_content on",$varenv{dbname},"");
+ $bw->log("3. NO tariff_content on",$dbname,"");
}
my $oprefix = "";
- $oprefix = "$dbt->{operator}->{$varenv{dbname}}->{oprefix}" if($dbt->{operator}->{$varenv{dbname}}->{oprefix});
+ $oprefix = "$dbt->{operator}->{$dbname}->{oprefix}" if($dbt->{operator}->{$dbname}->{oprefix});
my @tarifnr = ();
my @user_group = ();
@@ -1932,15 +1928,14 @@ sub fetch_tariff(){
if(!@tarifnr && (!$dbt->{merchant_ids}->{$merchant_id}->{id} || $dbt->{merchant_ids}->{$merchant_id}->{id} != 187)){
foreach my $id (keys (%$tariff_content)){
if($tariff_content->{$id}->{int18} eq 2){
- $bw->log("Tarif FOUND FALLBACK for No Tarif users with merchant $merchant_id if($tariff_content->{$id}->{int12} && $varenv{dbname}) (s-type:$tariff_content->{$id}->{int18})",$id,"");
+ $bw->log("Tarif FOUND FALLBACK for No Tarif users with merchant $merchant_id if($tariff_content->{$id}->{int12} && $dbname) (s-type:$tariff_content->{$id}->{int18})",$id,"");
push(@tarifnr, "$tariff_content->{$id}->{barcode}");
push(@user_group, "$oprefix$tariff_content->{$id}->{int12}");#sharee bike_node.main_id
push(@bike_group, "$oprefix$tariff_content->{$id}->{int12}");#sharee bike_node.main_id
}
}
}
- #$bw->log("FETCHED_Tarif by dbname:$varenv{dbname} | user_group:@user_group | bike_group:@bike_group | user_tour:@user_tour | tarifnr: @tarifnr",$tariff_content,"");
- $bw->log("FETCHED_Tarif by dbname:$varenv{dbname} with merchant $merchant_id | user_group:@user_group | bike_group:@bike_group | user_tour:@user_tour | tarifnr: @tarifnr",\@tarifnr,"");
+ $bw->log("FETCHED_Tarif by dbname:$dbname with merchant $merchant_id | user_group:@user_group | bike_group:@bike_group | user_tour:@user_tour | tarifnr: @tarifnr",\@tarifnr,"");
return (\@bike_group,\@user_group,$tariff_content,\@user_tour);
}
@@ -2181,7 +2176,7 @@ sub auth_verify(){
}#end if($varenv{dbname} ne "sharee_primary")
if($varenv{dbname} ne "sharee_primary"){
- ($bike_group,$user_group,$tariff_content,$user_tour) = $self->fetch_tariff($record,$q->param('authcookie'));
+ ($bike_group,$user_group,$tariff_content,$user_tour) = $self->fetch_tariff($varenv{dbname},$record,$q->param('authcookie'));
}
if($auth_primary->{c_id} > 0 && length($auth_primary->{txt05}) > 30){
@@ -2207,7 +2202,7 @@ sub auth_verify(){
$record = $dbt->fetch_record($dbh,$authref);
- ($bike_group,$user_group,$tariff_content,$user_tour) = $self->fetch_tariff($record,$q->param('authcookie'));
+ ($bike_group,$user_group,$tariff_content,$user_tour) = $self->fetch_tariff($varenv{dbname},$record,$q->param('authcookie'));
#maybe there isnt't any authcookie still available on confirm
if ($record->{c_id} > 0){
$return->{user_id} = $record->{txt08};
diff --git a/copri4/main/src/Mod/APIjsonclient.pm b/copri4/main/src/Mod/APIjsonclient.pm
index a58e6d4..db729e1 100755
--- a/copri4/main/src/Mod/APIjsonclient.pm
+++ b/copri4/main/src/Mod/APIjsonclient.pm
@@ -45,12 +45,14 @@ sub loop_sharees {
#my $project = $return_merchant->{project_id} || "all";
#only request keys which initated by sharee primary requests to operator
+ my $rest_hash = {};
my $rest = "";
foreach (@keywords){
if($_ =~ /request|authcookie|system|bike|station/g){
my $val = $q->param($_);
my $encoded_val = $uri_encode->encode($val);
$rest .= "$_=$encoded_val&";
+ $rest_hash->{$_} = "$encoded_val";
}
}
$rest =~ s/\&$//;
@@ -80,11 +82,14 @@ sub loop_sharees {
if($value->{operatorApp} && ($users_serviceapp->{u_id} || ($return_merchant->{project_id} eq $value->{project}))){
$bw->log("--> LOOP-start ($return_merchant->{merchant_id}) jsonclient loop_sharees $key by operatorApp: $value->{operatorApp}, netloc: $netloc if($return_merchant->{project_id} eq $value->{project} || $users_serviceapp->{u_id} > 0)\n","","");
- $ret_json = $self->fetch_operator_json($value->{operatorApp},$rest);
+ $ret_json = $self->fetch_operator_json("$value->{operatorApp}/APIjsonserver",$rest);
+
if($ret_json){
push(@uri_operator_array, $value->{operatorApp});
eval {
- my $response_in = decode_json($ret_json);
+ my $response_in = "";
+ $response_in = decode_json($ret_json);
+ #print Dumper($response_in);
#collect OP user_group
if($response_in->{shareejson}->{user_group}){
@@ -131,7 +136,7 @@ sub fetch_operator_json {
my $self = shift;
my $operator_server = shift || "";
my $rest = shift || "";
- my $operator_request = "$operator_server/APIjsonserver?$rest";
+ my $operator_request = "$operator_server?$rest";
$bw->log("fetch_operator_json >> ","$operator_request","");
diff --git a/copri4/main/src/Mod/APIjsonserver.pm b/copri4/main/src/Mod/APIjsonserver.pm
index fe3b81d..c05fc72 100755
--- a/copri4/main/src/Mod/APIjsonserver.pm
+++ b/copri4/main/src/Mod/APIjsonserver.pm
@@ -5,8 +5,6 @@ package Mod::APIjsonserver;
#
#Server for sharee json api
#
-#use lib qw(/var/www/copri4/tinkdms/src);
-#
##In DB context $q->escapeHTML must always done by API
#
use warnings;
@@ -27,6 +25,7 @@ use Mod::Basework;
use Mod::Shareework;
use Mod::APIfunc;
use Mod::APIjsonclient;
+use Mod::APIsigoclient;
use Data::Dumper;
use Sys::Hostname;
my $hostname = hostname;
@@ -43,6 +42,7 @@ sub handler {
my $tk = new Shareework;
my $apif = new APIfunc;
my $jsc = new APIjsonclient;
+ my $si = new APIsigoclient;
my %varenv = $cf->envonline();
@@ -433,7 +433,12 @@ elsif($q->param('request') eq "bikes_available"){
my ($auth,$authraw) = $apif->auth_verify($q);
$response = { %$response, %$auth };
$bw->log("Y bikes_available by c_id $authraw->{c_id}, Tarif:",$authraw->{txt30},"");
- $response->{bikes} = $apif->bikes_available($q,\%varenv,$authraw);
+
+ if($varenv{syshost} eq "shareeapp-sx"){
+ $response->{bikes} = $si->sigo_available($q,\%varenv,$authraw);
+ }else{
+ $response->{bikes} = $apif->bikes_available($q,\%varenv,$authraw);
+ }
}
if(ref($response->{bikes}) ne "HASH"){
$response->{response_state} = "Failure 5003: cannot find any user defined bike tariff";
@@ -635,7 +640,11 @@ elsif($q->param('request') eq "stations_available"){
my ($auth,$authraw) = $apif->auth_verify($q);
$response = { %$response, %$auth };
- ($response->{stations}, my $response_raw) = $apif->stations_available($q,\%varenv,$authraw);
+ if($varenv{syshost} eq "shareeapp-sx"){
+ $response->{stations} = $si->sigo_available($q,\%varenv,$authraw);
+ }else{
+ ($response->{stations}, my $response_raw) = $apif->stations_available($q,\%varenv,$authraw);
+ }
}
}
diff --git a/copri4/main/src/Mod/APIsigoclient.pm b/copri4/main/src/Mod/APIsigoclient.pm
index bf2deeb..23875e1 100755
--- a/copri4/main/src/Mod/APIsigoclient.pm
+++ b/copri4/main/src/Mod/APIsigoclient.pm
@@ -7,14 +7,14 @@ package APIsigoclient;
#
#380116b5-0522-43da-ab66-477744a731a3
#
-#use lib qw(/var/www/copri-bike/shareeapp-fr01/src);
+use lib qw(/var/www/copri-bike/shareeapp-sx/src);
use warnings;
use strict;
use POSIX;
use Exporter;
our @ISA = qw (Exporter);
-use POSIX;
+#use POSIX;
use CGI;
use JSON;
use LWP::UserAgent;
@@ -26,10 +26,14 @@ use Config::General;
use Lib::Config;
use Mod::DBtank;
use Mod::Basework;
+use Mod::APIfunc;
use Data::Dumper;
+my $q = new CGI;
+my $json = JSON->new->allow_nonref;
my $cf = new Config;
my $dbt = new DBtank;
+my $apif = new APIfunc;
my $bw = new Basework;
sub new {
@@ -39,70 +43,128 @@ sub new {
return $self;
}
-my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
+ my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
+ my $api_file = "/var/www/copri4/shareeconf/apikeys.cfg";
+ my $aconf = Config::General->new($api_file);
+ my %apikeyconf = $aconf->getall;
-my $api_file = "/var/www/copri4/shareeconf/apikeys.cfg";
-my $aconf = Config::General->new($api_file);
-my %apikeyconf = $aconf->getall;
+ my $ua = LWP::UserAgent->new;
+ $ua->agent("sharee sigoclient");
+ my $size = $ua->max_size;
+ my $bytes = 100000;
+ $ua->max_size( $bytes );
+ $ua->default_header( 'x-api-key' => $apikeyconf{sigo}->{api_key} );
-my $ua = LWP::UserAgent->new;
-$ua->agent("sharee sigo-client");
-my $size = $ua->max_size;
-my $bytes = 100000;
-$ua->max_size( $bytes );
-$ua->default_header( 'x-api-key' => $apikeyconf{sigo}->{api_key} );
-
-my $json = JSON->new->allow_nonref;
-my %varenv = $cf->envonline();
-my $response_in = {};
-my $dbh = "";
-my $owner = 169;
-
-open(FILE,">>$varenv{logdir}/APIsigo_client.log");
-print FILE "\n*** $now_dt 'sigo client' \n";
-
-sub get_bikes {
+sub sigo_available {
my $self = shift;
- my $uri_operator = shift || "";
+ my $q = shift;
+ my $varenv = shift || {};
+ my $auth = shift || {};
- open(FILE,">>$varenv{logdir}/APIsigo_client.log");
+ my $response_in = {};
+ my $dbh = "";
+ my $owner = 169;
+
+ my $authed = 0;
+ my $tariff_content = {};
+ $authed = 1 if(ref($auth) eq "HASH" && $auth->{c_id} && $auth->{c_id} > 0);
+ (my $bike_group,my $user_group,$tariff_content,my $user_tour) = $apif->fetch_tariff($varenv->{dbname},$auth,$q->param('authcookie'));
+
+ open(FILE,">>$varenv->{logdir}/APIsigo_client.log");
print FILE "\n*** $now_dt 'sigo client' \n";
- my $endpoint = "https://sigo.dev.sigo.green/api/v1/bikes";
- print "$endpoint\n";
+ #my $endpoint = "https://sigo.dev.sigo.green/api/v1/bikes";
+ my $endpoint = "$dbt->{operator}->{$varenv->{dbname}}->{endpoint}/bikes";
+
my $return = {};
my $rest_json = "";
- my $ret_json = get_sigo("","$endpoint",$rest_json);
+ my $ret_json = get_sigo("$endpoint",$rest_json);
eval {
$response_in = decode_json($ret_json);
- print FILE "<--- get_bikes response_in:\n" . Dumper($response_in);
- if(ref($response_in) eq "HASH"){
- foreach my $resp (@{ $response_in->{items} }) {
- #print Dumper($resp) . "\n";
- $return->{$resp->{mobile_bike_id}}->{bike} = "$resp->{mobile_bike_id}" || "";
- $return->{$resp->{mobile_bike_id}}->{station} = "$resp->{site}->{address}" || "";
- $return->{$resp->{mobile_bike_id}}->{uri_operator} = "$uri_operator" || "";
- $return->{$resp->{mobile_bike_id}}->{description} = "E-Lastenrad";
- $return->{$resp->{mobile_bike_id}}->{gps}->{latitude} = $resp->{site}->{lat} || "";
- $return->{$resp->{mobile_bike_id}}->{gps}->{longitude} = $resp->{site}->{lon} || "";
- $return->{$resp->{mobile_bike_id}}->{bike_charge} = "$resp->{energy_level}" || "0";
- $return->{$resp->{mobile_bike_id}}->{state} = "";
- if($resp->{status} eq "ACTIVE"){#?
- $return->{$resp->{mobile_bike_id}}->{state} = "available";
- }elsif($resp->{status} eq "MAINTANANCE"){
- $return->{$resp->{mobile_bike_id}}->{state} = "maintanance";
- }elsif($resp->{status} eq "OPERATION"){#?
- $return->{$resp->{mobile_bike_id}}->{state} = "occupied";
- }
+ print FILE "<--- station_and_bikes response_in:\n";
+ #print FILE Dumper($response_in) . "\n";
+
+ if(ref($response_in) eq "HASH"){
+ foreach my $resp (@{ $response_in->{items} }) {
+ print FILE Dumper($resp) . "\n";
+
+ if($dbt->{operator}->{$varenv->{dbname}}->{operatorApp} && $q->param('request') eq "stations_available"){
+
+ #station (mainly using sigojson site object)
+ my $station = "SX$resp->{site}->{id}";
+ if($station && looks_like_number($resp->{site}->{id}) && $resp->{site}->{status} eq "ACTIVE" && $resp->{site}->{lat} && $resp->{site}->{lon}){
+ print FILE "Station: $station\n";
+ $return->{$station}->{station} = "$station";
+ $return->{$station}->{authed} = "$authed";
+ $return->{$station}->{uri_operator} = "$dbt->{operator}->{$varenv->{dbname}}->{operatorApp}";
+ $return->{$station}->{description} = "$resp->{site}->{address}" || "";
+ $return->{$station}->{station_group} = ["SX300102"];#E-Lastenrad
+ $return->{$station}->{gps}->{latitude} = "$resp->{site}->{lat}" || "";
+ $return->{$station}->{gps}->{longitude} = "$resp->{site}->{lon}" || "";
+ $return->{$station}->{gps_radius} = "75";
+ $return->{$station}->{state} = "defect";
+ if($resp->{site}->{status} eq "ACTIVE"){#?
+ $return->{$station}->{state} = "available";
+ }elsif($resp->{site}->{status} eq "MAINTANANCE"){
+ $return->{$station}->{state} = "maintanance";
+ }elsif($resp->{site}->{status} eq "OFFLINE"){
+ $return->{$station}->{state} = "defect";
+ }
+ $return->{$station}->{operator_data} = {};
- $return->{$resp->{mobile_bike_id}}->{lock_state} = "unlocked";
- if($resp->{state}->{locked}){
- $return->{$resp->{mobile_bike_id}}->{lock_state} = "locked";
}
- $return->{$resp->{mobile_bike_id}}->{system} = "sigo";
- $return->{$resp->{mobile_bike_id}}->{unlock_allowed} = "1";
- $return->{$resp->{mobile_bike_id}}->{tariff_description} = {};
+ }#end stations_available
+
+ if($dbt->{operator}->{$varenv->{dbname}}->{operatorApp} && $q->param('request') eq "bikes_available"){
+
+ #bike (mainly using sigojson state object)
+ my $bike = "SX$resp->{mobile_bike_id}";
+ if($bike && looks_like_number($resp->{mobile_bike_id}) && $resp->{status} eq "ACTIVE"){
+ print FILE "Bike: $bike\n";
+ $return->{$bike}->{bike} = "$bike";
+ $return->{$bike}->{authed} = "$authed";
+ $return->{$bike}->{station} = "$resp->{site}->{id}" || "";
+ $return->{$bike}->{uri_operator} = "$dbt->{operator}->{$varenv->{dbname}}->{operatorApp}";
+ $return->{$bike}->{description} = "E-Lastenrad";
+ $return->{$bike}->{gps}->{latitude} = "$resp->{state}->{lat}" || "";
+ $return->{$bike}->{gps}->{longitude} = "$resp->{state}->{lon}" || "";
+ $return->{$bike}->{bike_charge} = "$resp->{energy_level}" || "0";
+ $return->{$bike}->{state} = "defect";
+ if($resp->{status} eq "ACTIVE"){#?
+ $return->{$bike}->{state} = "available";
+ }elsif($resp->{status} eq "MAINTANANCE"){
+ $return->{$bike}->{state} = "maintanance";
+ }elsif($resp->{status} eq "OFFLINE"){
+ $return->{$bike}->{state} = "defect";
+ }elsif($resp->{status} eq "OPERATION"){#?
+ $return->{$bike}->{state} = "occupied";
+ }
+
+ #$return->{$bike}->{lock_state} = "undefined";#?
+ $return->{$bike}->{lock_state} = "unlocked";
+ if($resp->{state}->{locked}){
+ $return->{$bike}->{lock_state} = "locked";
+ }
+ $return->{$bike}->{system} = "sigo";
+ $return->{$bike}->{bike_group} = ["SX300102"];#E-Lastenrad
+ $return->{$bike}->{unlock_allowed} = "1";
+ $return->{$bike}->{tariff_description} = {};
+ if(ref($tariff_content) eq "HASH"){
+ foreach my $tid (sort { $tariff_content->{$a}->{barcode} <=> $tariff_content->{$b}->{barcode} } keys (%$tariff_content)){
+ $return->{$bike}->{tariff_description}->{name} = "$tariff_content->{$tid}->{ct_name}";
+ $return->{$bike}->{tariff_description}->{number} = "$tariff_content->{$tid}->{barcode}";
+ $return->{$bike}->{tariff_description}->{eur_per_hour} = "$tariff_content->{$tid}->{int02}" || "0";
+ $return->{$bike}->{tariff_description}->{max_eur_per_day} = "$tariff_content->{$tid}->{int17}" if($tariff_content->{$tid}->{int17});
+ $return->{$bike}->{tariff_description}->{free_hours} = "$tariff_content->{$tid}->{int16}" if($tariff_content->{$tid}->{int16});
+ $return->{$bike}->{tariff_description}->{abo_eur_per_month} = "$tariff_content->{$tid}->{int15}" if($tariff_content->{$tid}->{int15});
+ #TODO, have to be set on Tarif table
+ $return->{$bike}->{tariff_description}->{operator_agb} = "Mit der Mietrad Anmietung wird folgender Betreiber AGB zugestimmt (Demo)." if($auth->{c_id} && ($auth->{c_id} == 1842 || $auth->{c_id} == 5781 || $auth->{c_id} == 22262));
+ }
+ }
+ }
+ }#end bikes_available
+
}
}
};
@@ -118,7 +180,6 @@ sub get_bikes {
#main GET
sub get_sigo {
- my $self = shift;
my $endpoint = shift || "";
my $rest_json = shift || "";
my $sigo_request = "$endpoint";
@@ -142,7 +203,6 @@ sub get_sigo {
sub post_sigo {
- my $self = shift;
my $endpoint = shift || "";
my $rest_json = shift || "";
my $sigo_request = "$endpoint";
@@ -164,6 +224,4 @@ sub post_sigo {
}
}
-close(FILE);
-
1;
diff --git a/copri4/main/src/Mod/Shareework.pm b/copri4/main/src/Mod/Shareework.pm
index cd146c8..76e4f0e 100755
--- a/copri4/main/src/Mod/Shareework.pm
+++ b/copri4/main/src/Mod/Shareework.pm
@@ -795,7 +795,7 @@ sub net_booking(){
my $main_ids;
- my ($bike_group,$user_group,$tariff_content,$user_tour) = $apif->fetch_tariff($ctadr,"");
+ my ($bike_group,$user_group,$tariff_content,$user_tour) = $apif->fetch_tariff($varenv{dbname},$ctadr,"");
$main_ids = join(",",@{$bike_group});
$main_ids =~ s/[a-z_]+//ig;
my $ct = {};
diff --git a/copri4/main/src/scripts/sigo_client.pl b/copri4/main/src/scripts/sigo_client.pl
index 8274443..0811b3b 100755
--- a/copri4/main/src/scripts/sigo_client.pl
+++ b/copri4/main/src/scripts/sigo_client.pl
@@ -25,12 +25,15 @@ my $si = new APIsigoclient;
my $bw = new Basework;
my $lang = "de";
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
+ my %varenv = $cf->envonline();
my $todo = $ARGV[1];
if($todo eq "get_bikes"){
- my $return = $si->get_bikes("https://shareeapp-sx.copri-bike.de");
- print Dumper($return);
+ $q->param(-name=>'request',-value=>"bikes_available");
+ my $auth = { c_id => 0 };
+ my $return = $si->sigo_available($q,\%varenv,$auth);
+ print $0 . Dumper($return) . "\n";
}
diff --git a/copri4/shareeapp-operator/src/Tpl/ModalboxDialog.pm b/copri4/shareeapp-operator/src/Tpl/ModalboxDialog.pm
index 8d8e7b9..b45ef96 100755
--- a/copri4/shareeapp-operator/src/Tpl/ModalboxDialog.pm
+++ b/copri4/shareeapp-operator/src/Tpl/ModalboxDialog.pm
@@ -61,7 +61,7 @@ sub mobox2(){
my $ctadr = $users_sharee if(ref($users_sharee) eq "HASH" && $users_sharee->{c_id});
my $main_ids;
- my ($bike_group,$user_group,$tariff_content,$user_tour) = $apif->fetch_tariff($ctadr,"");
+ my ($bike_group,$user_group,$tariff_content,$user_tour) = $apif->fetch_tariff($varenv->{dbname},$ctadr,"");
$main_ids = join(",",@{$bike_group});
$main_ids =~ s/[a-z_]+//ig;
diff --git a/copri4/shareeapp-operator/src/Tpl/PayoneSEPA.pm b/copri4/shareeapp-operator/src/Tpl/PayoneSEPA.pm
index c420ec1..3c25290 100755
--- a/copri4/shareeapp-operator/src/Tpl/PayoneSEPA.pm
+++ b/copri4/shareeapp-operator/src/Tpl/PayoneSEPA.pm
@@ -161,7 +161,7 @@ sub tpl(){
#--------------------
}
- print $q->div({-style=>'margin-top:1em;'},""),"\n";
+ print $q->div({-style=>'margin-top:1em;text-align:center;'},""),"\n";
print "\n";