station tour, operator hotline and 24h SMS

This commit is contained in:
Rainer Gümpelein 2022-03-14 17:37:49 +01:00
parent ec59942964
commit df954371f2
10 changed files with 170 additions and 106 deletions

View file

@ -204,43 +204,6 @@ sub service_work_search(){
return $pos_record;
}
#service pre-collect all or with bike/station ID
#obsolte and should be deleted
sub service_work_select(){
my $self = shift;
my $bike = shift || "";
my $station = shift || "";
my $interval = shift || 0;
my $content_template_id = shift || 0;
my $dt1 = DateTime->now;
my $return={};
my $bike_id = $1 if($bike =~ /(\d+)/);
my $station_id = $1 if($station =~ /(\d+)/);
my $pref = {
table => "content",
table_pos => "contentpos",
fetch => "all",
catch => "content_contentpos",
keyfield => "c_id",
template_id => "$content_template_id",
};
if(looks_like_number($bike_id)){
$pref->{barcode} = "=::" . $bike_id;
}
if(looks_like_number($station_id)){
$pref->{int04} = "=::" . $station_id;
}
$pref = { %$pref, mtime => ">=::(now() - interval '$interval day')" } if($interval > 0);
my $pos_record = $dbt->collect_post($dbh,$pref);
return $pos_record;
}#end service_work_select
#service_select by service_id=service-c_id
sub service_select {
my $self = shift;
@ -762,7 +725,7 @@ sub service_work {
$return->{$article}->{$key_change}->{interval} = "$interval";
$return->{$article}->{$key_change}->{time_over} = "$time_over";
$return->{$article}->{$key_change}->{service_type} = "$service_type";
$return->{$article}->{$key_change}->{work_val} = "$pos_record->{$id}->{$key}";
$return->{$article}->{$key_change}->{work_val} .= "$pos_record->{$id}->{$key}\n";
$return->{$article}->{$key_change}->{mtime} = "$pos_record->{$id}->{mtime}";
$return->{$article}->{$key_change}->{user_name} = "$u_name";
$return->{$article}->{$key_change}->{owner} = "$pos_record->{$id}->{owner}";
@ -1665,34 +1628,13 @@ sub stations_available(){
$pref_sql = "" if($pref_sql !~ /\d/);
my $record = {};
#on servicetool only stations on user_tour
#shareetool
if($q->param('authcookie') && $dbt->{merchant_ids}->{$varenv->{merchant_id}}->{id} && $dbt->{merchant_ids}->{$varenv->{merchant_id}}->{id} == 187){
if(scalar(@{$user_tour}) >= 1){
$pref_sql .= " AND (";
foreach(@{$user_tour}){
if($_ =~ /(\d+)/){
$pref_sql .= " ct.int07=$1 OR";
}
}
$pref_sql =~ s/OR$//;
$pref_sql .= ")";
$record = $dbt->fetch_record($dbh,$pref,$pref_sql) if(ref($bike_group) eq "ARRAY" && @{$bike_group}[0]);
}
}else{
$record = $dbt->fetch_record($dbh,$pref,$pref_sql) if(ref($bike_group) eq "ARRAY" && @{$bike_group}[0]);
}
$record = $dbt->fetch_record($dbh,$pref,$pref_sql) if(ref($bike_group) eq "ARRAY" && @{$bike_group}[0]);
my $op_return = {};
foreach my $id (sort { $record->{$a}->{barcode} <=> $record->{$b}->{barcode} } keys (%$record)){
$return->{$id}->{authed} = "$authed";
$return->{$id}->{station} = "$dbt->{operator}->{$varenv->{dbname}}->{oprefix}$record->{$id}->{int04}";
if($record->{$id}->{int07}){
$return->{$id}->{service_tour} = "$dbt->{operator}->{$varenv->{dbname}}->{oprefix}$record->{$id}->{int07}";
}else{
$return->{$id}->{service_tour} = "";
}
$return->{$id}->{uri_operator} = "$varenv->{wwwhost}";
($return->{$id}->{gps}->{latitude},$return->{$id}->{gps}->{longitude}) = split(/,/,$record->{$id}->{txt06});
#$return->{$id}->{description} = "$record->{$id}->{txt01}";
@ -1735,7 +1677,7 @@ sub stations_available(){
}#end stations_available
#stations_all
#stations_all (should only called by shareetool)
sub stations_all(){
my $self = shift;
my $q = shift || "";
@ -1779,6 +1721,9 @@ sub stations_all(){
$pref_sql = "" if($pref_sql !~ /\d/);
my $record = {};
my $op_return = {};
my %user_tour = ();
#on servicetool only stations on user_tour
#shareetool
$bw->log("stations user_tour by merchant id $dbt->{merchant_ids}->{$varenv->{merchant_id}}->{id} on $varenv->{dbname}",$user_tour,"");
@ -1788,20 +1733,19 @@ sub stations_all(){
$pref_sql .= " AND (";
foreach(@{$user_tour}){
if($_ =~ /(\d+)/){
$pref_sql .= " ct.int07=$1 OR";
#$pref_sql .= " ct.int07=$1 OR";
$user_tour{$1} = 1;
$pref_sql .= " ct.txt07 like '%$1%' OR";
}
}
$pref_sql =~ s/OR$//;
$pref_sql .= ")";
$record = $dbt->fetch_record($dbh,$pref,$pref_sql) if(ref($bike_group) eq "ARRAY" && @{$bike_group}[0]);
}
#stations_all only if authenticated
#}else{
#$record = $dbt->fetch_record($dbh,$pref,$pref_sql) if(ref($bike_group) eq "ARRAY" && @{$bike_group}[0]);
}
my $op_return = {};
#only nececarry if amount of available bikes lower then bike_soll (like konrad)
#my $bike_ist_factor = 1;
#$bike_ist_factor = $self->bikes_soll($record,$bikes_on_station);
@ -1813,11 +1757,25 @@ sub stations_all(){
#$bike_soll =~ s/\.\d+//;#rounded integer
$return->{$id}->{authed} = "$authed";
$return->{$id}->{station} = "$dbt->{operator}->{$varenv->{dbname}}->{oprefix}$record->{$id}->{int04}";
if($record->{$id}->{int07}){
$return->{$id}->{service_tour} = "$dbt->{operator}->{$varenv->{dbname}}->{oprefix}$record->{$id}->{int07}";
}else{
$return->{$id}->{service_tour} = "";
$return->{$id}->{service_tour} = "";
#hashed because of one station can have multi station tour
#there is a restriction in servicetool because of service_tour assignment (can keep only one value)
#keep in mind to select only users user_tour which in service_tour,
#because there can only one station assignmemt. Should be array, also in shareetool!
my %station_tour = ();
if($record->{$id}->{txt07} && $record->{$id}->{txt07} =~ /\d\s\d/){
%station_tour = map { $_ => 1 } split(/\s+/,$record->{$id}->{txt07});
}elsif($record->{$id}->{txt07}){
$station_tour{$record->{$id}->{txt07}} = 1;
}
#if multi station tour defined then last numerical will assigend
foreach my $stour (sort { $a <=> $b }keys (%user_tour)){
if($station_tour{$stour}){
$return->{$id}->{service_tour} = "$dbt->{operator}->{$varenv->{dbname}}->{oprefix}$stour";
}
}
$return->{$id}->{uri_operator} = "$varenv->{wwwhost}";
($return->{$id}->{gps}->{latitude},$return->{$id}->{gps}->{longitude}) = split(/,/,$record->{$id}->{txt06});
if($return->{$id}->{description}){