diff --git a/copri4/main/css/local_style_2.css b/copri4/main/css/local_style_2.css index b853104..bc9c110 100755 --- a/copri4/main/css/local_style_2.css +++ b/copri4/main/css/local_style_2.css @@ -171,6 +171,7 @@ div#Oline { font-size:16px; line-height:2.0; max-width:750px; + padding:0.2em 0; text-align:left; } .content_float2 { diff --git a/copri4/main/src/Mod/APIfunc.pm b/copri4/main/src/Mod/APIfunc.pm index acc54ec..a42b9e1 100755 --- a/copri4/main/src/Mod/APIfunc.pm +++ b/copri4/main/src/Mod/APIfunc.pm @@ -1699,38 +1699,45 @@ sub rentals(){ } } #sig update station_lock_state=locked to cancel once miniquery - elsif($record->{$id}->{int11} && $record->{$id}->{int11} == 3 && $record->{$id}->{int28} && $record->{$id}->{int28} == 3){ + elsif($record->{$id}->{int11} && $record->{$id}->{int11} == 3){ + + #$return->{state} = "requested";#used once in App after sig rental-end push-notify + $return->{$id}->{rentalId} = "$record->{$id}->{txt11}"; + + if($record->{$id}->{int28} && $record->{$id}->{int28} == 3){ - #only for project=Bayern and developer enabled - if(($dbt->{operator}->{$varenv{dbname}}->{project} eq "Bayern" && $auth->{int23} < 4) || ($auth->{c_id} == 1842 || $auth->{c_id} == 5781 || $auth->{c_id} == 11765 || $auth->{c_id} == 1843 || $auth->{c_id} == 38883)){ + #only for project=Bayern and developer enabled + if(($dbt->{operator}->{$varenv{dbname}}->{project} eq "Bayern" && $auth->{int23} < 4) || ($auth->{c_id} == 1842 || $auth->{c_id} == 5781 || $auth->{c_id} == 11765 || $auth->{c_id} == 1843 || $auth->{c_id} == 38883)){ - $bw->log("user_miniquery via $varenv{dbname} user ID $auth->{c_id} exist count:",$auth->{int23},""); - $return->{user_miniquery} = $dbt->evaluationsfragen($dbh); + $bw->log("user_miniquery via $varenv{dbname} user ID $auth->{c_id} exist count:",$auth->{int23},""); + $return->{user_miniquery} = $dbt->evaluationsfragen($dbh); - #user_miniquest_count - my $user_miniquest_count = $auth->{int23} || 0; - if($user_miniquest_count <= 4){ - $user_miniquest_count++; - my $update_op = { + #user_miniquest_count + my $user_miniquest_count = $auth->{int23} || 0; + if($user_miniquest_count <= 4){ + $user_miniquest_count++; + my $update_op = { table => "contentadr", int23 => $user_miniquest_count, atime => "now()", - }; - my $rows = $dbt->update_record($dbh,$update_op,$auth); - } - }#end mini_quest + }; + my $rows = $dbt->update_record($dbh,$update_op,$auth); + } + }#end mini_quest - #there seems some methodes which needs state, thats because disabled - #$return->{state} = "requested";#used once in App after sig rental-end push-notify + #there seems some methodes which needs state, thats because disabled + #$return->{state} = "requested";#used once in App after sig rental-end push-notify + $return->{$id}->{rentalId} = "$record->{$id}->{txt11}"; - my $update_pos = { + my $update_pos = { table => "contenttranspos", int28 => "1", c_id => "$id", - }; - $dbt->update_record($dbh,$update_pos,$update_pos); - $bw->log("sig update int28 station_lock_state=locked to cancel once miniquery",$update_pos,""); - } + }; + $dbt->update_record($dbh,$update_pos,$update_pos); + $bw->log("sig update int28 station_lock_state=locked to cancel once miniquery",$update_pos,""); + } + } } return $return; diff --git a/copri4/main/src/Mod/APIjsonserver.pm b/copri4/main/src/Mod/APIjsonserver.pm index e15e821..0436d45 100755 --- a/copri4/main/src/Mod/APIjsonserver.pm +++ b/copri4/main/src/Mod/APIjsonserver.pm @@ -264,7 +264,9 @@ elsif($q->param('request') eq "booking_request"){ if($ct_bike->{int11} == 3){ $sig_book = $si->sig_booking(\%varenv,"reserve",$authraw,$ct_bike,""); $sig_book->{bikeId} = "$ct_bike->{txt22}"; - $sig_book->{reservationId} = "$R::reservationId" if($R::reservationId);#only for cmd tests + #we only need rentalId because of reserve/end uses rentalId + #$sig_book->{reservationId} = "$R::reservationId" if($R::reservationId);#only for cmd tests + $sig_book->{rentalId} = "$R::rentalId" if($R::rentalId);#only for cmd tests } $response_book = $apif->booking_request($q,\%varenv,$authraw,$bike,$ct_bike,$ct_tariff,$aowner,$gps,$sig_book); }elsif(!$ct_tariff->{barcode}){ @@ -361,9 +363,6 @@ elsif($q->param('request') eq "booking_cancel" || $q->param('request') eq "booki my $booking_values = {}; if($ctpos->{int11} == 3){ - #this sig request is still not defined - #$response->{response_state} = "Failure: sig bike reservation can not be canceled on sig"; - #$response->{response_text} = "Abbruch, die Reservierung kann nicht storniert werden"; $sig_book = $si->sig_booking(\%varenv,"reserve_end",$authraw,"",$ctpos); ($rows, $booking_values) = $apif->booking_update($q,\%varenv,$authraw,$aowner,$sig_book); }else{ diff --git a/copri4/main/src/Mod/APIsigclient.pm b/copri4/main/src/Mod/APIsigclient.pm index 4fb2254..cea1f69 100755 --- a/copri4/main/src/Mod/APIsigclient.pm +++ b/copri4/main/src/Mod/APIsigclient.pm @@ -176,21 +176,16 @@ sub sig_available { $response_out->{$bike}->{gps}->{longitude} = "$resp->{state}->{lon}" || ""; $response_out->{$bike}->{bike_charge} = "$resp->{energy_level}" || "0"; $response_out->{$bike}->{state} = "defect"; + $response_out->{$bike}->{lock_state} = "locked"; if(uc($resp->{reservation_state}) eq "RESERVED"){ $response_out->{$bike}->{state} = "requested"; }elsif(uc($resp->{reservation_state}) eq "ACTIVE-RENTAL"){ + $response_out->{$bike}->{lock_state} = "unlocked"; $response_out->{$bike}->{state} = "occupied"; }elsif(!$resp->{reservation_state}){ $response_out->{$bike}->{state} = "available"; } - #1. change can take up to 2 mins to reflect - #2. When a customer will start a reservation, it will always be unlock, - #Sigo software automatically handle this condition - $response_out->{$bike}->{lock_state} = "unlocked"; - if($resp->{lock}->{status} eq "locked"){ - $response_out->{$bike}->{lock_state} = "locked"; - } $response_out->{$bike}->{system} = "sigo"; $response_out->{$bike}->{bike_group} = ["SX300102"];#E-Lastenrad $response_out->{$bike}->{unlock_allowed} = "1"; @@ -305,9 +300,9 @@ sub sig_booking { #reservation end, this sig request is still not defined. maybe end by rentalId #int10 state will be set on booking_request elsif($todo eq "reserve_end"){ - $endpoint .= "reserve/end"; + $endpoint .= "bikes/reserve/end"; %json = ( - reservationId => "$ctpos->{txt10}", + rentalId => "$ctpos->{txt11}", email => "$ctadr->{txt08}" ); } @@ -315,8 +310,8 @@ sub sig_booking { #int10 state will be set on main booking_update elsif($todo eq "rental"){ $endpoint .= "rental"; - #my $sig_bikeId = $ctpos->{txt22} || $ct_bike->{txt22}; - my $sig_bikeId = "380116b5-0522-43da-ab66-477744a731a3"; + my $sig_bikeId = $ctpos->{txt22} || $ct_bike->{txt22}; + #my $sig_bikeId = "380116b5-0522-43da-ab66-477744a731a3"; %json = ( bikeId => "$sig_bikeId", email => "$ctadr->{txt08}" @@ -386,25 +381,31 @@ sub sig_booking { owner => "169", }; - #TODO try it with user_bikes_available - #on sig api states maybe not just in time available - #check and save sig bike states - #$q->param(-name=>'request',-value=>"bikes_available"); - #(my $response->{bikes},my $return2copri) = $self->sig_available($q,$varenv,$ctadr); - #my $ctrows = 0; - #$ctrows = $tk->sigbike_cupdate($return2copri); - #print FILE "<--- ctrows:$ctrows, update content state with:" . Dumper($return2copri) . "\n"; + #reservation and rental will return only on success! "rentalId" + if($sig_book->{rentalId}){ + $update_pos->{txt11} = "$sig_book->{rentalId}"; + } + #without rentalId, bike will be available and unlocked! + elsif(($todo eq "reserve" || $todo eq "rental") && !$sig_book->{rentalId}){ + $update_pos->{int10} = 1; + $update_pos->{int20} = 1; - #foreach my $sid (keys (%{$return2copri})){ - # $update_pos->{int10} = "$return2copri->{$sid}->{int10}" if($return2copri->{$sid}->{int10}); - # $update_pos->{int20} = "$return2copri->{$sid}->{int20}" if($return2copri->{$sid}->{int20}); - #} - - $update_pos->{txt10} = "$sig_book->{reservationId}" if($sig_book->{reservationId}); - $update_pos->{txt11} = "$sig_book->{rentalId}" if($sig_book->{rentalId}); + #if($ct_bike->{c_id}){ + my $update_content = { + table => "content", + mtime => "now()", + owner => "169", + int10 => 1, + int20 => 1, + c_id => $ctpos->{cc_id}, + }; + $rows = $dbt->update_record($dbh,$update_content,$update_content); + print FILE "<--- rows: $rows, update_content: $ctpos->{cc_id}, with:" . Dumper($update_content) . "\n"; + #} + } + #$update_pos->{txt10} = "$sig_book->{reservationId}" if($sig_book->{reservationId});#never used $update_pos->{txt25} = "$ctpos->{txt25}\n$sig_book->{return_state}";# if($sig_book->{return_state}); $rows = $dbt->update_record($dbh,$update_pos,$ctpos); - print FILE "<--- rows: $rows, update_pos: $ctpos->{c_id}, with:" . Dumper($update_pos) . "\n"; } diff --git a/copri4/main/src/Mod/DBtank.pm b/copri4/main/src/Mod/DBtank.pm index be934bf..f2c19ad 100755 --- a/copri4/main/src/Mod/DBtank.pm +++ b/copri4/main/src/Mod/DBtank.pm @@ -647,7 +647,7 @@ sub collect_post(){ $sth = $dbh->prepare($sql); }else{ #rental pos with capture booking ct.state - $sql = "SELECT cp.*, ct.state FROM $fetch->{table_pos} cp, $fetch->{table} ct WHERE $cp_where and $poscid IN (SELECT ct.c_id FROM relation rel, $fetch->{table} ct WHERE rel.content_id=ct.c_id and $ct_where) order by cp.mtime ASC";#mtime aufsteigend get last (newest) entry + $sql = "SELECT cp.*, ct.state FROM $fetch->{table_pos} cp, $fetch->{table} ct WHERE $cp_where and cp.ct_id=ct.c_id and $poscid IN (SELECT ct.c_id FROM relation rel, $fetch->{table} ct WHERE rel.content_id=ct.c_id and $ct_where) order by cp.mtime ASC";#mtime aufsteigend get last (newest) entry $sth = $dbh->prepare($sql); } $bw->log("DBtank collect_post $source",$sql,"") if($debug); @@ -1375,7 +1375,7 @@ sub insert_pos(){ my $sth; #Verleihräder if($ct->{template_id} && $ct->{template_id} == 205){#Leihrad_list - $sth = $dbh->prepare("INSERT INTO contenttranspos (ct_id,cc_id,ca_id,ct_name,barcode,txt01,txt08,txt02,txt09,txt12,itime,start_time,end_time,int02,int03,int06,int04,txt05,txt06,txt07,int10,int12,int13,owner,int07,txt04,int09,int17,int15,int16,int11,int18,int19,txt17,txt18,int20,int25,int34,txt22,txt10,int35,int36,int37,time01,time02) VALUES ('$ctt_id','$ct->{c_id}','$ctadr->{c_id}','$ct_name','$ct->{barcode}','$ct->{txt01}','$user_name','$ct->{txt02}','$ctadr->{txt09}','$prefix',now(),now(),'$endRental','$unit_price','$menge','$station','$station','$ct->{txt06}','$ct->{txt06}','$ct->{txt07}','$status','$from_main_id','$deviceId','$owner','$rabatt','$tariff_desc','$tariff_nr','$daymax_price','$abo_price','$free_hours','$ct->{int11}','$sharing_type','$bike_charge','$ct->{txt17}','$ct->{txt18}','$ct->{int20}','$trackon','$staff','$sig_book->{bikeId}','$sig_book->{reservationId}','$unit_price1','$unit_price2','$start_price','$unit_time','$free_time') RETURNING c_id"); + $sth = $dbh->prepare("INSERT INTO contenttranspos (ct_id,cc_id,ca_id,ct_name,barcode,txt01,txt08,txt02,txt09,txt12,itime,start_time,end_time,int02,int03,int06,int04,txt05,txt06,txt07,int10,int12,int13,owner,int07,txt04,int09,int17,int15,int16,int11,int18,int19,txt17,txt18,int20,int25,int34,txt22,txt10,txt11,int35,int36,int37,time01,time02) VALUES ('$ctt_id','$ct->{c_id}','$ctadr->{c_id}','$ct_name','$ct->{barcode}','$ct->{txt01}','$user_name','$ct->{txt02}','$ctadr->{txt09}','$prefix',now(),now(),'$endRental','$unit_price','$menge','$station','$station','$ct->{txt06}','$ct->{txt06}','$ct->{txt07}','$status','$from_main_id','$deviceId','$owner','$rabatt','$tariff_desc','$tariff_nr','$daymax_price','$abo_price','$free_hours','$ct->{int11}','$sharing_type','$bike_charge','$ct->{txt17}','$ct->{txt18}','$ct->{int20}','$trackon','$staff','$sig_book->{bikeId}','$sig_book->{reservationId}','$sig_book->{rentalId}','$unit_price1','$unit_price2','$start_price','$unit_time','$free_time') RETURNING c_id"); }else{ $sth = $dbh->prepare("INSERT INTO contenttranspos (ct_id,cc_id,ca_id,ct_name,barcode,txt08,txt09,itime,int02,int03,txt01,txt06,txt07,int10,int12,owner) VALUES ('$ctt_id','$ct->{c_id}','$ctadr->{c_id}','$ct_name','0','$user_name','$ctadr->{txt09}',now(),'$unit_price','1','$ct->{txt01}','$ct->{txt06}','$ct->{txt07}','0','$from_main_id','$owner') RETURNING c_id"); } diff --git a/copri4/main/src/scripts/requested_timeout.pl b/copri4/main/src/scripts/requested_timeout.pl index 474b8ae..5f2293d 100755 --- a/copri4/main/src/scripts/requested_timeout.pl +++ b/copri4/main/src/scripts/requested_timeout.pl @@ -31,6 +31,9 @@ my $lang = "de"; my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime; my $dbh = ""; +my $interval_min = "15"; +$interval_min = $ARGV[1] if($ARGV[1] && $ARGV[1] =~ /^\d+$/); + #set available if requestes older than 15 minute my $return={}; my $pref = { @@ -40,7 +43,7 @@ my $pref = { #txt10 => "requested", int10 => "2", owner => "!=::199",#don't select LV api requested bikes - start_time => "<=::(now() - interval '15 minutes')", + start_time => "<=::(now() - interval '$interval_min minutes')", }; my $record_cp = $dbt->fetch_tablerecord($dbh,$pref);