2021-12-30 12:05:56 +01:00
package Calorin ;
#
#
# SPDX-License-Identifier: AGPL-3.0-or-later
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
#
use strict ;
use warnings ;
use POSIX ;
use CGI ;
use CGI::Carp qw( fatalsToBrowser ) ;
use CGI ':standard' ;
2022-10-05 12:36:02 +02:00
use Scalar::Util qw( looks_like_number ) ;
2021-12-30 12:05:56 +01:00
use Calendar::Simple ;
use Date::Calc qw( :all ) ;
use Lib::Config ;
use Mod::Buttons ;
use Mod::Libenz ;
use Mod::Callib ;
use Mod::DBtank ;
use Mod::APIfunc ;
use Mod::Pricing ;
use Data::Dumper ;
sub new {
my $ class = shift ;
my $ self = { } ;
bless ( $ self , $ class ) ;
return $ self ;
}
#Template
sub tpl () {
my ( $ node_meta , $ users_dms , $ u_group , $ return ) = @ _ ;
my $ q = new CGI ;
my $ cf = new Config ;
my $ lb = new Libenz ;
my $ but = new Buttons ;
my $ cb = new Callib ;
my $ apif = new APIfunc ;
my $ dbt = new DBtank ;
my $ pri = new Pricing ;
my $ lang = "de" ;
2022-12-19 19:00:27 +01:00
my @ tpl_order = ( 'c_id=ID=5=Datensatz ID (nur intern)' , 'date_time=Mietzeit' , 'txt08=Name=15' , 'int06=Start Station=5' , 'int04=End Station=5' , 'barcode=Bike Nr.=5' , 'int12=Group=select' , 'int10=Rental State=select' , 'int20=Lock State=select' , 'owner=User=select' , 'txt23=Comment=15' ) ;
2022-06-02 10:34:03 +02:00
2021-12-30 12:05:56 +01:00
my % varenv = $ cf - > envonline ( ) ;
my % ib = $ but - > ibuttons ( ) ;
my $ script = $ q - > script_name ( ) ;
my $ path_info = $ q - > path_info ( ) ;
my $ path = $ path_info ;
#with meta_host,
if ( "$varenv{metahost}" ) {
$ path = "$script" . "$path_info" ;
$ script = "" ;
}
$ path =~ s/\/user|\/manager|\/admin// ;
my $ now_time = strftime "%Y-%m-%d %H:%M" , localtime ;
2022-11-16 21:22:00 +01:00
my $ dbh_primary = $ dbt - > dbconnect_extern ( $ dbt - > { primary } - > { sharee_primary } - > { database } - > { dbname } ) ;
2022-06-30 18:23:39 +02:00
my $ users_dms_primary = { u_id = > 0 } ;
2022-11-28 18:28:06 +01:00
$ users_dms_primary = $ dbt - > select_users ( $ dbh_primary , $ users_dms - > { u_id } , "" ) ;
2022-06-30 18:23:39 +02:00
2021-12-30 12:05:56 +01:00
my $ table = "contenttrans" ;
my $ u_name = $ q - > escapeHTML ( "$R::u_name" ) ;
my $ dbh = "" ;
my $ channel_map = $ dbt - > channel_map ( ) ;
my $ mapref = { } ;
my $ ct_users = $ dbt - > users_map ( $ dbh , $ mapref ) ; #get serviceAPP and DMS users from contentadr
my @ _users = ( ":user" ) ;
foreach my $ id ( sort { $ channel_map - > { $ a } cmp $ channel_map - > { $ b } } keys ( %$ channel_map ) ) {
push ( @ _users , "$id:$channel_map->{$id}" ) ;
if ( $ channel_map - > { $ id } eq $ R:: s_owner ) {
#$searchref->{owner} = $id;
#$s_u_name = $channel_map->{$id};
}
}
if ( 1 == 1 ) {
foreach my $ ctu_id ( sort { $ ct_users - > { $ a } - > { txt01 } cmp $ ct_users - > { $ b } - > { txt01 } } keys ( %$ ct_users ) ) {
push ( @ _users , "$ct_users->{$ctu_id}->{c_id}:$ct_users->{$ctu_id}->{txt01}" ) ;
if ( $ ct_users - > { $ ctu_id } - > { ct_name } && ( $ ct_users - > { $ ctu_id } - > { txt01 } =~ /$R::s_owner/i ) ) {
#$searchref->{owner} = $ct_users->{$ctu_id}->{c_id};
#$s_u_name = $ct_users->{$ctu_id}->{txt01};
}
}
}
2022-12-19 19:00:27 +01:00
my $ bnode = { #template_id => 205,#Leihrad_liste
2021-12-30 12:05:56 +01:00
parent_id = > 200013 , #Waren
fetch = > "all" ,
keyfield = > "main_id" ,
} ;
2022-12-19 19:00:27 +01:00
my $ part_nodes = $ dbt - > fetch_rel4tpl4nd ( $ dbh , $ bnode ) ;
2021-12-30 12:05:56 +01:00
2022-09-15 17:06:08 +02:00
my $ pref_ct = {
table = > "contenttrans" ,
fetch = > "all" ,
keyfield = > "c_id" ,
template_id = > "IN::(209,218)" ,
} ;
my $ ct4rel = { c_id = > 0 } ;
$ ct4rel = $ dbt - > fetch_record ( $ dbh , $ pref_ct ) ;
2021-12-30 12:05:56 +01:00
2022-12-21 15:03:45 +01:00
my $ pref_cc = {
table = > "content" ,
fetch = > "all" ,
keyfield = > "c_id" ,
template_id = > "205" ,
} ;
my $ record_part = { c_id = > 0 } ;
$ record_part = $ dbt - > fetch_record ( $ dbh , $ pref_cc ) ;
my $ pref_st = {
table = > "content" ,
fetch = > "all" ,
keyfield = > "int04" ,
template_id = > "225" ,
} ;
my $ record_st = { c_id = > 0 } ;
$ record_st = $ dbt - > fetch_record ( $ dbh , $ pref_st ) ;
2021-12-30 12:05:56 +01:00
my @ months = $ cb - > monthmap ( ) ;
2022-12-21 15:03:45 +01:00
my $ hh = 0 ;
my $ mm = 0 ;
2021-12-30 12:05:56 +01:00
my $ day = strftime "%d" , localtime ;
my $ day_today = $ day ;
my $ mon = strftime "%m" , localtime ;
my $ mon_today = $ mon ;
my $ year = strftime "%Y" , localtime ;
my $ year_today = $ year ;
( $ year , $ mon , $ day , $ hh , $ mm ) = $ lb - > split_date ( $ users_dms - > { cal_start } ) if ( $ users_dms - > { cal_start } ) ;
print $ q - > end_form ;
print $ q - > start_form ( ) ;
2022-11-21 12:21:39 +01:00
print "<div id='Content4cal' style='min-width: 1400px;'>\n" ;
2021-12-30 12:05:56 +01:00
my $ start_date_time = $ R:: start_date_time ;
my $ end_date_time = $ R:: end_date_time ;
2022-11-14 21:16:22 +01:00
if ( ! $ start_date_time ) {
my ( $ nyear , $ nmon , $ nday ) = Add_Delta_YMD ( $ year , $ mon , 1 , 0 , 0 , - 10 ) ;
$ start_date_time = "$nday.$nmon.$nyear" ;
}
2021-12-30 12:05:56 +01:00
my $ c_date ; my $ start_chck = 0 ; my $ end_chck = 0 ; my $ message ;
if ( $ start_date_time ) {
( $ start_date_time , $ start_chck ) = $ lb - > checkdate ( $ start_date_time ) if ( $ start_date_time ne "%" ) ;
print $ q - > div ( { - style = > 'background-color:white;color:red;' } , "→ Datum Eingabefehler: $start_date_time <<<" ) if ( $ end_chck ) ;
}
if ( $ end_date_time ) {
( $ end_date_time , $ end_chck ) = $ lb - > checkdate ( $ end_date_time ) if ( $ end_date_time ne "%" ) ;
print $ q - > div ( { - style = > 'background-color:white;color:red;' } , "→ Datum Eingabefehler: $end_date_time <<<" ) if ( $ end_chck ) ;
}
if ( ! $ end_date_time ) {
my $ days4month = Days_in_Month ( $ year , $ mon ) ;
$ end_date_time = "$days4month.$mon.$year" ;
}
2022-11-14 21:16:22 +01:00
my $ limit = $ R:: limit || 400 ;
2021-12-30 12:05:56 +01:00
my $ offset = $ R:: offset || "0" ;
2022-11-14 21:16:22 +01:00
if ( $ R:: detail_search && ! $ R:: theft_details ) {
2021-12-30 12:05:56 +01:00
$ limit = 10000 ;
$ offset = 0 ;
}
#backward | forward
if ( $ R:: go eq "backward_list" ) {
$ offset -= $ limit if ( $ offset >= $ limit ) ;
} elsif ( $ R:: go eq "forward_list" ) {
$ offset += $ limit ;
}
2022-10-11 07:00:25 +02:00
my $ c_id = $ R:: cttpos_id || $ R:: c_id || "" ;
2022-06-02 10:34:03 +02:00
my $ cttpos = { } ;
2021-12-30 12:05:56 +01:00
$ R:: ct_ct_name =~ s/\#// ;
my $ search = {
table = > "$node_meta->{ct_table}" ,
2022-06-02 10:34:03 +02:00
limit = > $ q - > escapeHTML ( $ limit ) ,
offset = > $ q - > escapeHTML ( $ offset ) ,
} ;
2022-10-05 12:36:02 +02:00
if ( $ R:: ct_id && looks_like_number ( $ R:: ct_id ) ) {
2022-10-11 07:00:25 +02:00
$ search - > { ct_id } = $ R:: ct_id ;
} elsif ( $ c_id && looks_like_number ( $ c_id ) ) {
$ search - > { cttpos_id } = $ c_id ;
2022-10-02 19:26:08 +02:00
} else {
$ search - > { start_date_time } = "$start_date_time" ;
$ search - > { end_date_time } = "$end_date_time" ;
$ search - > { cttpos_id } = $ q - > escapeHTML ( "$R::cttpos_id" ) ;
$ search - > { txt06 } = $ q - > escapeHTML ( "$R::txt06" ) ;
$ search - > { txt08 } = $ q - > escapeHTML ( "$R::txt08" ) ;
$ search - > { txt23 } = $ q - > escapeHTML ( "$R::txt23" ) ;
$ search - > { int04 } = $ q - > escapeHTML ( "$R::int04" ) ;
$ search - > { int06 } = $ q - > escapeHTML ( "$R::int06" ) ;
$ search - > { int12 } = $ q - > escapeHTML ( "$R::int12" ) ;
$ search - > { int13 } = $ q - > escapeHTML ( "$R::int13" ) ;
$ search - > { cp_ct_name } = $ q - > escapeHTML ( "$R::cp_ct_name" ) ;
$ search - > { int10 } = $ q - > escapeHTML ( "$R::int10" ) ;
$ search - > { int20 } = $ q - > escapeHTML ( "$R::int20" ) ;
$ search - > { barcode } = $ q - > escapeHTML ( "$R::barcode" ) ;
$ search - > { ct_txt06 } = $ q - > escapeHTML ( "$R::ct_txt06" ) ; #PLZ
$ search - > { ct_ct_name } = $ q - > escapeHTML ( "$R::ct_ct_name" ) ;
2022-11-06 18:45:59 +01:00
$ search - > { owner } = $ q - > escapeHTML ( "$R::owner" ) ;
2022-10-02 19:26:08 +02:00
}
2022-06-26 19:27:11 +02:00
2021-12-30 12:05:56 +01:00
if ( ! $ start_chck && ! $ end_chck ) {
if ( $ node_meta - > { ct_table } eq "contenttranspos" ) {
$ cttpos = $ dbt - > collect_transpos ( $ dbh , $ search ) ;
} elsif ( $ node_meta - > { ct_table } eq "contenttheftpos" ) {
2022-11-14 21:16:22 +01:00
#7=get_event alarm
#8=get_position after validate
2022-11-21 12:21:39 +01:00
if ( ! $ R:: theft_details ) {
$ search - > { int10 } = "IN::(7,8)" ;
2023-01-05 18:11:24 +01:00
$ search - > { int03 } = ">::$dbt->{copri_conf}->{theftalarm}->{move_count}" ; #move count
2023-02-10 12:04:30 +01:00
$ search - > { int07 } = ">::$dbt->{copri_conf}->{theftalarm}->{speed}" ; #speed
$ search - > { int08 } = ">::$dbt->{copri_conf}->{theftalarm}->{meter}" ; #meter
#$search->{speedORmeter} = "(cp.int07 > $dbt->{copri_conf}->{theftalarm}->{speed} OR cp.int08 > $dbt->{copri_conf}->{theftalarm}->{meter})";
2022-11-21 12:21:39 +01:00
}
2021-12-30 12:05:56 +01:00
$ cttpos = $ dbt - > collect_theftpos ( $ dbh , $ search ) ;
}
}
2022-09-15 17:06:08 +02:00
print $ q - > div ( { - class = > "copri_header" , - style = > "background-color:$node_meta->{bg_color};" } , "$path" , $ q - > span ( { - style = > "padding:4px 10px;color:white;" } ,
2021-12-30 12:05:56 +01:00
" $months[$mon -1] $year" ,
$ q - > a ( { - class = > "linknav" , - style = > "padding:0 0.5em;" , - title = > "Monat zurück" , - href = > "?cal_delta_start=0:-1:0" } , " ← " ) ,
$ q - > a ( { - class = > "linknav" , - style = > "padding:0 0.5em;" , - title = > "Monat aktuell" , - href = > "?cal_today=1" } , " • " ) ,
$ q - > a ( { - class = > "linknav" , - style = > "padding:0 0.5em;" , - title = > "Monat vorwärts" , - href = > "?cal_delta_start=0:1:0" } , " → " ) ,
"$message"
) ) , "\n" ;
my $ sort_up = "up" ;
my $ sort_down = "down" ;
2022-08-02 09:37:22 +02:00
$ users_dms - > { cal_sort_updown } = "down" if ( ! $ users_dms - > { cal_sort_updown } ) ;
2021-12-30 12:05:56 +01:00
$ sort_up = "<b>$sort_up</b>" if ( $ users_dms - > { cal_sort_updown } eq "up" ) ;
$ sort_down = "<b>$sort_down</b>" if ( $ users_dms - > { cal_sort_updown } eq "down" ) ;
print $ q - > div ( { - style = > 'background-color:silver;height:10px;' } , "" ) , "\n" ;
print $ q - > start_table ( { - style = > "width:100%;" , - border = > '0' , - align = > 'left' , - cellpadding = > '1' , - cellspacing = > '0' } ) ;
print $ q - > Tr ( ) ;
2022-11-14 21:16:22 +01:00
print $ q - > td ( { - style = > "background-color:silver;border-right: solid thin gray;border-bottom: solid thin gray;width:30px;padding:1px 10px;" } , $ but - > singlesubmit1 ( "detail_search" , "search" ) ) , "\n" ;
2021-12-30 12:05:56 +01:00
#1. Search-fields
my $ h = 3 ;
print "<td class='search_line'>\n" ;
2022-09-15 17:06:08 +02:00
#print $q->a({-class=>"sortnav",-href=>"?cal_sort_updown=up\&offset=$offset\&limit=$limit",-title=>'Aufsteigend sortieren'},"$sort_up"),"|",$q->a({-class=>"sortnav",-href=>"?cal_sort_updown=down\&offset=$offset\&limit=$limit",-title=>'Absteigend sortieren'},"$sort_down"),"\n";
2022-11-14 21:16:22 +01:00
print $ but - > checkbox ( "1" , "theft_details" , "$R::theft_details" , "Details" ) if ( $ node_meta - > { ct_table } eq "contenttheftpos" && $ users_dms - > { u_id } == $ dbt - > { copri_conf } - > { superu_id } ) ;
2021-12-30 12:05:56 +01:00
foreach ( @ tpl_order ) {
#$h++;
my ( $ key , $ des , $ size ) = split /=/ , $ _ ;
2022-11-14 21:16:22 +01:00
my $ valxx = $ q - > param ( "$key" ) || "" ;
$ valxx = "" if ( $ R:: base_edit eq "save_pos" && $ key ne "barcode" ) ; #empty search fields, select only bike number
2022-06-26 19:27:11 +02:00
2021-12-30 12:05:56 +01:00
if ( $ key =~ /time/ ) {
$ size = "10px" ;
2022-03-26 10:19:13 +01:00
print $ q - > textfield ( - id = > 'datepicker1' , - class = > 'etxt' , - name = > "start_$key" , - override = > '1' , - default = > "$start_date_time" , - size = > "$size" , - maxlength = > 20 ) , "-" , $ q - > textfield ( - id = > 'datepicker2' , - class = > 'etxt' , - name = > "end_$key" , - override = > '1' , - default = > "$end_date_time" , - size = > "$size" , - maxlength = > 20 ) , "\n" ;
2021-12-30 12:05:56 +01:00
}
elsif ( $ key =~ /owner/ ) {
2022-06-26 19:27:11 +02:00
print $ but - > selector_class ( "$key" , "eselect" , "width:80px;" , $ valxx , @ _users ) , "\n" ;
2021-12-30 12:05:56 +01:00
}
elsif ( $ key =~ /int10/ && "$size" eq "select" ) { # && $node_meta->{tpl_id} == 205){#bike_state
my @ _lock_valxx = ( ":$des" ) ;
while ( my ( $ key , $ value ) = each % { $ dbt - > { copri_conf } - > { bike_state } } ) {
push @ _lock_valxx , "$key:$value" ; #[1:available] ...
}
2022-06-26 19:27:11 +02:00
print $ but - > selector_class ( "$key" , "eselect" , "" , $ valxx , @ _lock_valxx ) , "\n" ;
2021-12-30 12:05:56 +01:00
}
2022-12-19 19:00:27 +01:00
elsif ( $ key =~ /int12/ && "$size" eq "select" ) {
2021-12-30 12:05:56 +01:00
my @ _valxx = ( ":$des" ) ;
2022-12-19 19:00:27 +01:00
foreach my $ rid ( sort { $ part_nodes - > { $ a } - > { node_name } cmp $ part_nodes - > { $ b } - > { node_name } } keys ( %$ part_nodes ) ) {
push ( @ _valxx , "$part_nodes->{$rid}->{main_id}:$part_nodes->{$rid}->{node_name} ($part_nodes->{$rid}->{main_id})" ) if ( $ part_nodes - > { $ rid } - > { main_id } !~ /300006|300016|300026/ ) ;
2021-12-30 12:05:56 +01:00
}
2022-06-26 19:27:11 +02:00
print $ but - > selector_class ( "$key" , "eselect" , "width:100px;" , $ valxx , @ _valxx ) , "\n" ;
2021-12-30 12:05:56 +01:00
}
elsif ( $ key =~ /int20/ && "$size" eq "select" ) { # && $node_meta->{tpl_id} == 205){#lock_state locked/unlocked
my @ _lock_valxx = ( ":$des" ) ;
while ( my ( $ key , $ value ) = each % { $ dbt - > { copri_conf } - > { lock_state } } ) {
push @ _lock_valxx , "$key:$value" ; #[2:unlocked]
}
2022-06-26 19:27:11 +02:00
print $ but - > selector_class ( "$key" , "eselect" , "width:100px;" , $ valxx , @ _lock_valxx ) , "\n" ;
2021-12-30 12:05:56 +01:00
}
else {
$ size = "9px" if ( $ key =~ /int/ ) ;
2022-07-04 15:30:17 +02:00
if ( $ key =~ /ct_name|barcode/ ) {
2022-06-28 13:50:59 +02:00
print $ q - > textfield ( - class = > 'stxt2' , - name = > "$key" , - default = > "$valxx" , - size = > "$size" , - override = > '1' , - maxlength = > 40 , - placeholder = > "$des" , - autofocus = > 1 ) , "\n" ;
2021-12-30 12:05:56 +01:00
} else {
2022-06-28 13:50:59 +02:00
print $ q - > textfield ( - class = > 'stxt2' , - name = > "$key" , - default = > "$valxx" , - size = > "$size" , - override = > '1' , - maxlength = > 40 , - placeholder = > "$des" ) , "\n" ;
2021-12-30 12:05:56 +01:00
}
}
}
print "</td>\n" ;
my ( $ daymarker , $ raster_mmpx , $ day4month ) = $ lb - > month_line ( $ users_dms ) ;
print $ q - > Tr ( ) ;
print $ q - > td ( { - class = > 'element' , - style = > "height:1.5em;padding:0;border:0px solid green;" , - colspan = > "$h" , - nowrap = > "1" } , "$day4month" ) , "\n" ;
###
###Calendar Content
2022-09-15 17:06:08 +02:00
my $ nx = 0 ;
my $ set_style = "" ;
2021-12-30 12:05:56 +01:00
my $ scale_color = $ node_meta - > { bg_color } ;
2022-09-15 17:06:08 +02:00
my $ itime = "" ;
my $ start_time = "" ;
my $ end_time = "" ;
2021-12-30 12:05:56 +01:00
my ( $ year_st , $ mon_st , $ day_st , $ hh_st , $ mm_st ) ;
my ( $ year_en , $ mon_en , $ day_en , $ hh_en , $ mm_en ) ;
my $ nr = 0 ;
my $ i = $ offset || 0 ;
2022-09-15 17:06:08 +02:00
my $ c_left = "14px;" ;
foreach my $ pid ( sort { $ cttpos - > { $ b } - > { c_id } <=> $ cttpos - > { $ a } - > { c_id } } keys ( %$ cttpos ) ) {
2021-12-30 12:05:56 +01:00
$ nr + + ;
$ nx + + ;
2022-09-15 17:06:08 +02:00
$ i + + ;
$ c_left = "7px;" if ( $ i >= 10 ) ;
$ c_left = "0px;" if ( $ i >= 100 ) ;
2021-12-30 12:05:56 +01:00
$ set_style = "background-color:#fcfdfb;" ;
$ set_style = "background-color:#f4f1ee;" if ( $ nx % = 2 ) ;
2022-06-02 10:34:03 +02:00
$ set_style = "background-color:#b6dbe3;" if ( $ R:: c_id && $ R:: c_id == $ cttpos - > { $ pid } - > { c_id } ) ;
2021-12-30 12:05:56 +01:00
my $ trans_style = "padding:0 5px;border: 2px solid #f7ae37;" ;
my $ stamm_style = "padding:0 5px;border: 2px solid #98c13b;" ;
2022-09-15 17:06:08 +02:00
my $ part_style = "padding:0 5px;border: 2px solid #dcd77f;" ;
2021-12-30 12:05:56 +01:00
2022-10-14 08:28:51 +02:00
my ( $ ct_name , $ ct_txt00 , $ ct_txt01 , $ ct_phone , $ c_id4trans , $ tpl_id4trans , $ u_name ) ;
2021-12-30 12:05:56 +01:00
my $ id = $ cttpos - > { $ pid } - > { ct_id } ;
if ( $ ct4rel - > { $ id } - > { c_id } == $ cttpos - > { $ pid } - > { ct_id } ) {
$ ct_name = $ ct4rel - > { $ id } - > { ct_name } ;
$ ct_txt00 = $ ct4rel - > { $ id } - > { txt00 } ;
$ ct_txt01 = $ ct4rel - > { $ id } - > { txt01 } ;
$ ct_phone = $ ct4rel - > { $ id } - > { txt07 } ;
$ c_id4trans = $ ct4rel - > { $ id } - > { c_id } ;
$ tpl_id4trans = $ ct4rel - > { $ id } - > { template_id } ;
$ trans_style . = "background-color:#f7ae37;" if ( $ ct4rel - > { $ id } - > { c_id } == $ users_dms - > { c_id4trans } ) ;
}
2022-09-15 17:06:08 +02:00
if ( $ cttpos - > { $ pid } - > { start_time } ) {
( $ year_st , $ mon_st , $ day_st , $ hh_st , $ mm_st ) = $ lb - > split_date ( $ cttpos - > { $ pid } - > { start_time } ) ;
} else {
( $ year_st , $ mon_st , $ day_st , $ hh_st , $ mm_st ) = $ lb - > split_date ( $ cttpos - > { $ pid } - > { itime } ) ;
}
if ( $ cttpos - > { $ pid } - > { end_time } ) {
( $ year_en , $ mon_en , $ day_en , $ hh_en , $ mm_en ) = $ lb - > split_date ( $ cttpos - > { $ pid } - > { end_time } ) ;
} else {
( $ year_en , $ mon_en , $ day_en , $ hh_en , $ mm_en ) = $ lb - > split_date ( $ cttpos - > { $ pid } - > { itime } ) ;
}
2021-12-30 12:05:56 +01:00
2022-09-15 17:06:08 +02:00
#if($year_st && $mon_st && $day_st && $hh_st && $mm_st && $year_en && $mon_en && $day_en && $hh_en && $mm_en){
if ( 1 == 1 ) {
2021-12-30 12:05:56 +01:00
#generate px for rent scale
my $ start_nr = $ year_st . $ mon_st . $ day_st . $ hh_st . $ mm_st ;
my $ end_nr = $ year_en . $ mon_en . $ day_en . $ hh_en . $ mm_en ;
my $ day_stpx = 0 ;
my $ rent_day_px = 0 ;
2022-09-15 17:06:08 +02:00
my $ time_style = "" ; ;
2021-12-30 12:05:56 +01:00
if ( $ start_nr <= $ end_nr ) {
( $ day_stpx , $ rent_day_px ) = $ lb - > rent_scale ( $ users_dms , $ year_st , $ mon_st , $ day_st , $ hh_st , $ mm_st , $ year_en , $ mon_en , $ day_en , $ hh_en , $ mm_en ) ;
} else {
$ time_style = "color:red;" ;
}
2022-09-15 17:06:08 +02:00
$ itime = $ lb - > time4de ( $ cttpos - > { $ pid } - > { itime } , 1 ) ;
2021-12-30 12:05:56 +01:00
if ( $ cttpos - > { $ pid } - > { start_time } ) {
$ start_time = $ lb - > time4de ( $ cttpos - > { $ pid } - > { start_time } , 1 ) ;
$ end_time = $ lb - > time4de ( $ cttpos - > { $ pid } - > { end_time } , 1 ) ;
2022-09-15 17:06:08 +02:00
} else {
$ start_time = $ lb - > time4de ( $ cttpos - > { $ pid } - > { itime } , 1 ) ;
$ end_time = $ lb - > time4de ( $ cttpos - > { $ pid } - > { itime } , 1 ) ;
2021-12-30 12:05:56 +01:00
}
2022-03-14 17:37:49 +01:00
my $ u_name = $ cttpos - > { $ pid } - > { owner } || "" ;
my $ u_name_end = $ cttpos - > { $ pid } - > { owner_end } || "" ;
2021-12-30 12:05:56 +01:00
foreach my $ ctu_id ( keys ( %$ ct_users ) ) {
2022-03-14 17:37:49 +01:00
if ( $ u_name && $ channel_map - > { $ u_name } ) {
2021-12-30 12:05:56 +01:00
$ u_name = $ channel_map - > { $ u_name } ;
} elsif ( $ cttpos - > { $ pid } - > { owner } eq $ ct_users - > { $ ctu_id } - > { c_id } ) {
$ u_name = $ ct_users - > { $ ctu_id } - > { txt01 } ;
}
2022-03-14 17:37:49 +01:00
if ( $ u_name_end && $ channel_map - > { $ u_name_end } ) {
2021-12-30 12:05:56 +01:00
$ u_name_end = $ channel_map - > { $ u_name_end } ;
} elsif ( $ cttpos - > { $ pid } - > { owner_end } eq $ ct_users - > { $ ctu_id } - > { c_id } ) {
$ u_name_end = $ ct_users - > { $ ctu_id } - > { txt01 } ;
}
}
2022-03-14 17:37:49 +01:00
$ u_name_end = "-" if ( ! $ u_name_end ) ;
2021-12-30 12:05:56 +01:00
#if($ct_name){
if ( 1 == 1 ) {
2022-06-03 06:21:28 +02:00
print "<Tr><td class='element' colspan='$h' style='$set_style;0.91em;padding:0.3em 0 0 0em;'>\n" ;
2021-12-30 12:05:56 +01:00
my $ pos_hash = $ cttpos - > { $ pid } ;
my $ pos_details = "" ;
foreach my $ did ( sort keys ( % { $ pos_hash } ) ) {
$ pos_details . = $ did . " = " . $ pos_hash - > { $ did } . "</br>" if ( $ pos_hash - > { $ did } ) ;
}
2022-09-15 17:06:08 +02:00
my $ pos_id = "ID $cttpos->{$pid}->{c_id}" ;
2021-12-30 12:05:56 +01:00
my $ user_device = "" ;
2022-11-21 12:21:39 +01:00
my $ charge = "" ;
2022-12-16 08:37:05 +01:00
$ charge . = " → lock-charge $cttpos->{$pid}->{int14} %" if ( looks_like_number ( $ cttpos - > { $ pid } - > { int14 } ) ) ;
2023-01-11 06:55:55 +01:00
$ charge . = " → bike-charge $cttpos->{$pid}->{int19} %" if ( looks_like_number ( $ cttpos - > { $ pid } - > { int19 } ) && $ record_part - > { $ cttpos - > { $ pid } - > { cc_id } } - > { energy_id } ) ;
2022-12-06 19:57:49 +01:00
if ( $ users_dms_primary - > { u_id } && $ dbt - > { copri_conf } - > { contributors } && $ users_dms_primary - > { u_id } =~ /$dbt->{copri_conf}->{contributors}/ ) {
2021-12-30 12:05:56 +01:00
$ pos_id = $ q - > div ( { - class = > "popup" , - onclick = > "toggle_box('$pid')" } , "$cttpos->{$pid}->{c_id}" , $ q - > span ( { - class = > "popuptext" , - id = > "$pid" } , "$pos_details" ) ) ;
$ user_device = "" ;
2023-01-05 18:11:24 +01:00
$ user_device . = " → endAck" if ( $ cttpos - > { $ pid } - > { int27 } ) ;
2022-09-15 17:06:08 +02:00
my $ txt26 = $ cttpos - > { $ pid } - > { txt26 } ;
$ txt26 = substr ( $ cttpos - > { $ pid } - > { txt26 } , 0 , 25 ) if ( length ( $ cttpos - > { $ pid } - > { txt26 } ) > 20 ) ;
2022-03-14 17:37:49 +01:00
$ user_device . = " → $txt26" if ( $ txt26 ) ;
2022-09-15 17:06:08 +02:00
my $ txt21 = $ cttpos - > { $ pid } - > { txt21 } ;
$ txt21 = substr ( $ cttpos - > { $ pid } - > { txt21 } , 0 , 50 ) . " ..." if ( length ( $ cttpos - > { $ pid } - > { txt21 } ) > 50 ) ;
#$user_device .= " → $txt21" if($txt21);
2021-12-30 12:05:56 +01:00
}
2022-09-15 17:06:08 +02:00
my $ bikenr = $ cttpos - > { $ pid } - > { barcode } || $ cttpos - > { $ pid } - > { ct_name } ;
2021-12-30 12:05:56 +01:00
my $ status = "$dbt->{copri_conf}->{bike_state}->{$cttpos->{$pid}->{int10}}" || "state failure" ;
$ status = "<span style='color:#c63e3e;'>$dbt->{copri_conf}->{bike_state}->{$cttpos->{$pid}->{int10}}</span>" if ( $ cttpos - > { $ pid } - > { int10 } == 2 || $ cttpos - > { $ pid } - > { int10 } == 3 ) ;
2022-12-21 15:03:45 +01:00
if ( $ cttpos - > { $ pid } - > { int10 } ne $ record_part - > { $ cttpos - > { $ pid } - > { cc_id } } - > { int10 } ) {
2021-12-30 12:05:56 +01:00
$ status = "<span style='border: 1px solid #c63e3e;'>$dbt->{copri_conf}->{bike_state}->{$cttpos->{$pid}->{int10}}</span>" ;
}
2022-11-14 21:16:22 +01:00
my $ lock_state = "" ;
#my $lock_state = "lock failure" if(!$cttpos->{$pid}->{int20});
2021-12-30 12:05:56 +01:00
$ lock_state = "locked" if ( $ cttpos - > { $ pid } - > { int20 } == 1 ) ;
$ lock_state = "<span style='color:#c63e3e;'>unlocked</span>" if ( $ cttpos - > { $ pid } - > { int20 } == 2 ) ;
2022-09-15 17:06:08 +02:00
$ lock_state = "<span style='color:#c63e3e;'>locking</span>" if ( $ cttpos - > { $ pid } - > { int20 } == 3 ) ;
$ lock_state = "<span style='color:#c63e3e;'>unlocking</span>" if ( $ cttpos - > { $ pid } - > { int20 } == 4 ) ;
2022-12-21 15:03:45 +01:00
if ( $ cttpos - > { $ pid } - > { int20 } && $ cttpos - > { $ pid } - > { int20 } ne $ record_part - > { $ cttpos - > { $ pid } - > { cc_id } } - > { int20 } ) {
2022-03-14 17:37:49 +01:00
$ lock_state = "<span style='border: 1px solid #c63e3e;'>$dbt->{copri_conf}->{lock_state}->{$cttpos->{$pid}->{int20}}</span>" ;
}
2021-12-30 12:05:56 +01:00
my $ track_info = "" ;
my $ co2saving = "" ;
if ( $ cttpos - > { $ pid } - > { int26 } ) {
$ co2saving = $ pri - > co2calc ( $ cttpos - > { $ pid } ) ;
$ cttpos - > { $ pid } - > { int26 } =~ s/\./,/ ;
2022-11-21 12:21:39 +01:00
$ track_info = "→ $co2saving kg CO² ($cttpos->{$pid}->{int26} km)" ;
2021-12-30 12:05:56 +01:00
}
2022-11-09 15:17:55 +01:00
2022-12-06 19:57:49 +01:00
my $ edit_pos = $ q - > a ( { - class = > "editboo" , - href = > "?base_edit=transpos\&c_id=$cttpos->{$pid}->{c_id}\&owner=$users_dms->{u_id}" , - title = > "Position bearbeiten ($cttpos->{$pid}->{c_id})" } , $ q - > span ( { - class = > "bi bi-file-earmark-text-fill" , - style = > 'font-size:1.6em;' } ) ) ;
2022-12-19 19:00:27 +01:00
my $ part_path = "" ;
$ part_path = $ part_nodes - > { $ cttpos - > { $ pid } - > { int12 } } - > { node_name } if ( $ cttpos - > { $ pid } - > { int12 } ) ;
2022-12-21 15:03:45 +01:00
$ bikenr = $ q - > a ( { - class = > "linknav3" , - style = > "$stamm_style" , - href = > "/DMS/Waren/$part_path?detail_search=1&s_barcode=$cttpos->{$pid}->{barcode}" , - title = > "$cttpos->{$pid}->{txt01} | Artikel im Warenstamm" } , "$bikenr" ) if ( $ cttpos - > { $ pid } - > { cc_id } ) ;
2021-12-30 12:05:56 +01:00
if ( $ node_meta - > { ct_table } eq "contenttranspos" ) {
my $ start_station = "$cttpos->{$pid}->{int06}" ;
my $ end_station = "$cttpos->{$pid}->{int04}" ;
2022-12-21 15:03:45 +01:00
$ start_station = $ q - > a ( { - class = > "linknav3" , - style = > "" , - href = > "/DMS/Waren/?detail_search=1&s_int04=$cttpos->{$pid}->{int06}" , - title = > "$record_st->{$cttpos->{$pid}->{int06}}->{txt01} | Warenstamm nach Station filtern" } , "$cttpos->{$pid}->{int06}" ) if ( $ record_part - > { $ cttpos - > { $ pid } - > { cc_id } } - > { rel_id } ) ;
$ end_station = $ q - > a ( { - class = > "linknav3" , - style = > "" , - href = > "/DMS/Waren/?detail_search=1&s_int04=$cttpos->{$pid}->{int04}" , - title = > "$record_st->{$cttpos->{$pid}->{int04}}->{txt01} | Warenstamm nach Station filtern" } , "$cttpos->{$pid}->{int04}" ) if ( $ record_part - > { $ cttpos - > { $ pid } - > { cc_id } } - > { rel_id } ) ;
2022-09-15 17:06:08 +02:00
my $ comment = $ cttpos - > { $ pid } - > { txt23 } ;
$ comment = substr ( $ cttpos - > { $ pid } - > { txt23 } , 0 , 50 ) . " ..." if ( length ( $ cttpos - > { $ pid } - > { txt23 } ) > 50 ) ;
2022-11-21 12:21:39 +01:00
my $ comment_view = "" ;
$ comment_view = "→ $comment" if ( $ comment ) ;
2022-06-30 18:23:39 +02:00
my $ kunde = "$cttpos->{$pid}->{txt08}" ;
2022-11-28 18:28:06 +01:00
if ( $ users_dms_primary - > { u_id } && $ users_dms - > { u_id } && $ users_dms - > { int02 } >= 1 ) {
2022-09-15 17:06:08 +02:00
$ kunde = $ q - > a ( { - class = > "linknav3" , - style = > "$part_style" , - href = > "/DMS/Kunden/?detail_search=1&s_c_id=$cttpos->{$pid}->{ca_id}" , - title = > "Kunde im Kundenstamm" } , "$cttpos->{$pid}->{txt08} ($cttpos->{$pid}->{ca_id})" ) ; #2021-05-24 saves kd name
2022-06-30 18:23:39 +02:00
}
2021-12-30 12:05:56 +01:00
2022-06-02 10:34:03 +02:00
2022-09-15 17:06:08 +02:00
#Gebühren und Gutscheine
if ( $ cttpos - > { $ pid } - > { template_id } && $ cttpos - > { $ pid } - > { template_id } =~ /224|229/ ) {
2022-12-19 19:00:27 +01:00
print $ q - > div ( { - style = > "float:left;margin-left:$c_left" } , "$i) $edit_pos $pos_id → $start_time → $part_path Nr.$bikenr → $kunde → $u_name/$u_name_end $comment_view" ) , "\n" ;
2022-09-15 17:06:08 +02:00
} else {
2022-12-06 19:57:49 +01:00
print $ q - > div ( { - style = > "float:left;margin-left:$c_left" } , "$i) $edit_pos $pos_id → <span style='$time_style'>$start_time – $end_time</span> → $kunde → Start Station $start_station → End Station $end_station → Bike $bikenr $status $lock_state → $u_name/$u_name_end<br /><span style='padding-left:60px;'>$charge $track_info $comment_view</span>" ) , "\n" ;
2022-09-15 17:06:08 +02:00
}
2022-06-02 10:34:03 +02:00
2022-11-28 18:28:06 +01:00
if ( $ users_dms_primary - > { u_id } && $ users_dms - > { u_id } && $ users_dms - > { int03 } >= 1 ) {
2022-09-15 17:06:08 +02:00
print $ q - > div ( { - style = > 'float:left;margin-left:1em;' } , "→ Faktura" , $ q - > a ( { - class = > "linknav3" , - style = > "$trans_style" , - href = > "/DMS/Faktura?ct_trans=open\&c_id4trans=$c_id4trans\&tpl_id4trans=$tpl_id4trans\&kind_of_trans=Faktura\&owner=$users_dms->{owner}" , - title = > "Faktura Terminal öffnen" } , "\#$ct_name" ) ) , "\n" if ( $ c_id4trans && $ tpl_id4trans ) ;
print $ q - > div ( { - style = > 'float:left;margin-left:1em;' } , "$user_device" ) , "\n" ;
2022-06-30 18:23:39 +02:00
}
2021-12-30 12:05:56 +01:00
} elsif ( $ node_meta - > { ct_table } eq "contenttheftpos" ) {
my $ speed = 0 ;
if ( $ cttpos - > { $ pid } - > { int07 } && $ cttpos - > { $ pid } - > { int07 } > 0 ) {
$ speed = $ cttpos - > { $ pid } - > { int07 } * 1.852 ;
$ speed = $ lb - > round_half ( $ speed ) ;
}
my $ event_type = "" ;
2022-11-09 15:17:55 +01:00
my $ meter = $ cttpos - > { $ pid } - > { int08 } ;
$ meter =~ s/\./\,/ ;
2022-11-14 21:16:22 +01:00
if ( $ cttpos - > { $ pid } - > { int01 } && $ cttpos - > { $ pid } - > { int10 } == 7 ) {
$ event_type = "Alarm detected" ;
} elsif ( $ cttpos - > { $ pid } - > { int01 } && $ cttpos - > { $ pid } - > { txt10 } ) {
$ event_type = "statusCode $cttpos->{$pid}->{txt10}" ;
} elsif ( $ cttpos - > { $ pid } - > { int02 } && $ cttpos - > { $ pid } - > { txt06 } ) {
2022-11-09 15:17:55 +01:00
my $ gps2card = $ q - > a ( { - class = > "linknav3" , - href = > "/DMS/Karte?man_gps=$cttpos->{$pid}->{txt06}\&owner=$users_dms->{owner}" , - title = > "Karte öffnen" } , "$cttpos->{$pid}->{txt06}" ) ;
$ event_type = "Alarm movement → GPS $gps2card → speed $speed km/h → distance $meter m " ;
}
2022-11-14 21:16:22 +01:00
if ( $ cttpos - > { $ pid } - > { int20 } ) {
$ lock_state = $ dbt - > { copri_conf } - > { lock_state } - > { $ cttpos - > { $ pid } - > { int20 } } ;
}
print $ q - > div ( { - style = > "float:left;margin-left:$c_left" } , "$i) $pos_id → $end_time → Bike $bikenr $lock_state → $event_type → $u_name" ) , "\n" ;
2021-12-30 12:05:56 +01:00
}
2022-09-15 17:06:08 +02:00
print $ q - > div ( { - style = > "position:absolute;margin-left:$daymarker;border-right: solid thin #009899;height:1.5em;" } , " " ) , "\n" if ( "$mon" eq "$mon_today" ) ;
2021-12-30 12:05:56 +01:00
print $ q - > div ( { - style = > "position:static;margin-left:$day_stpx;width:$rent_day_px;height:1.5em;background-color:$scale_color;" } , " " ) , "\n" ;
print "</td></Tr>\n" ;
}
}
}
print $ q - > end_table ;
###
print "</div>\n" ;
my $ offset_nr = $ offset + $ nr ;
#backward | forward
print $ q - > div ( { - style = > 'float:left;padding:0.5em;' } , "Zeile: $offset - $offset_nr" ) , "\n" ;
2022-09-20 16:13:45 +02:00
print "<div style='float:left;padding:0.5em;'>\n" ;
print $ q - > a ( { - class = > "linknav1" , - href = > "?go=backward_list;offset=$offset;limit=$limit" , - title = > 'backward' } , " ← " ) if ( $ offset >= $ limit ) ;
print $ q - > a ( { - class = > "linknav1" , - href = > "?go=forward_list;offset=$offset;limit=$limit" , - title = > 'forward' } , " →" ) if ( $ nr >= $ limit - 10 ) ;
2021-12-30 12:05:56 +01:00
print "</div>\n" ;
2022-11-14 21:16:22 +01:00
print $ q - > div ( { - style = > 'clear:both;' } , " " ) , "\n" ;
2023-02-10 12:04:30 +01:00
if ( 1 == 2 && $ node_meta - > { ct_table } eq "contenttheftpos" ) {
print $ q - > div ( { - style = > 'text-align:left;text-decoration:underline;padding:0 0.5em;' } , "Legende" ) , "\n" ;
2022-11-14 21:16:22 +01:00
print $ q - > div ( { - style = > 'text-align:left;font-style:italic;padding:0.1em 0.5em;' } , $ q - > span ( { - style = > 'padding:0 0.8em;' , - style = > "color:$node_meta->{bg_color};" } , "Alarm detected:" ) , "Es wurde eine Bewegung (Erschütterung) mit abgeschlossenem Rahmenschloss erkannt" ) , "\n" ;
print $ q - > div ( { - style = > 'text-align:left;font-style:italic;padding:0.1em 0.5em;' } , $ q - > span ( { - style = > 'padding:0 0.8em;' , - style = > "color:$node_meta->{bg_color};" } , "Alarm movement:" ) , "Es wurde eine Fortbewegung mit abgeschlossenem Rahmenschloss erkannt" ) , "\n" ;
}
2021-12-30 12:05:56 +01:00
print $ q - > end_form ;
}
1 ;