mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-02-22 19:56:29 +01:00
sig station_lock_state collect_post
This commit is contained in:
parent
d918794ef0
commit
a8891eb704
5 changed files with 42 additions and 26 deletions
|
@ -1647,6 +1647,7 @@ sub user_bikes_occupied(){
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $q = shift;
|
my $q = shift;
|
||||||
my $auth = shift;
|
my $auth = shift;
|
||||||
|
my $station_lock_state = shift || "";
|
||||||
|
|
||||||
my $pref = {
|
my $pref = {
|
||||||
table => "contenttrans",
|
table => "contenttrans",
|
||||||
|
@ -1659,6 +1660,11 @@ sub user_bikes_occupied(){
|
||||||
int10 => "IN::('3','2')",
|
int10 => "IN::('3','2')",
|
||||||
"ct.close_time" => "is::null",
|
"ct.close_time" => "is::null",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#station_lock_stat enables a OR condition to view available as requested/occupied
|
||||||
|
##selects also station_lock_state=locking bikes to view once miniquery
|
||||||
|
#true if not defined! it will only defined on booking_request, because there must be available
|
||||||
|
$pref->{station_lock_state} = "3" if(!$station_lock_state);
|
||||||
my $record = $dbt->collect_post($dbh,$pref);
|
my $record = $dbt->collect_post($dbh,$pref);
|
||||||
return $record;
|
return $record;
|
||||||
}#end user_bikes_occupied
|
}#end user_bikes_occupied
|
||||||
|
@ -1725,8 +1731,7 @@ sub rentals(){
|
||||||
}
|
}
|
||||||
}#end mini_quest
|
}#end mini_quest
|
||||||
|
|
||||||
#there seems some methodes which needs state, thats because disabled
|
$return->{$id}->{state} = "returned";#used once in App after sig rental-end push-notify
|
||||||
#$return->{state} = "requested";#used once in App after sig rental-end push-notify
|
|
||||||
$return->{$id}->{rentalId} = "$record->{$id}->{txt11}";
|
$return->{$id}->{rentalId} = "$record->{$id}->{txt11}";
|
||||||
|
|
||||||
my $update_pos = {
|
my $update_pos = {
|
||||||
|
|
|
@ -209,7 +209,8 @@ elsif($q->param('request') eq "booking_request"){
|
||||||
$bike_id = $1 if($bike_id =~ /(\d+)/);
|
$bike_id = $1 if($bike_id =~ /(\d+)/);
|
||||||
|
|
||||||
#check count of occcupied/requested bikes
|
#check count of occcupied/requested bikes
|
||||||
my $record = $apif->user_bikes_occupied($q,$authraw);
|
#"station_lock_state" disables a OR condition to view available as requested/occupied
|
||||||
|
my $record = $apif->user_bikes_occupied($q,$authraw,"station_lock_state");
|
||||||
my $count=0;
|
my $count=0;
|
||||||
my $still_requested = 0;
|
my $still_requested = 0;
|
||||||
foreach my $id (keys(%$record)){
|
foreach my $id (keys(%$record)){
|
||||||
|
@ -308,7 +309,8 @@ elsif($q->param('request') eq "booking_request"){
|
||||||
}
|
}
|
||||||
|
|
||||||
#return list of occupied/requested bikes
|
#return list of occupied/requested bikes
|
||||||
$record = $apif->user_bikes_occupied($q,$authraw);
|
#"station_lock_state" disables a OR condition to view available as requested/occupied
|
||||||
|
$record = $apif->user_bikes_occupied($q,$authraw,"station_lock_state");
|
||||||
$response->{bikes_occupied} = $apif->rentals($record,$authraw,"1");#returns JSON rental values
|
$response->{bikes_occupied} = $apif->rentals($record,$authraw,"1");#returns JSON rental values
|
||||||
|
|
||||||
}#end still_requested
|
}#end still_requested
|
||||||
|
|
|
@ -379,33 +379,42 @@ sub sig_booking {
|
||||||
mtime => "now()",
|
mtime => "now()",
|
||||||
owner => "169",
|
owner => "169",
|
||||||
};
|
};
|
||||||
|
my $update_content = {
|
||||||
#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;
|
|
||||||
|
|
||||||
#if($ct_bike->{c_id}){
|
|
||||||
my $update_content = {
|
|
||||||
table => "content",
|
table => "content",
|
||||||
mtime => "now()",
|
mtime => "now()",
|
||||||
owner => "169",
|
owner => "169",
|
||||||
int10 => 1,
|
|
||||||
int20 => 1,
|
|
||||||
c_id => $ctpos->{cc_id},
|
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";
|
#rentalId will be only on success!
|
||||||
#}
|
if($sig_book->{rentalId}){
|
||||||
|
$update_pos->{txt11} = "$sig_book->{rentalId}";
|
||||||
}
|
}
|
||||||
#$update_pos->{txt10} = "$sig_book->{reservationId}" if($sig_book->{reservationId});#never used
|
if($todo eq "reserve" || $todo eq "rental"){
|
||||||
|
#mark it as unlocked if rentalId on rental
|
||||||
|
if($todo eq "rental" && $sig_book->{rentalId}){
|
||||||
|
$update_pos->{int20} = 2;
|
||||||
|
$update_content->{int20} = 2;
|
||||||
|
}
|
||||||
|
#without rentalId, bike will be available and unlocked!
|
||||||
|
else{
|
||||||
|
$update_pos->{int10} = 1;
|
||||||
|
$update_pos->{int20} = 1;
|
||||||
|
$update_content->{int10} = 1;
|
||||||
|
$update_content->{int20} = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#keep in mind, all other states will be done on REST, hopefully
|
||||||
$update_pos->{txt25} = "$ctpos->{txt25}\n$sig_book->{return_state}";# if($sig_book->{return_state});
|
$update_pos->{txt25} = "$ctpos->{txt25}\n$sig_book->{return_state}";# if($sig_book->{return_state});
|
||||||
$rows = $dbt->update_record($dbh,$update_pos,$ctpos);
|
$rows = $dbt->update_record($dbh,$update_pos,$ctpos);
|
||||||
print FILE "<--- rows: $rows, update_pos: $ctpos->{c_id}, with:" . Dumper($update_pos) . "\n";
|
print FILE "<--- rows: $rows, update_pos: $ctpos->{c_id}, with:" . Dumper($update_pos) . "\n";
|
||||||
|
|
||||||
|
if($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";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
close(FILE);
|
close(FILE);
|
||||||
|
|
|
@ -625,7 +625,7 @@ sub collect_post(){
|
||||||
}elsif($key =~ /^(c_id|ca_id|ct_id|owner|barcode|int\d+)$/ && $value){
|
}elsif($key =~ /^(c_id|ca_id|ct_id|owner|barcode|int\d+)$/ && $value){
|
||||||
$cp_where .= " and cp.$key $op $value";
|
$cp_where .= " and cp.$key $op $value";
|
||||||
}
|
}
|
||||||
}elsif($key eq "int10" && $value eq "('3','2')"){
|
}elsif($key eq "int10" && $value eq "('3','2')" && $fetch->{station_lock_state}){
|
||||||
#selects also station_lock_state=locking bikes to view once miniquery
|
#selects also station_lock_state=locking bikes to view once miniquery
|
||||||
$cp_where .= " and (cp.$key $op $value OR cp.int28 = 3)";
|
$cp_where .= " and (cp.$key $op $value OR cp.int28 = 3)";
|
||||||
}elsif($key =~ /^(c_id|ca_id|ct_id|owner|barcode|int\d+)$/ && $value){
|
}elsif($key =~ /^(c_id|ca_id|ct_id|owner|barcode|int\d+)$/ && $value){
|
||||||
|
|
|
@ -42,11 +42,11 @@ sub tpl(){
|
||||||
if($users_sharee->{c_id} && $R::sharee_edit ne "delete_account2" && ($users_sharee->{c_id} eq $varenv->{superu_id} || $dbt->{copri_conf}->{stage} eq "test" || $users_sharee->{txt08} eq "sigo\@sharee.bike")){
|
if($users_sharee->{c_id} && $R::sharee_edit ne "delete_account2" && ($users_sharee->{c_id} eq $varenv->{superu_id} || $dbt->{copri_conf}->{stage} eq "test" || $users_sharee->{txt08} eq "sigo\@sharee.bike")){
|
||||||
my $coo = $q->cookie('domcookie') || $q->param('sessionid') || "";
|
my $coo = $q->cookie('domcookie') || $q->param('sessionid') || "";
|
||||||
|
|
||||||
#my $api_test = "sharee_fr01"; my $bike="FR1538";
|
my $api_test = "sharee_fr01"; my $bike="FR1538";
|
||||||
#my $api_test = "sharee_fr01"; my $bike="FR4781";#Tracking and BVB test
|
#my $api_test = "sharee_fr01"; my $bike="FR4781";#Tracking and BVB test
|
||||||
#my $api_test = "sharee_kn"; my $bike="KN205";
|
#my $api_test = "sharee_kn"; my $bike="KN205";
|
||||||
#my $api_test = "sharee_wue"; my $bike="WUE5524";
|
#my $api_test = "sharee_wue"; my $bike="WUE5524";
|
||||||
my $api_test = "sharee_sx"; my $bike="S3X1001";
|
#my $api_test = "sharee_sx"; my $bike="S3X1001";
|
||||||
#my $api_test = "sharee_ren"; my $bike="REN2";
|
#my $api_test = "sharee_ren"; my $bike="REN2";
|
||||||
|
|
||||||
print $q->div({-style=>'float:right;text-align:right;height:25px;padding:6px 15px;background-color:white'},$q->a({-style=>"background-color:#ffffff;color:#$bgcolor1;", -href=>"$varenv->{metahost}/src/scripts/tests/index.pl?sessionid=$coo\&api_test=$api_test\&bike=$bike", -target=>'_blank'}," [ tests --> $api_test ] "),"$users_sharee->{txt08}",$q->a({-style=>"color:#$bgcolor1;", -href=>"logout_sharee$session"},"logout")),"\n";
|
print $q->div({-style=>'float:right;text-align:right;height:25px;padding:6px 15px;background-color:white'},$q->a({-style=>"background-color:#ffffff;color:#$bgcolor1;", -href=>"$varenv->{metahost}/src/scripts/tests/index.pl?sessionid=$coo\&api_test=$api_test\&bike=$bike", -target=>'_blank'}," [ tests --> $api_test ] "),"$users_sharee->{txt08}",$q->a({-style=>"color:#$bgcolor1;", -href=>"logout_sharee$session"},"logout")),"\n";
|
||||||
|
|
Loading…
Add table
Reference in a new issue