mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-05-14 15:46:28 +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
|
@ -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}){
|
||||
|
|
|
@ -512,7 +512,7 @@ elsif($q->param('request') eq "bikes_all"){
|
|||
|
||||
foreach my $id (keys(%{$response_work->{$biselect}})){
|
||||
|
||||
$bw->log("response_work:$biselect","|$id|$response_work->{$biselect}->{$id}->{mtime}|$response_work->{$biselect}->{$id}->{service_type}|$response_work->{$biselect}->{$id}->{time_over}|$response_work->{$biselect}->{$id}->{work_val}","");
|
||||
#$bw->log("response_work:$biselect","|$id|$response_work->{$biselect}->{$id}->{mtime}|$response_work->{$biselect}->{$id}->{service_type}|$response_work->{$biselect}->{$id}->{time_over}|$response_work->{$biselect}->{$id}->{work_val}","");
|
||||
|
||||
#time_over && (service_type || Aufgaben)
|
||||
if(($response_work->{$biselect}->{$id}->{time_over} == 1 && $response_work->{$biselect}->{$id}->{service_type} >= 1) || ($id eq "txt01" && $response_work->{$biselect}->{$id}->{work_val})){
|
||||
|
|
|
@ -1052,15 +1052,22 @@ sub collect_transpos {
|
|||
|
||||
$search->{offset} = 0 if(!$search->{offset});
|
||||
my $updown = "ASC";
|
||||
$updown = "DESC" if($search->{cal_sort_updown} eq "down");
|
||||
$updown = "DESC" if($search->{cal_sort_updown} && $search->{cal_sort_updown} eq "down");
|
||||
|
||||
my $where = "where cp.ct_id=ct.c_id";
|
||||
foreach my $key (%$search){
|
||||
$search->{$key} =~ s/\s//g;
|
||||
foreach my $key (keys (%$search)){
|
||||
$search->{$key} =~ s/\s//g if($key ne "start_time_interval");
|
||||
$where .= " and cp.c_id = $search->{$key}" if($key eq "cttpos_id" && $search->{$key});
|
||||
$where .= " and cp.end_time >= '$search->{$key}'" if($key eq "start_date_time");
|
||||
$where .= " and cp.end_time <= '$search->{$key}'" if($key eq "end_date_time");
|
||||
$where .= " and cp.start_time <= '$search->{$key}'" if($key eq "end_date_time");
|
||||
if($key eq "start_time_interval"){
|
||||
$where .= " and cp.start_time <= $search->{$key}";
|
||||
}
|
||||
if($key eq "start_date_time"){
|
||||
$where .= " and cp.end_time >= '$search->{$key}'";
|
||||
}
|
||||
if($key eq "end_date_time"){
|
||||
$where .= " and cp.end_time <= '$search->{$key}'";
|
||||
$where .= " and cp.start_time <= '$search->{$key}'";
|
||||
}
|
||||
$where .= " and cp.$key ilike '%$search->{$key}%'" if($key eq "txt08" && $search->{$key});
|
||||
$where .= " and (cp.int04 = $search->{$key} OR cp.int06 = $search->{$key})" if($key eq "int04" && looks_like_number($search->{$key}));
|
||||
$where .= " and cp.ct_name = '$search->{$key}'" if($key eq "cp_ct_name" && $search->{$key});
|
||||
|
@ -1072,11 +1079,13 @@ sub collect_transpos {
|
|||
$where .= " and cp.$key = $search->{$key}" if($key eq "int12" && looks_like_number($search->{$key}));#bike_group
|
||||
$where .= " and cp.$key = $search->{$key}" if($key eq "owner" && looks_like_number($search->{$key}));
|
||||
}
|
||||
|
||||
$where .= " ORDER BY cp.end_time $updown LIMIT $search->{limit} OFFSET $search->{offset}" if($search->{limit});
|
||||
my $sth = $dbh->prepare("SELECT cp.* from $search->{table} cp, contenttrans ct $where");
|
||||
my $sql = "SELECT cp.*,ct.txt07 AS phone from $search->{table} cp, contenttrans ct $where";
|
||||
my $sth = $dbh->prepare($sql);
|
||||
my $rc = $sth->execute();
|
||||
my $ct = $sth->fetchall_hashref("c_id");
|
||||
$sth->finish;
|
||||
$bw->log("collect_transpos",$sql,"") if($debug);
|
||||
return $ct;
|
||||
}
|
||||
|
||||
|
@ -1088,10 +1097,10 @@ sub collect_theftpos {
|
|||
|
||||
$search->{offset} = 0 if(!$search->{offset});
|
||||
my $updown = "ASC";
|
||||
$updown = "DESC" if($search->{cal_sort_updown} eq "down");
|
||||
$updown = "DESC" if($search->{cal_sort_updown} && $search->{cal_sort_updown} eq "down");
|
||||
|
||||
my $where = "where 1=1";
|
||||
foreach my $key (%$search){
|
||||
foreach my $key (keys (%$search)){
|
||||
$search->{$key} =~ s/\s//g;
|
||||
$where .= " and cp.c_id = $search->{$key}" if($key eq "cttpos_id" && $search->{$key});
|
||||
$where .= " and cp.end_time >= '$search->{$key}'" if($key eq "start_date_time");
|
||||
|
|
|
@ -532,6 +532,13 @@ print ATTR "next: $next\n" if($debug);
|
|||
$valxx = $q->escapeHTML("@val");
|
||||
$u_rows += $db->updater("$table","c_id",$c_id,$_,$valxx,$users_dms->{u_id});
|
||||
}
|
||||
#txt07 station user_tour multiple select
|
||||
elsif($tpl->{tpl_id} == 225 && $_ eq "txt07"){
|
||||
my @val = $q->param($_);
|
||||
#@txt18 = grep {!/null/} @txt18;
|
||||
$valxx = $q->escapeHTML("@val");
|
||||
$u_rows += $db->updater("$table","c_id",$c_id,$_,$valxx,$users_dms->{u_id});
|
||||
}
|
||||
#txt24 bike_group/station_group multiple select
|
||||
elsif($tpl->{tpl_id} == 225 && $_ eq "txt24"){
|
||||
my @val = $q->param($_);
|
||||
|
|
|
@ -102,6 +102,8 @@ sub sms_ack_digest {
|
|||
#used for sending message if lock_state=locking and after 45 sec no lock_state=locked
|
||||
sub sms_message {
|
||||
my $self = shift;
|
||||
my $todo = shift;
|
||||
my $hotline = shift;
|
||||
my $sms_to = shift;
|
||||
my $bike = shift;
|
||||
|
||||
|
@ -120,7 +122,20 @@ sub sms_message {
|
|||
$sms_tosub =~ s/^0/\+49/;
|
||||
$sms_to = $sms_tosub;
|
||||
}
|
||||
$sms_message .= "Ihre Miete von $bike wurde nicht beendet! Ihre kostenpflichtige Miete läuft weiter! Stellen Sie sicher, dass das Schloss geschlossen ist. Hotline 0761-45370099";
|
||||
if($todo eq "locking_progress"){
|
||||
$sms_message .= "Ihre Miete von $bike wurde nicht beendet! Ihre kostenpflichtige Miete läuft weiter! Stellen Sie sicher, dass das Schloss geschlossen ist. $hotline";
|
||||
}
|
||||
|
||||
if($todo eq "24h_occupied"){
|
||||
$sms_message .= "Zur Info! Sie haben $bike seit 24 Stunden kostenpflichtig gemietet!. $hotline";
|
||||
}
|
||||
if($todo eq "48h_occupied"){
|
||||
$sms_message .= "Zur Info! Sie haben $bike seit 48 Stunden kostenpflichtig gemietet!. $hotline";
|
||||
}
|
||||
if($todo eq "72h_occupied"){
|
||||
$sms_message .= "Zur Info! Sie haben $bike seit 72 Stunden kostenpflichtig gemietet!. $hotline";
|
||||
}
|
||||
|
||||
my $message = Encode::encode('iso-8859-1', Encode::decode('utf-8',"$sms_message"));
|
||||
|
||||
open(FILE,">>$dbt->{copri_conf}->{logdir}/sms_gtx.log");
|
||||
|
@ -134,6 +149,7 @@ sub sms_message {
|
|||
|
||||
print FILE "---> request:\n" . Dumper($request);
|
||||
|
||||
#my $ret_json = "";#$self->get_sms_gtx($request);#for testing without send
|
||||
my $ret_json = $self->get_sms_gtx($request);
|
||||
|
||||
eval {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue