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-10-14 08:28:51 +02: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=Flotte=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-06-30 18:23:39 +02:00
my $ dbh_primary = $ dbt - > dbconnect_extern ( "sharee_primary" ) ;
my $ users_dms_primary = { u_id = > 0 } ;
$ users_dms_primary = $ dbt - > select_users ( $ dbh_primary , $ users_dms - > { u_id } , "and int03=2" ) ;
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};
}
}
}
my $ bnode = { template_id = > 205 , #Leihrad_liste
parent_id = > 200013 , #Waren
fetch = > "all" ,
keyfield = > "main_id" ,
} ;
my $ bike_nodes = $ dbt - > fetch_rel4tpl4nd ( $ dbh , $ bnode ) ;
2022-09-15 17:06:08 +02:00
my $ pref_ct = {
table = > "contenttrans" ,
fetch = > "all" ,
keyfield = > "c_id" ,
template_id = > "IN::(209,218)" ,
} ;
2021-12-30 12:05:56 +01:00
2022-09-15 17:06:08 +02:00
my $ ct4rel = { c_id = > 0 } ;
$ ct4rel = $ dbt - > fetch_record ( $ dbh , $ pref_ct ) ;
2021-12-30 12:05:56 +01:00
my @ months = $ cb - > monthmap ( ) ;
my $ hh ; my $ mm ;
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-09-15 17:06:08 +02:00
print "<div id='Content4cal'>\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 ;
$ start_date_time = "01.$mon.$year" if ( ! $ start_date_time ) ;
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" ;
$ end_date_time = $ cb - > datetime_defaults ( $ end_date_time , "dummy" , $ lang ) ;
}
my $ limit = $ R:: limit || $ varenv { limit } * 2 ; #max. 160 * 2
my $ offset = $ R:: offset || "0" ;
if ( $ R:: detail_search ) {
$ 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" ) {
$ cttpos = $ dbt - > collect_theftpos ( $ dbh , $ search ) ;
}
}
2022-09-15 17:06:08 +02:00
my $ pref_cc = {
table = > "content" ,
fetch = > "all" ,
keyfield = > "c_id" ,
template_id = > "205" ,
} ;
my $ ct4rel_part = { c_id = > 0 } ;
$ ct4rel_part = $ dbt - > fetch_record ( $ dbh , $ pref_cc ) ;
2021-12-30 12:05:56 +01:00
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" ;
my $ hstyle = "border-right: solid thin gray;border-bottom: solid thin gray;" ;
my $ search = "search" ;
my $ edit = "ct_trans" ;
my $ new_key = "new_transdate" ;
print $ q - > start_table ( { - style = > "width:100%;" , - border = > '0' , - align = > 'left' , - cellpadding = > '1' , - cellspacing = > '0' } ) ;
print $ q - > Tr ( ) ;
print $ q - > td ( { - style = > "background-color:silver;$hstyle;width:30px;padding:1px 10px;" } , $ but - > singlesubmit1 ( "detail_search" , "$search" ) ) , "\n" ;
#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";
2021-12-30 12:05:56 +01:00
foreach ( @ tpl_order ) {
#$h++;
my ( $ key , $ des , $ size ) = split /=/ , $ _ ;
2022-10-02 19:26:08 +02:00
my $ valxx = $ q - > param ( "$_" ) || "" ;
#$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
}
elsif ( $ key =~ /int12/ && "$size" eq "select" ) { # && $node_meta->{tpl_id} == 210){#Flotte bike_group (bikenode.main_id)
my @ _valxx = ( ":$des" ) ;
foreach my $ rid ( sort { $ bike_nodes - > { $ a } - > { node_name } cmp $ bike_nodes - > { $ b } - > { node_name } } keys ( %$ bike_nodes ) ) {
push ( @ _valxx , "$bike_nodes->{$rid}->{main_id}:$bike_nodes->{$rid}->{node_name} ($bike_nodes->{$rid}->{main_id})" ) ;
}
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 } ;
my $ edit = "ct_trans" ;
my $ save_key = "save" ;
my $ delete_key = "delete" ;
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 = "" ;
#if($users_dms->{u_id} == $dbt->{copri_conf}->{bike_state}->{superu_id}){
2022-09-15 17:06:08 +02:00
if ( $ users_dms - > { u_id } && $ users_dms - > { u_id } =~ /1842|5781|11765|21618|38883/ ) {
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 = "" ;
$ user_device . = " → lock charge $cttpos->{$pid}->{int14} %" if ( $ cttpos - > { $ pid } - > { int14 } ) ;
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-09-15 17:06:08 +02:00
if ( $ cttpos - > { $ pid } - > { int10 } ne $ ct4rel_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>" ;
}
my $ lock_state = "lock failure" if ( ! $ cttpos - > { $ pid } - > { int20 } ) ;
$ 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 ) ;
if ( $ cttpos - > { $ pid } - > { int20 } ne $ ct4rel_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/\./,/ ;
$ track_info = "→ - $co2saving kg CO² ($cttpos->{$pid}->{int26} km)" ;
}
if ( $ node_meta - > { ct_table } eq "contenttranspos" ) {
my $ start_station = "$cttpos->{$pid}->{int06}" ;
my $ end_station = "$cttpos->{$pid}->{int04}" ;
2022-09-15 17:06:08 +02:00
$ start_station = $ q - > a ( { - class = > "linknav3" , - style = > "" , - href = > "/DMS/Waren/?detail_search=1&s_int04=$cttpos->{$pid}->{int06}" , - title = > "Rad Warenstamm nach Station filtern" } , "$cttpos->{$pid}->{int06}" ) if ( $ ct4rel_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 = > "Rad Warenstamm nach Station filtern" } , "$cttpos->{$pid}->{int04}" ) if ( $ ct4rel_part - > { $ cttpos - > { $ pid } - > { cc_id } } - > { rel_id } ) ;
my $ comment = $ cttpos - > { $ pid } - > { txt23 } ;
$ comment = substr ( $ cttpos - > { $ pid } - > { txt23 } , 0 , 50 ) . " ..." if ( length ( $ cttpos - > { $ pid } - > { txt23 } ) > 50 ) ;
2022-06-30 18:23:39 +02:00
my $ kunde = "$cttpos->{$pid}->{txt08}" ;
if ( $ users_dms_primary - > { u_id } && $ users_dms_primary - > { int03 } == 2 ) {
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-09-15 17:06:08 +02: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" } ) ) ;
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/ ) {
print $ q - > div ( { - style = > "float:left;margin-left:$c_left" } , "$i) $edit_pos $pos_id → $start_time → Nr. $bikenr → $kunde → $u_name/$u_name_end" ) , "\n" ;
} else {
$ bikenr = $ q - > a ( { - class = > "linknav3" , - style = > "$stamm_style" , - href = > "/DMS/Waren/?detail_search=1&s_barcode=$cttpos->{$pid}->{barcode}" , - title = > "Rad im Warenstamm" } , "$bikenr" ) if ( $ cttpos - > { $ pid } - > { cc_id } ) ;
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 $track_info → $u_name/$u_name_end" ) , "\n" ;
#print $q->div({-style=>"float:left;margin-left:$c_left"}, "$i) $edit_pos $pos_id → Start $start_time Station $start_station → End $end_time Station $end_station → Bike $bikenr $status $lock_state $track_info → $kunde → $u_name/$u_name_end"),"\n";
}
2022-06-02 10:34:03 +02:00
2022-06-30 18:23:39 +02:00
if ( $ users_dms_primary - > { u_id } && $ users_dms_primary - > { int03 } == 2 ) {
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
}
2022-09-20 16:13:45 +02:00
print $ q - > div ( { - style = > 'float:left;margin-left:1em;' } , " → $comment" ) , "\n" if ( $ comment ) ;
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 = "" ;
$ event_type = "Diebstahlalarm" if ( $ cttpos - > { $ pid } - > { int01 } ) ;
$ event_type = "GPS $cttpos->{$pid}->{txt06} → speed $speed km/h → distance $cttpos->{$pid}->{int08} Meter" if ( $ cttpos - > { $ pid } - > { int02 } ) ;
2022-09-15 17:06:08 +02:00
print $ q - > div ( { - style = > "float:left;margin-left:$c_left" } , "$i) $pos_id → $end_time → $event_type → Bike $bikenr → $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" ;
print $ q - > end_form ;
}
1 ;