mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-02-23 04:06:27 +01:00
stations_available bike_count
This commit is contained in:
parent
882f848355
commit
cf476a2154
2 changed files with 48 additions and 21 deletions
|
@ -2259,6 +2259,21 @@ sub stations_available(){
|
||||||
my $record = {};
|
my $record = {};
|
||||||
$record = $dbt->fetch_record($dbh,$pref,$pref_sql) if(ref($bike_node) eq "ARRAY" && @{$bike_node}[0]);
|
$record = $dbt->fetch_record($dbh,$pref,$pref_sql) if(ref($bike_node) eq "ARRAY" && @{$bike_node}[0]);
|
||||||
|
|
||||||
|
#bike_count
|
||||||
|
my $bpref = {
|
||||||
|
table => "content",
|
||||||
|
fetch => "all",
|
||||||
|
keyfield => "barcode",
|
||||||
|
template_id => "205",
|
||||||
|
int10 => "1",
|
||||||
|
};
|
||||||
|
my $record_bikes = {};
|
||||||
|
$record_bikes = $dbt->fetch_record($dbh,$bpref,"");
|
||||||
|
|
||||||
|
#user_rental_count
|
||||||
|
my $record_rentals = {};
|
||||||
|
$record_rentals = $self->user_bikes_occupied($q,$auth,"") if($auth->{c_id});
|
||||||
|
|
||||||
my $hotline_hash = {
|
my $hotline_hash = {
|
||||||
table => "contentuser",
|
table => "contentuser",
|
||||||
fetch => "one",
|
fetch => "one",
|
||||||
|
@ -2270,6 +2285,23 @@ sub stations_available(){
|
||||||
|
|
||||||
my $op_return = {};
|
my $op_return = {};
|
||||||
foreach my $id (sort { $record->{$a}->{barcode} <=> $record->{$b}->{barcode} } keys (%$record)){
|
foreach my $id (sort { $record->{$a}->{barcode} <=> $record->{$b}->{barcode} } keys (%$record)){
|
||||||
|
my $bike_count = 0;
|
||||||
|
foreach my $b_id (keys (%$record_bikes)){
|
||||||
|
if($record->{$id}->{int04} == $record_bikes->{$b_id}->{int04}){
|
||||||
|
$bike_count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$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";
|
||||||
|
$return->{$id}->{uri_operator} = "$varenv->{wwwhost}";
|
||||||
|
|
||||||
$return->{$id}->{authed} = "$authed";
|
$return->{$id}->{authed} = "$authed";
|
||||||
$return->{$id}->{capacity} = "$record->{$id}->{int05}" || "1";
|
$return->{$id}->{capacity} = "$record->{$id}->{int05}" || "1";
|
||||||
|
|
||||||
|
@ -2279,8 +2311,6 @@ sub stations_available(){
|
||||||
($return->{$id}->{gps}->{latitude},$return->{$id}->{gps}->{longitude}) = split(/,/,$record->{$id}->{txt06});
|
($return->{$id}->{gps}->{latitude},$return->{$id}->{gps}->{longitude}) = split(/,/,$record->{$id}->{txt06});
|
||||||
my $description = $q->unescapeHTML($record->{$id}->{txt01}) || "";
|
my $description = $q->unescapeHTML($record->{$id}->{txt01}) || "";
|
||||||
$return->{$id}->{description} = "$description";
|
$return->{$id}->{description} = "$description";
|
||||||
#$return->{$id}->{description} = Encode::encode('utf-8', Encode::decode('iso-8859-1', $description));
|
|
||||||
|
|
||||||
$return->{$id}->{state} = "$dbt->{copri_conf}->{bike_state}->{$record->{$id}->{int10}}";
|
$return->{$id}->{state} = "$dbt->{copri_conf}->{bike_state}->{$record->{$id}->{int10}}";
|
||||||
$return->{$id}->{gps_radius} = "$record->{$id}->{int06}";
|
$return->{$id}->{gps_radius} = "$record->{$id}->{int06}";
|
||||||
$return->{$id}->{station_group} = "";
|
$return->{$id}->{station_group} = "";
|
||||||
|
|
|
@ -662,16 +662,12 @@ 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";
|
||||||
}
|
}
|
||||||
#}
|
|
||||||
#selects also push event=RENTAL_END station_lock_state bikes to view feedback and miniquery
|
|
||||||
#elsif($key eq "int10" && $value eq "('3','2')" && $fetch->{show_dialog}){
|
|
||||||
# $cp_where .= " and (cp.$key $op $value OR cp.int28 = 3)";#select only if no dialog saved
|
|
||||||
}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($fetch->{catch} && $key eq "template_id" && $value){
|
}elsif($fetch->{catch} && $key eq "template_id" && $value){
|
||||||
$cp_where .= " and cp.$key $op $value";
|
$cp_where .= " and cp.$key $op $value";
|
||||||
}elsif(!$fetch->{catch} && $key =~ /main_id|template_id/ && $value){
|
#}elsif(!$fetch->{catch} && $key =~ /main_id|template_id/ && $value){
|
||||||
$ct_where .= " and rel.$key $op $value";
|
#$ct_where .= " and rel.$key $op $value";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -685,7 +681,8 @@ sub collect_post(){
|
||||||
$sth = $dbh->prepare($sql);
|
$sth = $dbh->prepare($sql);
|
||||||
}else{
|
}else{
|
||||||
#rental pos with capture booking ct.state
|
#rental pos with capture booking ct.state
|
||||||
$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
|
#$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
|
||||||
|
$sql = "SELECT cp.*, ct.state FROM $fetch->{table_pos} cp, $fetch->{table} ct WHERE $cp_where and cp.ct_id=ct.c_id and $ct_where order by cp.mtime ASC";#mtime aufsteigend get last (newest) entry
|
||||||
$sth = $dbh->prepare($sql);
|
$sth = $dbh->prepare($sql);
|
||||||
}
|
}
|
||||||
#$bw->log("DBtank collect_post ",$sql,"") if($debug);
|
#$bw->log("DBtank collect_post ",$sql,"") if($debug);
|
||||||
|
|
Loading…
Add table
Reference in a new issue