mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-05-15 08:06:27 +02:00
station tour, operator hotline and 24h SMS
This commit is contained in:
parent
ec59942964
commit
df954371f2
10 changed files with 170 additions and 106 deletions
|
@ -3,8 +3,13 @@
|
|||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
|
||||
#
|
||||
#SMS message if 24h,48h,72h occupied
|
||||
#sudo su www-data -c "./src/scripts/sms_message.pl shareedms-fr01 '24h_occupied' '' ''"
|
||||
#
|
||||
#SMS message locking_progress after 45sec
|
||||
#sudo su www-data -c "./src/scripts/sms_message.pl shareeapp-operator locking_progress '0179xxxx372' $pos_id"
|
||||
#
|
||||
#
|
||||
use vars qw($syshost);
|
||||
|
||||
BEGIN {
|
||||
|
@ -16,6 +21,10 @@ use lib "/var/www/copri-bike/$syshost/src";
|
|||
use strict;
|
||||
use warnings;
|
||||
use POSIX;
|
||||
use DateTime;
|
||||
use DateTime::Format::Pg;
|
||||
use Data::Dumper;
|
||||
|
||||
use Mod::DBtank;
|
||||
use Mod::SMSTransport;
|
||||
|
||||
|
@ -23,11 +32,70 @@ my $dbt = new DBtank;
|
|||
my $smstrans = new SMSTransport;
|
||||
|
||||
my $todo = $ARGV[1] || die 'todo not defined';
|
||||
my $phone = $ARGV[2] || die 'phone not defined';
|
||||
my $pos_id = $ARGV[3] || die 'no booking id available';
|
||||
my $phone = $ARGV[2] || "";
|
||||
my $pos_id = $ARGV[3] || "";
|
||||
my $dbh = "";
|
||||
|
||||
if($todo eq "locking_progress"){
|
||||
#operator contact
|
||||
my $pref_cc = {
|
||||
table => "contentuser",
|
||||
fetch => "one",
|
||||
template_id => "197",
|
||||
c_id => 1,
|
||||
};
|
||||
my $record_cc = { c_id => 0 };
|
||||
$record_cc = $dbt->fetch_record($dbh,$pref_cc);
|
||||
my $hotline = "";
|
||||
$record_cc->{txt07} =~ s/\s//g;
|
||||
$hotline = "Hotline $record_cc->{txt01} $record_cc->{txt07}";
|
||||
|
||||
|
||||
#SMS message if 24h,48h,72h occupied
|
||||
if($todo eq "24h_occupied"){
|
||||
#select booking pos if state=occupied and start_time > 24h
|
||||
my $search = {
|
||||
table => "contenttranspos",
|
||||
int10 => 3,
|
||||
start_time_interval => "(now() - interval '1 day')",
|
||||
};
|
||||
|
||||
my $dt1 = DateTime->now(time_zone => "Europe/Berlin");
|
||||
|
||||
my $cttpos = { c_id => 0 };
|
||||
$cttpos = $dbt->collect_transpos($dbh,$search);
|
||||
|
||||
foreach my $pid (sort { $cttpos->{$b}->{end_time} cmp $cttpos->{$a}->{end_time} } keys(%$cttpos)){
|
||||
if($cttpos->{$pid}->{int10} == 3){
|
||||
my $dt2 = "";
|
||||
$dt2 = DateTime::Format::Pg->parse_datetime($cttpos->{$pid}->{start_time});
|
||||
my $dt2_24h_occupied = $dt2->add( days => 1 );
|
||||
$dt2 = DateTime::Format::Pg->parse_datetime($cttpos->{$pid}->{start_time});
|
||||
my $dt2_48h_occupied = $dt2->add( days => 2 );
|
||||
$dt2 = DateTime::Format::Pg->parse_datetime($cttpos->{$pid}->{start_time});
|
||||
my $dt2_72h_occupied = $dt2->add( days => 3 );
|
||||
#print $dt1 . ">=" . $dt2_72h_occupied . "|" . $dt1 . ">=" . $dt2_48h_occupied . "|" . $dt1 . ">=" . $dt2_24h_occupied . "\n";
|
||||
if($dt2){
|
||||
if($dt1 >= $dt2_72h_occupied){
|
||||
$todo = "72h_occupied";
|
||||
$smstrans->sms_message($dt1 >= $dt2_72h_occupied,$todo,$hotline,$cttpos->{$pid}->{phone},$cttpos->{$pid}->{ct_name});
|
||||
print $dt1 . ">=" . $dt2_72h_occupied . "|$todo,$hotline,$cttpos->{$pid}->{phone},$cttpos->{$pid}->{ct_name}\n";
|
||||
}elsif($dt1 >= $dt2_48h_occupied){
|
||||
$todo = "48h_occupied";
|
||||
$smstrans->sms_message($todo,$hotline,$cttpos->{$pid}->{phone},$cttpos->{$pid}->{ct_name});
|
||||
print $dt1 . ">=" . $dt2_48h_occupied . "|$todo,$hotline,$cttpos->{$pid}->{phone},$cttpos->{$pid}->{ct_name}\n";
|
||||
}elsif($dt1 >= $dt2_24h_occupied){
|
||||
$todo = "24h_occupied";
|
||||
$smstrans->sms_message($todo,$hotline,$cttpos->{$pid}->{phone},$cttpos->{$pid}->{ct_name});
|
||||
print $dt1 . ">=" . $dt2_24h_occupied . "|$todo,$hotline,$cttpos->{$pid}->{phone},$cttpos->{$pid}->{ct_name}\n";
|
||||
}
|
||||
}
|
||||
sleep 1;
|
||||
}
|
||||
}
|
||||
}#end
|
||||
|
||||
#SMS message locking_progress after 45sec
|
||||
if($todo eq "locking_progress" && $phone && $pos_id){
|
||||
sleep 45;
|
||||
#select booking pos if lock_state=locking still set
|
||||
my $booking_pos = {
|
||||
|
@ -39,7 +107,6 @@ if($todo eq "locking_progress"){
|
|||
my $booking = { c_id => 0 };
|
||||
$booking = $dbt->fetch_tablerecord($dbh,$booking_pos);
|
||||
if($booking->{int20} == 3){
|
||||
$smstrans->sms_message($phone,$booking->{ct_name});
|
||||
$smstrans->sms_message($todo,$hotline,$phone,$booking->{ct_name});
|
||||
}
|
||||
|
||||
}
|
||||
}#end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue