mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-02-22 03:36:30 +01:00
fixing some file links and creating standard dirs. Moving Service-Tour setup to DMS-Account
This commit is contained in:
parent
d6292aa09d
commit
bf83052322
51 changed files with 1275 additions and 436 deletions
8
.gitignore
vendored
8
.gitignore
vendored
|
@ -0,0 +1,8 @@
|
||||||
|
cache/
|
||||||
|
data/
|
||||||
|
pdf/
|
||||||
|
cache/
|
||||||
|
xml/
|
||||||
|
csv/
|
||||||
|
json/
|
||||||
|
site/
|
|
@ -1256,7 +1256,10 @@ sub booking_update(){
|
||||||
$update_cc->{txt13} = "$dbt->{operator}->{$varenv{dbname}}->{oprefix}";
|
$update_cc->{txt13} = "$dbt->{operator}->{$varenv{dbname}}->{oprefix}";
|
||||||
|
|
||||||
#return after booking_update
|
#return after booking_update
|
||||||
|
#in real, we know freed accountable rentals only on rental end's
|
||||||
|
$pri->count_freedrental($q,$varenv,$auth->{c_id},$record_pos);
|
||||||
my ($pricing,$counting) = $pri->counting_rental(\%varenv,$record_pos);
|
my ($pricing,$counting) = $pri->counting_rental(\%varenv,$record_pos);
|
||||||
|
|
||||||
#int03 only used for tarif counting backwards compatibility
|
#int03 only used for tarif counting backwards compatibility
|
||||||
$update_pos->{int03} = "$pricing->{computed_hours}" if(looks_like_number($pricing->{computed_hours}));
|
$update_pos->{int03} = "$pricing->{computed_hours}" if(looks_like_number($pricing->{computed_hours}));
|
||||||
$update_pos->{int38} = "$counting->{int38}" if(looks_like_number($counting->{int38}));
|
$update_pos->{int38} = "$counting->{int38}" if(looks_like_number($counting->{int38}));
|
||||||
|
@ -1264,8 +1267,6 @@ sub booking_update(){
|
||||||
$update_pos->{int40} = "$counting->{int40}" if(looks_like_number($counting->{int40}));
|
$update_pos->{int40} = "$counting->{int40}" if(looks_like_number($counting->{int40}));
|
||||||
$update_pos->{int41} = "$counting->{int41}" if(looks_like_number($counting->{int41}));
|
$update_pos->{int41} = "$counting->{int41}" if(looks_like_number($counting->{int41}));
|
||||||
|
|
||||||
#in real, we know freed accountable rentals only on rental end's
|
|
||||||
$pri->count_freedrental($q,$varenv,$auth->{c_id},$update_pos);
|
|
||||||
$rows_end = $dbt->update_record($dbh,$update_pos,$record_pos);
|
$rows_end = $dbt->update_record($dbh,$update_pos,$record_pos);
|
||||||
|
|
||||||
if($rows_end > 0){
|
if($rows_end > 0){
|
||||||
|
@ -1276,7 +1277,9 @@ sub booking_update(){
|
||||||
|
|
||||||
$geo_debug .= "Matching station: $stations_raw->{$id}->{barcode}|$gps_data->{latitude},$gps_data->{longitude},$latitude_station,$longitude_station --> $gps_data->{geo_distance} Meter\n";
|
$geo_debug .= "Matching station: $stations_raw->{$id}->{barcode}|$gps_data->{latitude},$gps_data->{longitude},$latitude_station,$longitude_station --> $gps_data->{geo_distance} Meter\n";
|
||||||
last;
|
last;
|
||||||
}else{
|
}
|
||||||
|
#out of geofence
|
||||||
|
else{
|
||||||
if($gps_data->{geo_distance} <= $geo_distance_next){
|
if($gps_data->{geo_distance} <= $geo_distance_next){
|
||||||
$geo_distance_next = $gps_data->{geo_distance};
|
$geo_distance_next = $gps_data->{geo_distance};
|
||||||
$station_next = "$dbt->{operator}->{$varenv{dbname}}->{oprefix}$stations_raw->{$id}->{int04}";
|
$station_next = "$dbt->{operator}->{$varenv{dbname}}->{oprefix}$stations_raw->{$id}->{int04}";
|
||||||
|
@ -1302,22 +1305,21 @@ sub booking_update(){
|
||||||
|
|
||||||
$rows_end = $dbt->update_record($dbh,$update_pos,$record_pos);
|
$rows_end = $dbt->update_record($dbh,$update_pos,$record_pos);
|
||||||
|
|
||||||
$geo_debug .= "Out of station distance: $stations_raw->{$id}->{int04}|$gps_data->{latitude},$gps_data->{longitude},$latitude_station,$longitude_station --> $geo_distance_next Meter ($geo_distance_next <= $gps_data->{geo_distance}) station_next: $station_next\n";
|
$geo_debug .= "Out of station distance: $stations_raw->{$id}->{int04}|rows_end:$rows_end|$gps_data->{latitude},$gps_data->{longitude},$latitude_station,$longitude_station --> $geo_distance_next Meter ($geo_distance_next <= $gps_data->{geo_distance}) station_next: $station_next\n";
|
||||||
|
|
||||||
$booking_values->{response_state} = "Failure 2178: bike " . $q->param('bike') . " out of GEO fencing. $geo_distance_next meter distance to next station $station_next .";
|
if($record_pos->{int42} == 1){
|
||||||
$booking_values->{response_text} = "Achtung! Ihr aktueller Standort liegt außerhalb einer Fahrradstation. Die Miete Fahrrad Nr. " . $q->param('bike') . " kann nicht $state_text werden. $geo_distance_next Meter Entfernung zur nächsten Station $station_next . Falls Sie sich doch an einer Station befinden, dann wiederholen Sie \"Miete beenden\".";
|
$booking_values->{response_state} = "Failure 2179: bike " . $q->param('bike') . " out of GEO fencing. $geo_distance_next meter distance to A-A station $station_next .";
|
||||||
|
$booking_values->{response_text} = "Achtung! Dieses Mietrad darf nur an der Station zurück gegeben werden an der es ausgeliehen wurde. Die Miete zu Rad " . $q->param('bike') . " kann nicht $state_text werden. $geo_distance_next Meter Entfernung zur A-A Station $station_next . Falls Sie sich doch an der Station befinden, dann wiederholen Sie \"Miete beenden\".";
|
||||||
|
}else{
|
||||||
|
$booking_values->{response_state} = "Failure 2178: bike " . $q->param('bike') . " out of GEO fencing. $geo_distance_next meter distance to next station $station_next .";
|
||||||
|
$booking_values->{response_text} = "Achtung! Ihr aktueller Standort liegt außerhalb einer für das Mietende freigegebenen Radstation. Die Miete zu Rad " . $q->param('bike') . " kann nicht $state_text werden. $geo_distance_next Meter Entfernung zur nächsten Station $station_next . Falls Sie sich doch an einer Station befinden, dann wiederholen Sie \"Miete beenden\".";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
$geo_debug .= "ERROR no station GPS: $stations_raw->{$id}->{int04}|$gps_data->{latitude},$gps_data->{longitude},$latitude_station,$longitude_station --> $gps_data->{geo_distance} Meter\n";
|
$geo_debug .= "ERROR no station GPS: $stations_raw->{$id}->{int04}|$gps_data->{latitude},$gps_data->{longitude},$latitude_station,$longitude_station --> $gps_data->{geo_distance} Meter\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#$geo_distance_next == 100000 defaults to if no station in stations_raw
|
|
||||||
if($record_pos->{int42} == 0 && !$rows_end && $geo_distance_next == 100000){
|
|
||||||
$geo_distance_next = "undefined";
|
|
||||||
$booking_values->{response_state} = "Failure 2244: this bike not accepted on A-A station, state change forbidden.";
|
|
||||||
$booking_values->{response_text} = "Ein Mietende mit diesem Rad ist an dieser Station nicht erlaubt, da es sich hier um eine sog. A-A Station handelt. An A-A Stationen dürfen nur Mieträder zurück gegeben werden die von dort gemietet wurden.";
|
|
||||||
}
|
|
||||||
$booking_values->{geo_distance} = "$geo_distance_next";
|
$booking_values->{geo_distance} = "$geo_distance_next";
|
||||||
#print "$geo_debug\n";
|
#print "$geo_debug\n";
|
||||||
$bw->log("GEOfencing geo_debug:$geo_debug",$q,"");
|
$bw->log("GEOfencing geo_debug:$geo_debug",$q,"");
|
||||||
|
@ -2540,10 +2542,10 @@ sub fetch_tariff(){
|
||||||
#shareetool user_tour
|
#shareetool user_tour
|
||||||
if($auth_operator->{c_id} && $merchant_id && $dbt->{merchant_ids}->{$merchant_id}->{id} && $dbt->{merchant_ids}->{$merchant_id}->{id} == 187){
|
if($auth_operator->{c_id} && $merchant_id && $dbt->{merchant_ids}->{$merchant_id}->{id} && $dbt->{merchant_ids}->{$merchant_id}->{id} == 187){
|
||||||
my $users_serviceapp = $dbt->select_users($dbh,$auth_operator->{c_id},"and int09=1");
|
my $users_serviceapp = $dbt->select_users($dbh,$auth_operator->{c_id},"and int09=1");
|
||||||
if($users_serviceapp->{int09}){
|
if($users_serviceapp->{int09} && $users_serviceapp->{txt07}){
|
||||||
$auth_operator->{txt18} =~ s/(\d+)/$dbt->{operator}->{$dbname}->{oprefix}$1/g;
|
$users_serviceapp->{txt07} =~ s/(\d+)/$dbt->{operator}->{$dbname}->{oprefix}$1/g;
|
||||||
@user_tour = ($auth_operator->{txt18});
|
@user_tour = ($users_serviceapp->{txt07});
|
||||||
@user_tour = split(/\s/,$auth_operator->{txt18}) if($auth_operator->{txt18} =~ /\s/);
|
@user_tour = split(/\s/,$users_serviceapp->{txt07}) if($users_serviceapp->{txt07} =~ /\s/);
|
||||||
}
|
}
|
||||||
}#end user_tour
|
}#end user_tour
|
||||||
|
|
||||||
|
@ -2557,7 +2559,7 @@ sub fetch_tariff(){
|
||||||
}
|
}
|
||||||
#else select all available user tarif entries
|
#else select all available user tarif entries
|
||||||
$tariff_all = $dbt->fetch_record($dbh,$tariff);
|
$tariff_all = $dbt->fetch_record($dbh,$tariff);
|
||||||
$bw->log("$dbname Tariff type for operator registered user with Tarif $auth_operator->{txt30} by int18:$tariff->{int18} select 4:",$tariff_all,"");
|
$bw->log("$dbname Tariff type for operator registered user with Tarif in txt30:$auth_operator->{txt30} with s-type int18:$tariff->{int18} select 4:",$auth_operator->{txt30},"");
|
||||||
}
|
}
|
||||||
#end operators address
|
#end operators address
|
||||||
else{
|
else{
|
||||||
|
@ -3065,7 +3067,6 @@ sub authorization(){
|
||||||
$pass_name =~ s/\s//g;
|
$pass_name =~ s/\s//g;
|
||||||
my $pwmd5=md5_hex($pass_name) || "";
|
my $pwmd5=md5_hex($pass_name) || "";
|
||||||
my $pwsha256=sha256_base64($pwmd5) || "";
|
my $pwsha256=sha256_base64($pwmd5) || "";
|
||||||
#$authref->{txt11} = "$pwmd5";
|
|
||||||
$authref->{txt04} = "$pwsha256";
|
$authref->{txt04} = "$pwsha256";
|
||||||
|
|
||||||
#Servicetool, only users with users.int09=1
|
#Servicetool, only users with users.int09=1
|
||||||
|
|
|
@ -151,7 +151,7 @@ sub update_operatorsloop {
|
||||||
delete $record_primary->{txt30};#tarifs
|
delete $record_primary->{txt30};#tarifs
|
||||||
delete $record_primary->{txt15};#Bonusnr
|
delete $record_primary->{txt15};#Bonusnr
|
||||||
delete $record_primary->{int07};#Rabatt
|
delete $record_primary->{int07};#Rabatt
|
||||||
delete $record_primary->{txt18};#Service tour
|
delete $record_primary->{int09};#Service App staff
|
||||||
delete $record_primary->{int16};#payone-cron-interval
|
delete $record_primary->{int16};#payone-cron-interval
|
||||||
delete $record_primary->{int19};#Ilockit Admin
|
delete $record_primary->{int19};#Ilockit Admin
|
||||||
#delete $record_primary->{int05};#Web-Login
|
#delete $record_primary->{int05};#Web-Login
|
||||||
|
@ -1049,9 +1049,9 @@ sub insert_contentoid {
|
||||||
delete $insert->{txt17};#operators
|
delete $insert->{txt17};#operators
|
||||||
delete $insert->{txt30};#tarifs
|
delete $insert->{txt30};#tarifs
|
||||||
delete $insert->{txt15};#Bonusnr
|
delete $insert->{txt15};#Bonusnr
|
||||||
delete $insert->{int07};#Rabatt
|
|
||||||
delete $insert->{txt18};#Service tour
|
|
||||||
delete $insert->{int05};#Web-Login
|
delete $insert->{int05};#Web-Login
|
||||||
|
delete $insert->{int07};#Rabatt
|
||||||
|
delete $insert->{int09};#Service App staff
|
||||||
delete $insert->{int16};#payone-cron-interval
|
delete $insert->{int16};#payone-cron-interval
|
||||||
delete $insert->{int19};#Ilockit Admin
|
delete $insert->{int19};#Ilockit Admin
|
||||||
#delete $insert->{int12};#Vde (remove delete for global setting)
|
#delete $insert->{int12};#Vde (remove delete for global setting)
|
||||||
|
@ -1454,7 +1454,7 @@ sub insert_pos(){
|
||||||
my $user_name = $ctadr->{txt01};
|
my $user_name = $ctadr->{txt01};
|
||||||
$user_name = $ctadr->{txt08} if(!$user_name || $user_name eq "no name");
|
$user_name = $ctadr->{txt08} if(!$user_name || $user_name eq "no name");
|
||||||
my $staff = 0;
|
my $staff = 0;
|
||||||
$staff = 1 if($ctadr->{txt18});#service staff (no sms message)
|
$staff = 1 if($ctadr->{int09});#service staff (no sms message)
|
||||||
|
|
||||||
my $deviceId = $ct->{int13} || 0;
|
my $deviceId = $ct->{int13} || 0;
|
||||||
my $bike_charge = $ct->{int19} || 0;
|
my $bike_charge = $ct->{int19} || 0;
|
||||||
|
|
|
@ -345,7 +345,7 @@ sub handler {
|
||||||
}elsif(($R::u_id || $R::c_idadr) && $R::base_edit =~ /_dmsusers/){
|
}elsif(($R::u_id || $R::c_idadr) && $R::base_edit =~ /_dmsusers/){
|
||||||
my $u_id = $1 if($R::u_id && $R::u_id =~ /(\d+)/);
|
my $u_id = $1 if($R::u_id && $R::u_id =~ /(\d+)/);
|
||||||
$u_id = $1 if($R::c_idadr && $R::c_idadr =~ /(\d+)/ && $R::base_edit eq "new_dmsusers");
|
$u_id = $1 if($R::c_idadr && $R::c_idadr =~ /(\d+)/ && $R::base_edit eq "new_dmsusers");
|
||||||
$feedb = $tk->manage_dmsusers($q,\%varenv,$R::base_edit,$u_id,$users_dms);
|
$feedb = $pl->manage_dmsusers($q,\%varenv,$R::base_edit,$u_id,$users_dms);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$feedb->{message} = "failure::Abbruch. Schreibender Zugriff \"DMS-Account\" verweigert.";
|
$feedb->{message} = "failure::Abbruch. Schreibender Zugriff \"DMS-Account\" verweigert.";
|
||||||
|
|
|
@ -380,7 +380,6 @@ sub captureCC_main {
|
||||||
#txt16=txid must be copied from last captured invoice.
|
#txt16=txid must be copied from last captured invoice.
|
||||||
#int01 sum must be set!
|
#int01 sum must be set!
|
||||||
#sequenz = 2
|
#sequenz = 2
|
||||||
#sudo su www-data -c "./src/scripts/payone_post.pl tinkdms refund contenttrans '' 32332 2"
|
|
||||||
sub refund {
|
sub refund {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $varenv = shift;
|
my $varenv = shift;
|
||||||
|
|
|
@ -51,6 +51,86 @@ my %varenv = $cf->envonline();
|
||||||
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
|
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
|
||||||
my $debug=1;
|
my $debug=1;
|
||||||
|
|
||||||
|
#insert/save/delete DMS users
|
||||||
|
sub manage_dmsusers {
|
||||||
|
my $self = shift;
|
||||||
|
my $q = shift;
|
||||||
|
my $varenv = shift;
|
||||||
|
my $base_edit = shift;
|
||||||
|
my $u_id = shift;
|
||||||
|
my $users_dms = shift || {};
|
||||||
|
my $owner = $users_dms->{u_id} || 0;
|
||||||
|
my $table = "users";
|
||||||
|
$q->import_names('R');
|
||||||
|
my @keywords = $q->param;
|
||||||
|
|
||||||
|
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
|
||||||
|
my $feedb = { message => "", i_rows => 0, u_rows => 0, d_rows => 0 };
|
||||||
|
$bw->log("manage_dmsusers",$q,"");
|
||||||
|
|
||||||
|
my $dbh = "";
|
||||||
|
my $adref = {
|
||||||
|
table => "contentadr",
|
||||||
|
fetch => "one",
|
||||||
|
template_id => "202",
|
||||||
|
c_id => "$u_id",
|
||||||
|
};
|
||||||
|
my $ctadr = $dbt->fetch_record($dbh,$adref);
|
||||||
|
|
||||||
|
#users have to be exist only if DMS activated
|
||||||
|
my $uref = {
|
||||||
|
table => "users",
|
||||||
|
fetch => "one",
|
||||||
|
u_id => "$u_id",
|
||||||
|
};
|
||||||
|
my $users = $dbt->fetch_tablerecord($dbh,$uref);
|
||||||
|
|
||||||
|
#datahash on update
|
||||||
|
my $dmsusers = {
|
||||||
|
table => "users",
|
||||||
|
mtime => "now()",
|
||||||
|
owner => "$owner",
|
||||||
|
u_id => "$u_id",
|
||||||
|
};
|
||||||
|
if(ref($users) eq "HASH" && $users->{u_id} && (!$ctadr->{c_id} || $base_edit eq "delete_dmsusers")){
|
||||||
|
$bw->log("delete DMS user from $varenv->{dbname}",$ctadr->{c_id},"");
|
||||||
|
$feedb->{d_rows} = $dbt->delete_content($dbh,"users",$u_id);
|
||||||
|
$dbt->update_one($dbh,$adref,"int07=null");
|
||||||
|
$dbt->update_one($dbh,$adref,"int09=null");
|
||||||
|
}elsif(ref($users) eq "HASH" && $users->{u_id} && $ctadr->{c_id} && $ctadr->{c_id} == $users->{u_id} && $base_edit eq "save_dmsusers"){
|
||||||
|
$bw->log("update DMS user to $varenv->{dbname}",$ctadr->{c_id},"");
|
||||||
|
foreach(@keywords){
|
||||||
|
my $val = $q->param($_);
|
||||||
|
my $valxx = $q->escapeHTML("$val");
|
||||||
|
$valxx =~ s/^\s+//; $valxx =~ s/\s+$//;
|
||||||
|
if($_ =~ /^int\d+/){
|
||||||
|
$valxx =~ s/,/./g;
|
||||||
|
$valxx = 0 if(!looks_like_number($valxx));# set to 0 for using == operator
|
||||||
|
$feedb->{u_rows} = $dbt->update_one($dbh,$dmsusers,"$_=$valxx");
|
||||||
|
if($_ eq "int09"){
|
||||||
|
if($valxx == 1){
|
||||||
|
$dbt->update_one($dbh,$adref,"int09=1");
|
||||||
|
}else{
|
||||||
|
$dbt->update_one($dbh,$adref,"int09=null");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}elsif($_ =~ /^txt\d+/){
|
||||||
|
my @val = $q->param($_);
|
||||||
|
$valxx = $q->escapeHTML("@val");
|
||||||
|
$feedb->{u_rows} = $dbt->update_one($dbh,$dmsusers,"$_='$valxx'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}elsif($ctadr->{c_id} && !$users->{u_id} && $base_edit eq "new_dmsusers"){
|
||||||
|
$bw->log("insert DMS user to $varenv->{dbname}",$ctadr->{c_id},"");
|
||||||
|
$feedb->{i_rows} = $dbt->insert_users($dbh,$ctadr->{c_id},$owner);
|
||||||
|
$dbt->update_one($dbh,$adref,"int07=100");
|
||||||
|
}
|
||||||
|
|
||||||
|
return $feedb;
|
||||||
|
}#end manage_dmsusers
|
||||||
|
|
||||||
|
|
||||||
#insert content or contentuser
|
#insert content or contentuser
|
||||||
sub new_content {
|
sub new_content {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
@ -1014,7 +1094,7 @@ sub set_usertarif {
|
||||||
my $i = 0;
|
my $i = 0;
|
||||||
my $dbh_operator = $dbt->dbconnect_extern($dbname);#operator connect
|
my $dbh_operator = $dbt->dbconnect_extern($dbname);#operator connect
|
||||||
|
|
||||||
my $tariff_all = { barcode => 0, txt18 => 0};
|
my $tariff_all = { barcode => 0, int18 => 0};
|
||||||
my $tariff = {
|
my $tariff = {
|
||||||
table => "content",
|
table => "content",
|
||||||
fetch => "all",
|
fetch => "all",
|
||||||
|
|
|
@ -151,7 +151,7 @@ sub counting_rental {
|
||||||
my $rental_minute = $self->clock_minutes($computed_clock);
|
my $rental_minute = $self->clock_minutes($computed_clock);
|
||||||
|
|
||||||
#if end_station == start_station and rental minutes < 5 minutes, then 0
|
#if end_station == start_station and rental minutes < 5 minutes, then 0
|
||||||
$rental_minute = 0 if($ctpos->{int04} == $ctpos->{int06} && $rental_minute && $rental_minute < 5);
|
$rental_minute = 0 if($ctpos->{int04} && $ctpos->{int06} && $ctpos->{int04} == $ctpos->{int06} && $rental_minute && $rental_minute < 5);
|
||||||
my $rental_minute_all = $rental_minute;
|
my $rental_minute_all = $rental_minute;
|
||||||
|
|
||||||
#init with some defaults
|
#init with some defaults
|
||||||
|
|
|
@ -217,7 +217,6 @@ sub save_account(){
|
||||||
$pw_dummy = "1";
|
$pw_dummy = "1";
|
||||||
}elsif(length($valxx) >= 8){
|
}elsif(length($valxx) >= 8){
|
||||||
my $pwmd5 = md5_hex($valxx) || "";
|
my $pwmd5 = md5_hex($valxx) || "";
|
||||||
$u_rows = $dbt->update_one($dbh,$update_primary,"txt11='$pwmd5'") if(length($pwmd5) > 20);
|
|
||||||
my $pwsha256=sha256_base64($pwmd5) || "";
|
my $pwsha256=sha256_base64($pwmd5) || "";
|
||||||
$u_rows = $dbt->update_one($dbh,$update_primary,"txt04='$pwsha256'") if(length($pwsha256) > 20);
|
$u_rows = $dbt->update_one($dbh,$update_primary,"txt04='$pwsha256'") if(length($pwsha256) > 20);
|
||||||
}
|
}
|
||||||
|
@ -244,12 +243,6 @@ sub save_account(){
|
||||||
elsif($_ =~ /int07|int16|int19|int23/){
|
elsif($_ =~ /int07|int16|int19|int23/){
|
||||||
$u_rows = $dbt->update_one("",$update_primary,"$_=$valxx");
|
$u_rows = $dbt->update_one("",$update_primary,"$_=$valxx");
|
||||||
}
|
}
|
||||||
#user_tour
|
|
||||||
elsif($_ =~ /txt18/){
|
|
||||||
my @txt18 = $q->param('txt18');
|
|
||||||
@txt18 = grep {!/null/} @txt18;
|
|
||||||
$u_rows = $dbt->update_one("",$update_primary,"$_='@txt18'");
|
|
||||||
}
|
|
||||||
#Text Sonstiges
|
#Text Sonstiges
|
||||||
elsif($_ =~ /txt29/){
|
elsif($_ =~ /txt29/){
|
||||||
$u_rows = $dbt->update_one("",$update_primary,"$_='$valxx'");
|
$u_rows = $dbt->update_one("",$update_primary,"$_='$valxx'");
|
||||||
|
@ -580,76 +573,6 @@ sub save_account(){
|
||||||
return ($ret,$feedb);
|
return ($ret,$feedb);
|
||||||
}#end save_account
|
}#end save_account
|
||||||
|
|
||||||
#insert/save/delete DMS users
|
|
||||||
sub manage_dmsusers {
|
|
||||||
my $self = shift;
|
|
||||||
my $q = shift;
|
|
||||||
my $varenv = shift;
|
|
||||||
my $base_edit = shift;
|
|
||||||
my $u_id = shift;
|
|
||||||
my $users_dms = shift || {};
|
|
||||||
my $owner = $users_dms->{u_id} || 0;
|
|
||||||
my $table = "users";
|
|
||||||
$q->import_names('R');
|
|
||||||
my @keywords = $q->param;
|
|
||||||
|
|
||||||
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
|
|
||||||
my $feedb = { message => "", i_rows => 0, u_rows => 0, d_rows => 0 };
|
|
||||||
$bw->log("manage_dmsusers",$q,"");
|
|
||||||
|
|
||||||
my $dbh = "";
|
|
||||||
my $adref = {
|
|
||||||
table => "contentadr",
|
|
||||||
fetch => "one",
|
|
||||||
template_id => "202",
|
|
||||||
c_id => "$u_id",
|
|
||||||
};
|
|
||||||
my $ctadr = $dbt->fetch_record($dbh,$adref);
|
|
||||||
|
|
||||||
#users have to be exist only if DMS activated
|
|
||||||
my $uref = {
|
|
||||||
table => "users",
|
|
||||||
fetch => "one",
|
|
||||||
u_id => "$u_id",
|
|
||||||
};
|
|
||||||
my $users = $dbt->fetch_tablerecord($dbh,$uref);
|
|
||||||
|
|
||||||
#datahash on update
|
|
||||||
my $dmsusers = {
|
|
||||||
table => "users",
|
|
||||||
mtime => "now()",
|
|
||||||
owner => "$owner",
|
|
||||||
u_id => "$u_id",
|
|
||||||
};
|
|
||||||
|
|
||||||
if(ref($users) eq "HASH" && $users->{u_id} && (!$ctadr->{c_id} || $base_edit eq "delete_dmsusers")){
|
|
||||||
$bw->log("delete DMS user from $varenv->{dbname}",$ctadr->{c_id},"");
|
|
||||||
$feedb->{d_rows} = $dbt->delete_content($dbh,"users",$u_id);
|
|
||||||
$dbt->update_one($dbh,$adref,"int07=null");
|
|
||||||
}elsif(ref($users) eq "HASH" && $users->{u_id} && $ctadr->{c_id} && $ctadr->{c_id} == $users->{u_id} && $base_edit eq "save_dmsusers"){
|
|
||||||
$bw->log("update DMS user to $varenv->{dbname}",$ctadr->{c_id},"");
|
|
||||||
foreach(@keywords){
|
|
||||||
my $val = $q->param($_);
|
|
||||||
my $valxx = $q->escapeHTML("$val");
|
|
||||||
$valxx =~ s/^\s+//; $valxx =~ s/\s+$//;
|
|
||||||
if($_ =~ /^int\d+/){
|
|
||||||
$valxx =~ s/,/./g;
|
|
||||||
#$valxx = "null" if(!looks_like_number($valxx));#empty
|
|
||||||
$valxx = 0 if(!looks_like_number($valxx));# set to 0 for using == operator
|
|
||||||
$feedb->{u_rows} = $dbt->update_one($dbh,$dmsusers,"$_=$valxx");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}elsif($ctadr->{c_id} && !$users->{u_id} && $base_edit eq "new_dmsusers"){
|
|
||||||
$bw->log("insert DMS user to $varenv->{dbname}",$ctadr->{c_id},"");
|
|
||||||
$feedb->{i_rows} = $dbt->insert_users($dbh,$ctadr->{c_id},$owner);
|
|
||||||
$dbt->update_one($dbh,$adref,"int07=100");
|
|
||||||
}
|
|
||||||
|
|
||||||
return $feedb;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#coupon alias Gutschein
|
#coupon alias Gutschein
|
||||||
sub save_transact(){
|
sub save_transact(){
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
@ -846,7 +769,6 @@ sub send_password(){
|
||||||
my $pwmd5 = md5_hex($coo) || "";
|
my $pwmd5 = md5_hex($coo) || "";
|
||||||
|
|
||||||
if($email && $email =~ /\w\@\w/ && $pwmd5 && length($pwmd5) > 20 && $email !~ /$dbt->{copri_conf}->{test_accounts}/i){
|
if($email && $email =~ /\w\@\w/ && $pwmd5 && length($pwmd5) > 20 && $email !~ /$dbt->{copri_conf}->{test_accounts}/i){
|
||||||
$db->updater("contentadr","1","1","txt11","$pwmd5","$owner","txt08","ilike","$email");
|
|
||||||
my $pwsha256=sha256_base64($pwmd5) || "";
|
my $pwsha256=sha256_base64($pwmd5) || "";
|
||||||
$db->updater("contentadr","1","1","txt04","$pwsha256","$owner","txt08","ilike","$email");
|
$db->updater("contentadr","1","1","txt04","$pwsha256","$owner","txt08","ilike","$email");
|
||||||
system(`$varenv{basedir}/src/Mod/newsletter_tink.pl "$varenv{basedir}" "$varenv{wwwhost}" "send_password" "$email" "$coo"`);
|
system(`$varenv{basedir}/src/Mod/newsletter_tink.pl "$varenv{basedir}" "$varenv{wwwhost}" "send_password" "$email" "$coo"`);
|
||||||
|
|
|
@ -760,7 +760,7 @@ EOF
|
||||||
}
|
}
|
||||||
elsif($key =~ /txt/ && "$size" =~ /select/){
|
elsif($key =~ /txt/ && "$size" =~ /select/){
|
||||||
if($size =~ /_multiple/){
|
if($size =~ /_multiple/){
|
||||||
if($key =~ /txt18/ && $node_meta->{tpl_id} eq "202"){ #user defined service_tour alias user_tour
|
if($key =~ /txt07/ && $node_meta->{tpl_id} eq "198"){ #user defined service_tour alias user_tour
|
||||||
my $height = scalar(@_service_valxx);
|
my $height = scalar(@_service_valxx);
|
||||||
print $q->Tr();
|
print $q->Tr();
|
||||||
print $q->td({-class=>'left_italic_cms',-style=>'vertical-align:top;',-colspan=>'1'},"$des");
|
print $q->td({-class=>'left_italic_cms',-style=>'vertical-align:top;',-colspan=>'1'},"$des");
|
||||||
|
|
|
@ -274,7 +274,7 @@ sub tpl(){
|
||||||
elsif($node_meta->{node_name} eq "Tagesbericht"){
|
elsif($node_meta->{node_name} eq "Tagesbericht"){
|
||||||
$R::detail_search="search";
|
$R::detail_search="search";
|
||||||
$searchref->{offset} = 0;
|
$searchref->{offset} = 0;
|
||||||
$searchref->{limit} = 1000;
|
$searchref->{limit} = 10000;
|
||||||
$v_journal = $node_meta->{node_name};
|
$v_journal = $node_meta->{node_name};
|
||||||
$searchref->{opos} = "null";
|
$searchref->{opos} = "null";
|
||||||
$tplids = 218;
|
$tplids = 218;
|
||||||
|
@ -301,11 +301,16 @@ sub tpl(){
|
||||||
}
|
}
|
||||||
|
|
||||||
#search at all
|
#search at all
|
||||||
if($R::detail_search eq "search"){
|
if($R::detail_search && $R::detail_search eq "search"){
|
||||||
$tplids = "209,218";
|
$tplids = "209,218";
|
||||||
}
|
}
|
||||||
$searchref->{tplids} = "$tplids";
|
$searchref->{tplids} = "$tplids";
|
||||||
|
}elsif($R::detail_search && $R::detail_search eq "search"){
|
||||||
|
$searchref->{offset} = 0;
|
||||||
|
$searchref->{limit} = 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$main_ids = "$main_id,";
|
$main_ids = "$main_id,";
|
||||||
$main_ids .= $db->collect_noderec($main_id,$lang,"nothing");
|
$main_ids .= $db->collect_noderec($main_id,$lang,"nothing");
|
||||||
$main_ids =~ s/,$//;
|
$main_ids =~ s/,$//;
|
||||||
|
@ -389,11 +394,6 @@ EOF
|
||||||
my $ct_ids = "";
|
my $ct_ids = "";
|
||||||
my $last_ab = {};
|
my $last_ab = {};
|
||||||
|
|
||||||
if($R::detail_search && $R::detail_search eq "search"){
|
|
||||||
$searchref->{offset} = 0;
|
|
||||||
$searchref->{limit} = 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $channel_map = $dbt->channel_map();
|
my $channel_map = $dbt->channel_map();
|
||||||
my $mapref = {};
|
my $mapref = {};
|
||||||
my $ct_users = $dbt->users_map($dbh,$mapref);#get serviceAPP and DMS users from contentadr
|
my $ct_users = $dbt->users_map($dbh,$mapref);#get serviceAPP and DMS users from contentadr
|
||||||
|
@ -1297,6 +1297,7 @@ EOF
|
||||||
print "<div style='padding:6px 0 0 10px;'>\n";
|
print "<div style='padding:6px 0 0 10px;'>\n";
|
||||||
print $q->a({-class=>"linknav1",-href=>"?go=backward_list;offset=$searchref->{offset};limit=$searchref->{limit}",-title=>'backward'},"← ") if($searchref->{offset} >= $searchref->{limit});
|
print $q->a({-class=>"linknav1",-href=>"?go=backward_list;offset=$searchref->{offset};limit=$searchref->{limit}",-title=>'backward'},"← ") if($searchref->{offset} >= $searchref->{limit});
|
||||||
print $q->a({-class=>"linknav1",-href=>"?go=forward_list;offset=$searchref->{offset};limit=$searchref->{limit}",-title=>'forward'}," →") if($counter >= $limit-10); #if($rows > $limit && $nr > 0);
|
print $q->a({-class=>"linknav1",-href=>"?go=forward_list;offset=$searchref->{offset};limit=$searchref->{limit}",-title=>'forward'}," →") if($counter >= $limit-10); #if($rows > $limit && $nr > 0);
|
||||||
|
print $q->span({-style=>'color:silver;'}," (offset:$searchref->{offset}, limit:$searchref->{limit})");
|
||||||
print "</div>\n";
|
print "</div>\n";
|
||||||
|
|
||||||
print $q->div({-style=>''}, " "),"\n";
|
print $q->div({-style=>''}, " "),"\n";
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
/*
|
||||||
|
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
Copyright (c) Rainer Gümpelein, TeilRad GmbH
|
||||||
|
*/
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
|
|
|
@ -1,145 +0,0 @@
|
||||||
#!/usr/bin/perl
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
||||||
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
|
|
||||||
#
|
|
||||||
#For pdf pw files
|
|
||||||
#"pdftotext -upw FksjxxxxxxfmC1h Teilrad_ISI_PLUS_BB01207.pdf"
|
|
||||||
#:1,$ s/^\n//g
|
|
||||||
#:1,$ s/\n/;/g
|
|
||||||
#:1,$ s/;C2-/\rC2-/g
|
|
||||||
#:1,$ s/;QR-/\rQR-/g
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#check if UTF-8
|
|
||||||
#file Teilrad_ISI_PLUS_BB01207.txt
|
|
||||||
#iconv -t utf-8 -f iso-8859-1 Ilockitkeys_110520.csv -o Ilockitkeys_110520_utf8.cs
|
|
||||||
#
|
|
||||||
#sudo su www-data -c "./src/scripts/Ilockit_CSV2DB.pl shareedms-kn ../shareeconf/smartlock-keys/Ilockit-16-BB01742_1v2.csv"
|
|
||||||
#
|
|
||||||
#do it twice to set hex-key and bike-nr!
|
|
||||||
#
|
|
||||||
use vars qw($syshost);
|
|
||||||
|
|
||||||
BEGIN {
|
|
||||||
$syshost = $ARGV[0] || exit 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
use lib "/var/www/copri-bike/$syshost/src";
|
|
||||||
|
|
||||||
my $csv_file = $ARGV[1] || "";
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
use warnings;
|
|
||||||
use POSIX;
|
|
||||||
use DBI;
|
|
||||||
use CGI ':standard';
|
|
||||||
use Lib::Config;
|
|
||||||
use Mod::DBtank;
|
|
||||||
use Scalar::Util qw(looks_like_number);
|
|
||||||
use Data::Dumper;
|
|
||||||
|
|
||||||
my $q = new CGI;
|
|
||||||
my $cf = new Config;
|
|
||||||
my %varenv = $cf->envonline("$syshost");
|
|
||||||
print "$varenv{wwwhost}\n";
|
|
||||||
my $dbt = new DBtank;
|
|
||||||
my $lang = "de";
|
|
||||||
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
|
|
||||||
my $dbh = "";
|
|
||||||
my $main_id = 300103;#TODO Flotten ID
|
|
||||||
my $template_id = 205;
|
|
||||||
|
|
||||||
###
|
|
||||||
#Start loop payone log and update userid ##################################
|
|
||||||
####
|
|
||||||
#reading CSV
|
|
||||||
my $dbh_csv = DBI->connect("DBI:CSV:");
|
|
||||||
$dbh_csv->{'csv_tables'}->{'ilockitcsv'} = {
|
|
||||||
'eol' => "\n",
|
|
||||||
'sep_char' => ";",
|
|
||||||
'quote_char' => undef,
|
|
||||||
#'quote_char' => "\"",
|
|
||||||
'escape_char' => undef,
|
|
||||||
'file' => $csv_file,
|
|
||||||
#'col_names' => ["serialnr","ilockit_id","ilockit_key","c1"]
|
|
||||||
'col_names' => ["serialnr","ilockit_id","ilockit_key","c1","bikeid","rahmen","stationid","bike_name"]
|
|
||||||
};
|
|
||||||
|
|
||||||
my $sth = $dbh_csv->prepare("SELECT * FROM ilockitcsv where serialnr like 'C2-%'");
|
|
||||||
my $rc = $sth->execute();
|
|
||||||
my $csv = $sth->fetchall_hashref("serialnr");
|
|
||||||
|
|
||||||
my $i=0;
|
|
||||||
foreach my $id (sort { $csv->{$a}->{serialnr} cmp $csv->{$b}->{serialnr} } keys (%$csv)){
|
|
||||||
$i++;
|
|
||||||
|
|
||||||
if($csv->{$id}->{serialnr}){
|
|
||||||
$csv->{$id}->{ilockit_id} =~ s/\+/\-/;
|
|
||||||
$csv->{$id}->{c1} =~ s/R/red /g;
|
|
||||||
$csv->{$id}->{c1} =~ s/B/blue /g;
|
|
||||||
$csv->{$id}->{c1} =~ s/G/green /g;
|
|
||||||
$csv->{$id}->{c1} =~ s/\s$//;#empty last space
|
|
||||||
$csv->{$id}->{bikeid} =~ s/THU//;
|
|
||||||
$csv->{$id}->{stationid} =~ s/THU//;
|
|
||||||
|
|
||||||
print "$i) $csv->{$id}->{serialnr}|\n";
|
|
||||||
|
|
||||||
my $ct = &select_content($csv->{$id});
|
|
||||||
|
|
||||||
my $data = {
|
|
||||||
table => "content",
|
|
||||||
main_id => "$main_id",
|
|
||||||
template_id => "$template_id",
|
|
||||||
txt22 => "$csv->{$id}->{serialnr}",
|
|
||||||
txt18 => "$csv->{$id}->{ilockit_id}",
|
|
||||||
byte01 => "\\x$csv->{$id}->{ilockit_key}",
|
|
||||||
barcode => "$csv->{$id}->{bikeid}",
|
|
||||||
int04 => "$csv->{$id}->{stationid}",#station
|
|
||||||
txt01 => "$csv->{$id}->{bike_name}",
|
|
||||||
txt11 => "$csv->{$id}->{rahmen}",
|
|
||||||
txt23 => "$csv->{$id}->{c1}",
|
|
||||||
int10 => "1",#available
|
|
||||||
int20 => "1",#locked
|
|
||||||
int11 => "2",#Ilockit
|
|
||||||
txt04 => "", #Sonstiges
|
|
||||||
mtime => "now()",
|
|
||||||
owner => "1842",
|
|
||||||
};
|
|
||||||
|
|
||||||
if(ref($ct) eq "HASH" && $ct->{c_id} && ref($data) eq "HASH" && $csv->{$id}->{serialnr}){
|
|
||||||
print "UPDATE $csv->{$id}->{serialnr} (c_id:$ct->{c_id})\n";
|
|
||||||
$data->{barcode} = $ct->{c_id} if(!$ct->{barcode});
|
|
||||||
$dbt->update_record($dbh,$data, { c_id => $ct->{c_id} });
|
|
||||||
print Dumper($data) . "\n";
|
|
||||||
}elsif(ref($data) eq "HASH" && $csv->{$id}->{serialnr}){
|
|
||||||
print "INSERT $csv->{$id}->{serialnr}\n";
|
|
||||||
$dbt->insert_contentoid($dbh,$data);
|
|
||||||
print Dumper($data) . "\n";
|
|
||||||
}else{
|
|
||||||
print "nothing todo\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#content check if still exists
|
|
||||||
sub select_content{
|
|
||||||
my $ct_hash = shift;
|
|
||||||
my $fetch = {
|
|
||||||
table => "content",
|
|
||||||
main_id => "$main_id",
|
|
||||||
template_id => "$template_id",
|
|
||||||
fetch => "one",
|
|
||||||
};
|
|
||||||
if(ref($ct_hash) eq "HASH" && $ct_hash->{serialnr}){
|
|
||||||
$fetch = { %$fetch , txt22 => "=::$ct_hash->{serialnr}" };
|
|
||||||
#$fetch = { %$fetch , barcode => "<::100" };
|
|
||||||
#$fetch = { %$fetch , int10 => "!=::3" };
|
|
||||||
#$fetch = { %$fetch , int11 => "!=::2" };
|
|
||||||
}
|
|
||||||
|
|
||||||
my $ct = $dbt->fetch_record($dbh,$fetch);
|
|
||||||
return $ct;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
|
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
|
||||||
#
|
#
|
||||||
|
#Examples
|
||||||
|
#./src/scripts/Ilockit_cloud.pl shareedms-operator get_events 95
|
||||||
#
|
#
|
||||||
##sudo su www-data -c "./src/scripts/Ilockit_cloud.pl shareedms-fr01 get_events 95"
|
#./src/scripts/Ilockit_cloud.pl shareedms-operator get_positions
|
||||||
#
|
|
||||||
#sudo su www-data -c "./src/scripts/Ilockit_cloud.pl shareedms-fr01 get_positions"
|
|
||||||
#
|
#
|
||||||
#Ilockit GPS cloud
|
#Ilockit GPS cloud
|
||||||
#
|
#
|
||||||
|
@ -77,15 +77,15 @@ while (my ($key, $op_name) = each %{ $dbt->{operator} }) {
|
||||||
$dbh = $dbt->dbconnect_extern($sharee_operator);
|
$dbh = $dbt->dbconnect_extern($sharee_operator);
|
||||||
|
|
||||||
#per cronjob once a day to get and update content with cloud device id
|
#per cronjob once a day to get and update content with cloud device id
|
||||||
#sudo su www-data -c "./src/scripts/Ilockit_cloud.pl shareedms-fr01 get_devices"
|
#./src/scripts/Ilockit_cloud.pl shareedms-fr01 get_devices
|
||||||
&get_devices($dbh,$op_name) if($todo eq "get_devices");
|
&get_devices($dbh,$op_name) if($todo eq "get_devices");
|
||||||
|
|
||||||
#sudo su www-data -c "./src/scripts/Ilockit_cloud.pl shareedms-fr01 get_events 95"
|
#./src/scripts/Ilockit_cloud.pl shareedms-fr01 get_events 95
|
||||||
if($todo eq "get_events"){
|
if($todo eq "get_events"){
|
||||||
&get_events($dbh,$op_name,$response_in);
|
&get_events($dbh,$op_name,$response_in);
|
||||||
&get_positions($dbh,$op_name);
|
&get_positions($dbh,$op_name);
|
||||||
}
|
}
|
||||||
#sudo su www-data -c "./src/scripts/Ilockit_cloud.pl shareedms-fr01 get_positions 6572"
|
#./src/scripts/Ilockit_cloud.pl shareedms-fr01 get_positions 6572
|
||||||
#&get_positions($dbh,$op_name->{oprefix}) if($todo eq "get_positions");
|
#&get_positions($dbh,$op_name->{oprefix}) if($todo eq "get_positions");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,15 +6,9 @@
|
||||||
#get tracking by
|
#get tracking by
|
||||||
#Ilockit trips by Ilockit cloud
|
#Ilockit trips by Ilockit cloud
|
||||||
#
|
#
|
||||||
#sudo su www-data -c "./src/scripts/Ilockit_trackingcloud.pl shareedms-fr01 get_tripsum 155884"
|
#Example
|
||||||
|
#./src/scripts/Ilockit_trackingcloud.pl shareedms-operator get_tripsum 155884
|
||||||
#
|
#
|
||||||
#2021-07-20
|
|
||||||
#GPS tracking
|
|
||||||
#Unser System bieten für die Auswertung von Fahrtstrecken bereits Zusammenfassungen an. Hierfür können Sie einfach die folgenden Calls benutzen:
|
|
||||||
#
|
|
||||||
#GET /api/reports/summary?groupId=95& from=2021-07-17T18:30:00Z& to=2021-07-20T18:30:00Z - Gibt Ihnen eine Zusammenfassung aller Fahrstrecken für die Schlösser in der Gruppe zurück.
|
|
||||||
#
|
|
||||||
#GET /api/reports/trips?groupId=95& from=2020-07-17T18:30:00Z& to=2021-07-20T18:30:00Z - Gibt Ihnen einzelne Fahrtstrecken für die Schlösser in der Gruppe zurück.
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
use vars qw($syshost);
|
use vars qw($syshost);
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
/*
|
/*
|
||||||
|
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
Copyright (c) haveltec GmbH, TeilRad GmbH
|
||||||
|
|
||||||
|
Created by Bjoern Kinberger on 04.10.18.
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
*/
|
*/
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -11,22 +16,12 @@ import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Bjoern Kinberger on 04.10.18.
|
|
||||||
*
|
|
||||||
* This is a test class for the authentication process without a server
|
|
||||||
*
|
|
||||||
* Only use this for the development process, the key generation should be done on the server!
|
|
||||||
*/
|
|
||||||
public class Ilockkeygen {
|
public class Ilockkeygen {
|
||||||
//private static final String LOG_TAG = Ilockkeygen.class.getName();
|
//private static final String LOG_TAG = Ilockkeygen.class.getName();
|
||||||
public static byte[] sha1Value;
|
public static byte[] sha1Value;
|
||||||
|
|
||||||
|
|
||||||
public static void generateKey(byte[] randomNum, byte[] internKey) {
|
public static void generateKey(byte[] randomNum, byte[] internKey) {
|
||||||
|
|
||||||
//System.out.println( "K_int_byte = " + internKey );
|
|
||||||
//System.out.println("K_int_string = " + new String(internKey));
|
|
||||||
System.out.println("K_int = " + Arrays.toString(internKey));
|
System.out.println("K_int = " + Arrays.toString(internKey));
|
||||||
|
|
||||||
byte[] filler = {0, 0, 0, 0};
|
byte[] filler = {0, 0, 0, 0};
|
||||||
|
|
|
@ -1,50 +0,0 @@
|
||||||
#!/usr/bin/perl
|
|
||||||
#
|
|
||||||
#Autor ragu@gnu-systems.de
|
|
||||||
#
|
|
||||||
#Ilockit authentify test
|
|
||||||
#
|
|
||||||
#sudo su www-data -c "./src/scripts/Ilocktestauth.pl shareeapp_operator 1003"
|
|
||||||
#
|
|
||||||
#
|
|
||||||
use vars qw($syshost);
|
|
||||||
|
|
||||||
BEGIN {
|
|
||||||
$syshost = $ARGV[0] || exit 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
use lib "/var/www/copri-bike/$syshost/src";
|
|
||||||
|
|
||||||
my $dbname = $ARGV[1] || "";
|
|
||||||
my $bike = $ARGV[2] || "";
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
use warnings;
|
|
||||||
use POSIX;
|
|
||||||
use CGI ':standard';
|
|
||||||
use Lib::Config;
|
|
||||||
use Data::Dumper;
|
|
||||||
|
|
||||||
my $q = new CGI;
|
|
||||||
my $cf = new Config;
|
|
||||||
my %varenv = $cf->envonline("$syshost");
|
|
||||||
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
|
|
||||||
|
|
||||||
|
|
||||||
my @K_select = `cd /var/www/copri-bike/$varenv{syshost}/src/scripts && export CLASSPATH='.:/usr/share/java:/usr/share/java/postgresql.jar' && java Ilockauth $dbname $bike`;
|
|
||||||
foreach(@K_select){
|
|
||||||
my ($K_key,$K_val) = split(/ = /, $_);
|
|
||||||
$K_val =~ s/\n//g;
|
|
||||||
print "$K_key: $K_val\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
my $receiver_usb = "abcd";
|
|
||||||
if($receiver_usb =~ /(\w)(\w)$/){
|
|
||||||
my $a = ord($1);
|
|
||||||
my $b = ord($2);
|
|
||||||
print "$1|$2" . "\n";
|
|
||||||
print "$a|$b" . "\n";
|
|
||||||
my $receiver_id = sprintf( "%x", $a ) . sprintf( "%x", $b );
|
|
||||||
print $receiver_id . "\n";
|
|
||||||
}
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
../../../../../sharee.bike/copri-bike/main/src/scripts/adrupdate_byCSV.pl
|
|
|
@ -1 +0,0 @@
|
||||||
../../../../../sharee.bike/copri-bike/main/src/scripts/auerswald_gespr.pl
|
|
|
@ -1 +0,0 @@
|
||||||
../../../../../sharee.bike/copri-bike/main/src/scripts/coupongen.pl
|
|
|
@ -1 +0,0 @@
|
||||||
../../../../../sharee.bike/copri-bike/main/src/scripts/coupongen_check.pl
|
|
|
@ -1 +0,0 @@
|
||||||
../../../../../sharee.bike/copri-bike/main/src/scripts/cpdate_check.pl
|
|
|
@ -1 +0,0 @@
|
||||||
../../../../../sharee.bike/copri-bike/main/src/scripts/ftpSWK.pl
|
|
|
@ -1 +0,0 @@
|
||||||
../../../../../sharee.bike/copri-bike/main/src/scripts/ftpSWKstatistik.pl
|
|
|
@ -1,26 +0,0 @@
|
||||||
#!/usr/bin/perl
|
|
||||||
|
|
||||||
# Client
|
|
||||||
use JSON::RPC::Client;
|
|
||||||
|
|
||||||
my $client = new JSON::RPC::Client;
|
|
||||||
|
|
||||||
my $uri = 'http://www.example.com/jsonrpc/Test';
|
|
||||||
my $obj = {
|
|
||||||
method => 'sum', # or 'MyApp.sum'
|
|
||||||
params => [10, 20],
|
|
||||||
};
|
|
||||||
|
|
||||||
my $res = $client->call( $uri, $obj )
|
|
||||||
|
|
||||||
if($res){
|
|
||||||
if ($res->is_error) {
|
|
||||||
print "Error : ", $res->error_message;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
print $res->result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
print $client->status_line;
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
../../../../../sharee.bike/copri-bike/main/src/scripts/loop_SWKcode.pl
|
|
|
@ -1 +0,0 @@
|
||||||
../../../../../sharee.bike/copri-bike/main/src/scripts/mailTransportInnofact.pl
|
|
|
@ -1 +0,0 @@
|
||||||
../../../../../sharee.bike/copri-bike/main/src/scripts/mailTransportcms.pl
|
|
254
copri4/main/src/scripts/mailTransportcms.pl
Executable file
254
copri4/main/src/scripts/mailTransportcms.pl
Executable file
|
@ -0,0 +1,254 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
|
||||||
|
#
|
||||||
|
#2023-01-02
|
||||||
|
#adapted from mailTransport.pl without bulkmail
|
||||||
|
#NEW
|
||||||
|
#managed text by operator cms
|
||||||
|
#
|
||||||
|
#Example
|
||||||
|
#./src/scripts/mailTransportcms.pl 'shareedms-operator' 'send_alarm2hotline' '[contentuser.c_id]' '[contenttheftpos.c_id]'
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
use vars qw($syshost);
|
||||||
|
|
||||||
|
BEGIN {
|
||||||
|
$syshost = $ARGV[0] || die 'syshost not defined';
|
||||||
|
}
|
||||||
|
|
||||||
|
use lib "/var/www/copri-bike/$syshost/src";
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use utf8;
|
||||||
|
use Encode;
|
||||||
|
use POSIX;
|
||||||
|
use Scalar::Util qw(looks_like_number);
|
||||||
|
use Lib::Config;
|
||||||
|
use Mod::DBtank;
|
||||||
|
use Mod::MailTransport;
|
||||||
|
use Data::Dumper;
|
||||||
|
my $cf = new Config;
|
||||||
|
my %varenv = $cf->envonline();
|
||||||
|
|
||||||
|
my $dbt = new DBtank;
|
||||||
|
my $mailtrans = new MailTransport;
|
||||||
|
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
|
||||||
|
|
||||||
|
#one contentadr.c_id OR email on command
|
||||||
|
my $todo = $ARGV[1] || "";
|
||||||
|
my $adr_id = $ARGV[2] || "";#takes ctt.c_id or ctadr.email
|
||||||
|
my $ct_id = $ARGV[3] || "";
|
||||||
|
my $attachment = $ARGV[4] || "";
|
||||||
|
|
||||||
|
open(EMA, ">> $dbt->{copri_conf}->{logdir}/mailTransportcms.log");
|
||||||
|
print EMA "\n$now_dt, start mailTransportcms.pl syshost: $syshost, todo:$todo, adr_id:$adr_id, ct_id:$ct_id, attachment:$attachment \n";
|
||||||
|
|
||||||
|
|
||||||
|
#mailxcfg is shareeconf/mailx.cfg <block> selection!
|
||||||
|
#hash data to send
|
||||||
|
my $sendref = {
|
||||||
|
mailxcfg => "mailx_default",
|
||||||
|
#mailxcfg => "mailx_admin",
|
||||||
|
syshost => "$syshost",
|
||||||
|
mail_to => "",
|
||||||
|
c_id => 0,
|
||||||
|
subject => "",
|
||||||
|
message => "",
|
||||||
|
signature => "",
|
||||||
|
attachment => "",
|
||||||
|
};
|
||||||
|
|
||||||
|
#my $project = $dbt->{operator}->{$varenv{dbname}}->{project} || die "project not defined";
|
||||||
|
my $oprefix = $dbt->{operator}->{$varenv{dbname}}->{oprefix} || "";
|
||||||
|
|
||||||
|
my $sendmail = {};
|
||||||
|
|
||||||
|
#send_cpdate_message, done by cronjob cpdate_check.pl
|
||||||
|
$sendmail = send_cpupdate_message($todo,$sendref,$adr_id) if(($todo eq "send_cpupdate_message" || $todo eq "send_proactive_cpupdate_message") && looks_like_number($adr_id));
|
||||||
|
|
||||||
|
#send_alarm2hotline, done by Ilockit_cloud.pl
|
||||||
|
$sendmail = send_alarm2hotline($sendref,$ct_id) if($todo eq "send_alarm2hotline" && looks_like_number($adr_id) && looks_like_number($ct_id));
|
||||||
|
|
||||||
|
if($sendmail->{c_id}){
|
||||||
|
sendmailjob($sendmail);
|
||||||
|
}else{
|
||||||
|
print EMA "Error, can not sendmailjob without c_id\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
#send_cpupdate_message
|
||||||
|
sub send_cpupdate_message {
|
||||||
|
my $todo = shift;
|
||||||
|
my $sendref = shift;
|
||||||
|
my $adr_id = shift || "";
|
||||||
|
|
||||||
|
my $client_encoding = "iso-8859-1";
|
||||||
|
my $dbh_primary = $dbt->dbconnect_extern($dbt->{primary}->{sharee_primary}->{database}->{dbname},$client_encoding);
|
||||||
|
|
||||||
|
#TeilRad Kontakt
|
||||||
|
my $pref_ctu = {
|
||||||
|
table => "contentuser",
|
||||||
|
fetch => "one",
|
||||||
|
c_id => "1",#Kontakt-hotline
|
||||||
|
};
|
||||||
|
my $uadr = { c_id => 0 };
|
||||||
|
$uadr = $dbt->fetch_tablerecord($dbh_primary,$pref_ctu);
|
||||||
|
|
||||||
|
#CMS text
|
||||||
|
my $cms_message_key = "email-cpupdate-message";
|
||||||
|
$cms_message_key = "email-proactive-cpupdate-message" if($todo eq "send_proactive_cpupdate_message");
|
||||||
|
my $pref_cms = {
|
||||||
|
table => "contentuser",
|
||||||
|
fetch => "one",
|
||||||
|
ct_name => "$cms_message_key",
|
||||||
|
};
|
||||||
|
my $cms_prim = { c_id => 0, txt01 => '' };
|
||||||
|
$cms_prim = $dbt->fetch_tablerecord($dbh_primary,$pref_cms);
|
||||||
|
|
||||||
|
#Kunde
|
||||||
|
my $pref_adr = {
|
||||||
|
table => "contentadr",
|
||||||
|
fetch => "one",
|
||||||
|
c_id => "$adr_id",
|
||||||
|
};
|
||||||
|
my $cta = { c_id => 0 };
|
||||||
|
$cta = $dbt->fetch_tablerecord($dbh_primary,$pref_adr);
|
||||||
|
|
||||||
|
$sendref = prepare_content($sendref,$cta,$cms_prim,$uadr);
|
||||||
|
|
||||||
|
return $sendref;
|
||||||
|
}#end send_cpupdate_message
|
||||||
|
|
||||||
|
#prepare email by cms markup
|
||||||
|
sub prepare_content {
|
||||||
|
my $sendref = shift;
|
||||||
|
my $cta = shift;
|
||||||
|
my $cms_prim = shift;
|
||||||
|
my $uadr = shift;
|
||||||
|
|
||||||
|
my $globalconf_file = "/var/www/copri4/shareeconf/global.cfg";
|
||||||
|
my $conf = Config::General->new($globalconf_file);
|
||||||
|
my %globalconf = $conf->getall;
|
||||||
|
|
||||||
|
my $app_name = "App";
|
||||||
|
while (my ($key, $merchant) = each %{ $globalconf{merchant_ids} }) {
|
||||||
|
$app_name =~ s/$app_name/$merchant->{app_name}/ if($merchant->{app_name} && $cta->{int15} && $cta->{int15} == $merchant->{id});
|
||||||
|
}
|
||||||
|
my $subject = "TeilRad Mietradsystem";#default
|
||||||
|
$subject = $1 if($cms_prim->{txt01} =~ /--subject--(.*)--subject--/);
|
||||||
|
$cms_prim->{txt01} =~ s/--subject--$subject--subject--//;
|
||||||
|
$cms_prim->{txt01} =~ s/\n//;
|
||||||
|
$cms_prim->{txt01} =~ s/\n//;
|
||||||
|
|
||||||
|
my $signature = <<EOF
|
||||||
|
--
|
||||||
|
$uadr->{txt01}
|
||||||
|
$uadr->{txt03}
|
||||||
|
$uadr->{txt06}
|
||||||
|
$uadr->{txt07}
|
||||||
|
$uadr->{txt08}
|
||||||
|
|
||||||
|
$uadr->{txt84}
|
||||||
|
|
||||||
|
EOF
|
||||||
|
;
|
||||||
|
|
||||||
|
$sendref->{mail_to} = $cta->{txt08};
|
||||||
|
$sendref->{c_id} = $cta->{c_id};
|
||||||
|
$sendref->{subject} = $subject;
|
||||||
|
$sendref->{subject} =~ s/::app_name::/$app_name/;
|
||||||
|
$sendref->{subject} =~ s/Mein // if($sendref->{subject} =~ /^Mein/);
|
||||||
|
|
||||||
|
$sendref->{message} = $cms_prim->{txt01};
|
||||||
|
$sendref->{message} =~ s/::user_name::/$cta->{txt01}/;
|
||||||
|
$sendref->{message} =~ s/::app_name::/$app_name/g;
|
||||||
|
$sendref->{message} =~ s/::signature::/$signature/;
|
||||||
|
$sendref->{message} =~ s/\n/\<br \/\>/g;
|
||||||
|
|
||||||
|
return $sendref;
|
||||||
|
}#end prepare_content
|
||||||
|
|
||||||
|
|
||||||
|
#send_alarm2hotline
|
||||||
|
sub send_alarm2hotline {
|
||||||
|
my $sendref = shift;
|
||||||
|
my $ct_id = shift || "";
|
||||||
|
|
||||||
|
my $client_encoding = "iso-8859-1";
|
||||||
|
my $dbh = $dbt->dbconnect_extern($dbt->{operator}->{$varenv{dbname}}->{database}->{dbname},$client_encoding);
|
||||||
|
|
||||||
|
my $pref_ctu = {
|
||||||
|
table => "contentuser",
|
||||||
|
fetch => "one",
|
||||||
|
c_id => "1",#Kontakt-hotline
|
||||||
|
};
|
||||||
|
my $uadr = { c_id => 0 };
|
||||||
|
$uadr = $dbt->fetch_tablerecord($dbh,$pref_ctu);
|
||||||
|
$sendref->{mail_to} = $uadr->{txt08};
|
||||||
|
|
||||||
|
#without cms
|
||||||
|
my $cms_prim = { c_id => 0, txt01 => 'Folgendes Mietrad hat einen Diebstahlalarm ausgelöst' };
|
||||||
|
|
||||||
|
my $pref_ct = {
|
||||||
|
table => "contenttheftpos",
|
||||||
|
fetch => "one",
|
||||||
|
c_id => $ct_id,
|
||||||
|
};
|
||||||
|
|
||||||
|
my $ct = { c_id => 0 };
|
||||||
|
$ct = $dbt->fetch_tablerecord($dbh,$pref_ct);
|
||||||
|
|
||||||
|
$sendref->{c_id} = $ct->{c_id};
|
||||||
|
$sendref->{subject} = "Diebstahlalarm $oprefix$ct->{barcode}";
|
||||||
|
|
||||||
|
$sendref->{message} = <<EOF
|
||||||
|
$cms_prim->{txt01}
|
||||||
|
|
||||||
|
Bike: $oprefix$ct->{barcode}
|
||||||
|
Speed: $ct->{int07}
|
||||||
|
Meter: $ct->{int08}
|
||||||
|
GPS: $ct->{txt06}
|
||||||
|
Timestamp: $ct->{start_time}
|
||||||
|
|
||||||
|
Öffne das Alarmjournal für weitere Informationen:
|
||||||
|
<a href='$dbt->{operator}->{$varenv{dbname}}->{operatorDMS}/DMS/Alarmjournal'>$dbt->{operator}->{$varenv{dbname}}->{operatorDMS}/DMS/Alarmjournal</a>
|
||||||
|
|
||||||
|
Freundliche Grüße,
|
||||||
|
--
|
||||||
|
$uadr->{txt01}
|
||||||
|
$uadr->{txt03}
|
||||||
|
$uadr->{txt06}
|
||||||
|
|
||||||
|
$uadr->{txt84}
|
||||||
|
|
||||||
|
EOF
|
||||||
|
;
|
||||||
|
|
||||||
|
$sendref->{message} =~ s/\n/\<br \/\>/g;
|
||||||
|
return $sendref;
|
||||||
|
}
|
||||||
|
|
||||||
|
#sending mail job
|
||||||
|
sub sendmailjob {
|
||||||
|
my $sendref = shift || "";
|
||||||
|
|
||||||
|
#at first connect mailxchanger by mailx.cfg config
|
||||||
|
my ($smtp,$mailxconf) = $mailtrans->mail_connect($sendref);
|
||||||
|
|
||||||
|
#one mailing with mail address on command
|
||||||
|
if($sendref->{mail_to} =~ /\w\@\w/ && $sendref->{subject} && $sendref->{message}){
|
||||||
|
my $ret = "";
|
||||||
|
$ret = $mailtrans->mail_transport($smtp,$mailxconf,$sendref);
|
||||||
|
|
||||||
|
print EMA "done mailing with state to $sendref->{mail_to}: $ret\n";
|
||||||
|
}else{
|
||||||
|
print EMA "Error, no or false email address $sendref->{mail_to}, exit\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print EMA "\n\n";
|
||||||
|
close EMA;
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
../../../../../sharee.bike/copri-bike/main/src/scripts/payone_cron.pl
|
|
|
@ -1 +0,0 @@
|
||||||
../../../../../sharee.bike/copri-bike/main/src/scripts/payone_post_Payment.pl
|
|
|
@ -1,10 +1,12 @@
|
||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
#
|
#
|
||||||
#Autor ragu@gnu-systems.de
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
|
||||||
#
|
#
|
||||||
#set availabel if requested > 15min
|
#set availabel if requested > 15min
|
||||||
#
|
#
|
||||||
#sudo su www-data -c "./src/scripts/requested_timeout.pl shareedms-fr01"
|
#Example
|
||||||
|
#./src/scripts/requested_timeout.pl shareedms-operator
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
use vars qw($syshost);
|
use vars qw($syshost);
|
||||||
|
@ -40,7 +42,6 @@ my $pref = {
|
||||||
table => "contenttranspos",
|
table => "contenttranspos",
|
||||||
fetch => "all",
|
fetch => "all",
|
||||||
keyfield => "c_id",
|
keyfield => "c_id",
|
||||||
#txt10 => "requested",
|
|
||||||
int10 => "2",
|
int10 => "2",
|
||||||
owner => "!=::199",#don't select LV api requested bikes
|
owner => "!=::199",#don't select LV api requested bikes
|
||||||
start_time => "<=::(now() - interval '$interval_min minutes')",
|
start_time => "<=::(now() - interval '$interval_min minutes')",
|
||||||
|
@ -49,7 +50,6 @@ my $record_cp = $dbt->fetch_tablerecord($dbh,$pref);
|
||||||
|
|
||||||
my $update_cp = {
|
my $update_cp = {
|
||||||
table => "contenttranspos",
|
table => "contenttranspos",
|
||||||
#txt10 => "available",
|
|
||||||
int10 => "1",
|
int10 => "1",
|
||||||
owner_end => "172",
|
owner_end => "172",
|
||||||
mtime => "now()",
|
mtime => "now()",
|
||||||
|
|
|
@ -5,13 +5,14 @@
|
||||||
#
|
#
|
||||||
#On this forking script, nothing will saved on script, else by execute APIsigclient methodes
|
#On this forking script, nothing will saved on script, else by execute APIsigclient methodes
|
||||||
#
|
#
|
||||||
# command line syntax
|
# command line syntax
|
||||||
# sudo su www-data -c "./src/scripts/sig_client.pl shareeapp-sx 'todo' 'user_id' 'sig bikeId' 'pos_id'"
|
# examples
|
||||||
|
# ./src/scripts/sig_client.pl shareeapp-operator 'todo' 'user_id' 'sig bikeId' 'pos_id'
|
||||||
#
|
#
|
||||||
# sudo su www-data -c "./src/scripts/sig_client.pl shareeapp-sx bikes_available"
|
# ./src/scripts/sig_client.pl shareeapp-operator bikes_available
|
||||||
#
|
#
|
||||||
# sudo su www-data -c "./src/scripts/sig_client.pl shareeapp-sx reserve 1842 '380116b5-0522-43da-ab66-477744a731a3' ''"
|
# ./src/scripts/sig_client.pl shareeapp-operator reserve [user_id] '380116b5-0522-43da-ab66-477744axxxxx' ''
|
||||||
# sudo su www-data -c "./src/scripts/sig_client.pl shareeapp-sx rental 1842 '380116b5-0522-43da-ab66-477744a731a3' ''"
|
# ./src/scripts/sig_client.pl shareeapp-operator rental [user_id] '380116b5-0522-43da-ab66-477744axxxxx' ''
|
||||||
#
|
#
|
||||||
use vars qw($syshost);
|
use vars qw($syshost);
|
||||||
|
|
||||||
|
@ -95,24 +96,24 @@ if($todo eq "bikes_available"){
|
||||||
|
|
||||||
#only for tests. build in methode
|
#only for tests. build in methode
|
||||||
elsif($todo eq "reserve"){
|
elsif($todo eq "reserve"){
|
||||||
#$ctadr = { c_id => 1842 };
|
#$ctadr = { c_id => user };
|
||||||
#$ct_bike = { txt22 => "380116b5-0522-43da-ab66-477744a731a3" };
|
#$ct_bike = { txt22 => "380116b5-0522-43da-ab66-4777xxxxxxx3" };
|
||||||
my $return = $si->sig_booking(\%varenv,$todo,$ctadr,$ct_bike,$ctpos);
|
my $return = $si->sig_booking(\%varenv,$todo,$ctadr,$ct_bike,$ctpos);
|
||||||
#print $0 . Dumper($return) . "\n";
|
#print $0 . Dumper($return) . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
#live! Fork rental request with bike "id"
|
#live! Fork rental request with bike "id"
|
||||||
elsif($todo eq "rental" && $ctadr->{c_id} > 0){
|
elsif($todo eq "rental" && $ctadr->{c_id} > 0){
|
||||||
#$ctadr = { c_id => 1842 };
|
#$ctadr = { c_id => user };
|
||||||
#$ct_bike = { txt22 => "380116b5-0522-43da-ab66-477744a731a3" };
|
#$ct_bike = { txt22 => "380116b5-0522-43da-ab66-47774xxxxxa3" };
|
||||||
my $return = $si->sig_booking(\%varenv,$todo,$ctadr,$ct_bike,$ctpos);
|
my $return = $si->sig_booking(\%varenv,$todo,$ctadr,$ct_bike,$ctpos);
|
||||||
#print $0 . Dumper($return) . "\n";
|
#print $0 . Dumper($return) . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
#live! Fork unlock by lock_state=unlocking request with bike "id"
|
#live! Fork unlock by lock_state=unlocking request with bike "id"
|
||||||
elsif($todo eq "unlock" && $ctadr->{c_id} > 0){
|
elsif($todo eq "unlock" && $ctadr->{c_id} > 0){
|
||||||
#$ctadr = { c_id => 1842 };
|
#$ctadr = { c_id => user };
|
||||||
#$ct_bike = { txt22 => "380116b5-0522-43da-ab66-477744a731a3" };
|
#$ct_bike = { txt22 => "380116b5-0522-43da-ab66-47774xxxxxa3" };
|
||||||
my $return = $si->sig_unlock(\%varenv,$todo,$ctadr,$ct_bike,$ctpos);
|
my $return = $si->sig_unlock(\%varenv,$todo,$ctadr,$ct_bike,$ctpos);
|
||||||
#print $0 . Dumper($return) . "\n";
|
#print $0 . Dumper($return) . "\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
#!/usr/bin/perl
|
|
||||||
#
|
|
||||||
#sudo su www-data -c "./src/scripts/sms_gtx_SMSTransport.pl shareeapp-operator '+491799xxxx72'"
|
|
||||||
#
|
|
||||||
use vars qw($syshost);
|
|
||||||
|
|
||||||
BEGIN {
|
|
||||||
$syshost = $ARGV[0] || die 'syshost not defined';
|
|
||||||
}
|
|
||||||
|
|
||||||
use lib "/var/www/copri4/$syshost/src";
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
use warnings;
|
|
||||||
use POSIX;
|
|
||||||
use Mod::SMSTransport;
|
|
||||||
|
|
||||||
my $smstrans = new SMSTransport;
|
|
||||||
|
|
||||||
my $phone = $ARGV[1] || die 'phone not defined';
|
|
||||||
my $adrhash = {
|
|
||||||
txt07 => $phone,
|
|
||||||
txt34 => "nureinlangertestdigest",
|
|
||||||
};
|
|
||||||
|
|
||||||
my $ret_json = $smstrans->sms_ack_digest($adrhash);
|
|
|
@ -3,14 +3,15 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
|
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
|
||||||
#
|
#
|
||||||
|
#Examples
|
||||||
#SMS message if 24h,48h,72h occupied
|
#SMS message if 24h,48h,72h occupied
|
||||||
#sudo su www-data -c "./src/scripts/sms_message.pl shareedms-fr01 '24h_occupied' '' ''"
|
#./src/scripts/sms_message.pl shareedms-operator '24h_occupied' '' ''
|
||||||
#
|
#
|
||||||
#SMS message locking_progress after 60sec
|
#SMS message locking_progress after 60sec
|
||||||
#sudo su www-data -c "./src/scripts/sms_message.pl shareeapp-operator locking_progress '0179xxxx372' $pos_id"
|
#./src/scripts/sms_message.pl shareeapp-operator locking_progress '0179xxxx372' $pos_id
|
||||||
#
|
#
|
||||||
#SMS theftalarm
|
#SMS theftalarm
|
||||||
#sudo su www-data -c "./src/scripts/sms_message.pl shareedms-kn 'send_alarm2hotline' '' '18498'"
|
#./src/scripts/sms_message.pl shareedms-operator 'send_alarm2hotline' '' '18498'
|
||||||
#
|
#
|
||||||
use vars qw($syshost);
|
use vars qw($syshost);
|
||||||
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
../../../../../sharee.bike/copri-bike/main/src/scripts/statistik_amountCSV_files.pl
|
|
276
copri4/main/src/scripts/statistik_amountCSV_files.pl
Executable file
276
copri4/main/src/scripts/statistik_amountCSV_files.pl
Executable file
|
@ -0,0 +1,276 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
|
||||||
|
#
|
||||||
|
#Generates CSV for amount channels and start-station/end-station and Nuter Registrierung
|
||||||
|
#
|
||||||
|
#csv/Statistik-Allnewuser_amount_*
|
||||||
|
#csv/Statistik-channel_amount_*
|
||||||
|
#csv/Statistik-start_end_station_*
|
||||||
|
#csv/Statistik-Bonusnewuser_amount_*
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#Examples
|
||||||
|
#./src/scripts/statistik_amountCSV_files.pl shareedms-operator '' '' '300103'"
|
||||||
|
#
|
||||||
|
#with start_time and end_time
|
||||||
|
#./src/scripts/statistik_amountCSV_files.pl shareedms-operator '2022-01-01' '2022-02-01' '300101'"
|
||||||
|
#./src/scripts/statistik_amountCSV_files.pl shareedms-operator '2022-01-01' '2022-02-01' '300103'"
|
||||||
|
#
|
||||||
|
use vars qw($syshost);
|
||||||
|
|
||||||
|
BEGIN {
|
||||||
|
$syshost = $ARGV[0] || exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
use lib "/var/www/copri-bike/$syshost/src";
|
||||||
|
|
||||||
|
my $start_itime = $ARGV[1] || "";
|
||||||
|
my $end_itime = $ARGV[2] || "";
|
||||||
|
|
||||||
|
#2022-08-03 changed $bikesys int12 select to $bike_type_id int29
|
||||||
|
my $bike_type_id = $ARGV[3] || "";
|
||||||
|
my $flotte_type = "";
|
||||||
|
if($bike_type_id == 300101){
|
||||||
|
$flotte_type = "Lastenrad";
|
||||||
|
}elsif($bike_type_id == 300103){
|
||||||
|
$flotte_type = "Stadtrad";
|
||||||
|
}else{
|
||||||
|
print "Failure, bike_type_id must be nodes.type_id number of Flot\n\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
my $owner = $ARGV[4] || "";
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use utf8;
|
||||||
|
use POSIX;
|
||||||
|
use CGI ':standard';
|
||||||
|
use Lib::Config;
|
||||||
|
use Mod::DBtank;
|
||||||
|
use Scalar::Util qw(looks_like_number);
|
||||||
|
use DateTime;
|
||||||
|
use DateTime::Format::Pg;
|
||||||
|
use Text::CSV_XS;
|
||||||
|
use Sys::Hostname;
|
||||||
|
my $hostname = hostname;
|
||||||
|
|
||||||
|
use Mod::Libenz;
|
||||||
|
use Mod::Pricing;
|
||||||
|
use Mod::APIfunc;
|
||||||
|
|
||||||
|
use Data::Dumper;
|
||||||
|
|
||||||
|
my $q = new CGI;
|
||||||
|
my $cf = new Config;
|
||||||
|
my %varenv = $cf->envonline();
|
||||||
|
#print "host: $varenv{wwwhost}\n";
|
||||||
|
my $dbt = new DBtank;
|
||||||
|
my $lb = new Libenz;
|
||||||
|
my $pri = new Pricing;
|
||||||
|
my $apif = new APIfunc;
|
||||||
|
|
||||||
|
my $dbh = $dbt->dbconnect();
|
||||||
|
|
||||||
|
my $dt1 = DateTime->now(time_zone => 'Europe/Berlin');
|
||||||
|
if(!$end_itime){
|
||||||
|
$end_itime = $dt1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$start_itime){
|
||||||
|
$start_itime = $dt1->clone->add(months => -1, end_of_month => 'preserve');
|
||||||
|
}
|
||||||
|
|
||||||
|
my $month = $1 if($start_itime =~ /\d{4}-(\d{2})-\d{2}/);
|
||||||
|
$month = sprintf('%.2d',$month);
|
||||||
|
my $year = $1 if($start_itime =~ /(\d{4})-\d{2}-\d{2}/);
|
||||||
|
|
||||||
|
|
||||||
|
my $channel_map = $dbt->channel_map();
|
||||||
|
my $channel = "ALL";
|
||||||
|
foreach my $id (keys (%$channel_map)){
|
||||||
|
$channel = $channel_map->{$id} if($id eq $owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
my $new_reg=0;
|
||||||
|
my $swk_reg=0;
|
||||||
|
my $swk_i=0;
|
||||||
|
|
||||||
|
#collect new users in time-range
|
||||||
|
my $adr_search = {
|
||||||
|
table => "contentadr",
|
||||||
|
fetch => "all",
|
||||||
|
keyfield => "c_id",
|
||||||
|
int09 => "is::null", #not Service App staff
|
||||||
|
};
|
||||||
|
$adr_search = { %$adr_search , owner => $owner } if($owner && $owner =~ /^\d+$/);
|
||||||
|
$adr_search = { %$adr_search , start_itime => ">=::$start_itime" } if($start_itime);
|
||||||
|
$adr_search = { %$adr_search , end_itime => "<::$end_itime" } if($end_itime);
|
||||||
|
my $adr = $dbt->fetch_tablerecord($dbh,$adr_search);
|
||||||
|
|
||||||
|
|
||||||
|
foreach my $id (sort { $adr->{$a}->{itime} cmp $adr->{$b}->{itime} }keys (%$adr)){
|
||||||
|
#mailAck && smsAck
|
||||||
|
if($adr->{$id}->{int04} && $adr->{$id}->{int04} == 1 && $adr->{$id}->{int13} && $adr->{$id}->{int13} == 1){
|
||||||
|
|
||||||
|
$new_reg++;
|
||||||
|
|
||||||
|
#New SWK Bonus registrations
|
||||||
|
if($adr->{$id}->{txt15} && $adr->{$id}->{txt15} =~ /\d+/){
|
||||||
|
$swk_reg++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#fetch all stations
|
||||||
|
my $pref = {
|
||||||
|
table => "content",
|
||||||
|
fetch => "all",
|
||||||
|
keyfield => "int04",
|
||||||
|
main_id => "=::300016",
|
||||||
|
template_id => "225",
|
||||||
|
int04 => "!=::99",#virtual station
|
||||||
|
int10 => "1", #available
|
||||||
|
txt01 => "not ilike::%Contributor%",
|
||||||
|
};
|
||||||
|
my $station_rec = $dbt->fetch_record($dbh,$pref);
|
||||||
|
|
||||||
|
|
||||||
|
#Statistik-start_end_station
|
||||||
|
my $csv_start_station = Text::CSV_XS->new ({ binary => 1, sep_char => ";", eol => "\r\n" });
|
||||||
|
my $filename_start_station = "Statistik-start_end_station_$year-$month-$flotte_type.csv";
|
||||||
|
open my $sstation, ">", "$varenv{csv}/$filename_start_station" or die "$filename_start_station: $!\n";
|
||||||
|
my @start_station = ("$year-$month Station","Menge Anmietungen/Rueckgaben");
|
||||||
|
$csv_start_station->print($sstation, \@start_station);#$start_station CSV header
|
||||||
|
|
||||||
|
#Statistik-channel_amount
|
||||||
|
my $csv_amount = Text::CSV_XS->new ({ binary => 1, sep_char => ";", eol => "\r\n" });
|
||||||
|
my $filename_amount = "Statistik-channel_amount_$year-$month-$flotte_type.csv";
|
||||||
|
open my $aamount, ">", "$varenv{csv}/$filename_amount" or die "$filename_amount: $!\n";
|
||||||
|
my @amount = ("$year-$month $flotte_type","Menge");
|
||||||
|
$csv_amount->print($aamount, \@amount);#$amount CSV header:
|
||||||
|
|
||||||
|
#Statistik-Allnewuser_amount
|
||||||
|
my $csv_allamount = Text::CSV_XS->new ({ binary => 1, sep_char => ";", eol => "\r\n" });
|
||||||
|
my $filename_allamount = "Statistik-Allnewuser_amount_$year-$month.csv";
|
||||||
|
open my $allaamount, ">", "$varenv{csv}/$filename_allamount" or die "$filename_allamount: $!\n";
|
||||||
|
my @allamount = ("$year-$month Gesamtanzahl Neuregistrierungen","Menge");
|
||||||
|
$csv_allamount->print($allaamount, \@allamount);#$allamount CSV header:
|
||||||
|
$csv_allamount->print($allaamount, ["neue NutzerInnen","$new_reg"]);
|
||||||
|
print "Neue NutzerInnen: $new_reg\n";
|
||||||
|
|
||||||
|
#Statistik-Bonusnewuser_amount
|
||||||
|
my $csv_swkamount = Text::CSV_XS->new ({ binary => 1, sep_char => ";", eol => "\r\n" });
|
||||||
|
my $filename_swkamount = "Statistik-Bonusnewuser_amount_$year-$month.csv";
|
||||||
|
open my $swkaamount, ">", "$varenv{csv}/$filename_swkamount" or die "$filename_swkamount: $!\n";
|
||||||
|
my @swkamount = ("$year-$month Gesamtanzahl Neuregistrierungen Bonusnummer","Menge");
|
||||||
|
$csv_swkamount->print($swkaamount, \@swkamount);#$swkamount CSV header:
|
||||||
|
$csv_swkamount->print($swkaamount, ["neue NutzerInnen mit Bonus Tarif","$swk_reg"]);
|
||||||
|
print "Neue NutzerInnen mit Bonus Tarif: $swk_reg\n";
|
||||||
|
|
||||||
|
my $sum_minutes=0;
|
||||||
|
my $sum_hours=0;
|
||||||
|
my $pricing = {};
|
||||||
|
my $counting = {};
|
||||||
|
my $diff_station = 0;
|
||||||
|
|
||||||
|
#station hash init
|
||||||
|
my $start_station = {};
|
||||||
|
my $end_station = {};
|
||||||
|
foreach my $int04_id (sort { $station_rec->{$a}->{int04} <=> $station_rec->{$b}->{int04} } keys (%$station_rec)){
|
||||||
|
$start_station->{$int04_id} = 0;
|
||||||
|
$end_station->{$int04_id} = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $pos_search = {
|
||||||
|
table => "contenttranspos",
|
||||||
|
fetch => "all",
|
||||||
|
keyfield => "c_id",
|
||||||
|
#int04 => "!=::99",#virtual end-station
|
||||||
|
int05 => "is::null",#not if sub workflow doc
|
||||||
|
int06 => "!=::99",#virtual start-station
|
||||||
|
int29 => "$bike_type_id",#nodes.type_id
|
||||||
|
int34 => "is::null",#not if staff
|
||||||
|
};
|
||||||
|
$pos_search->{owner} = $owner if($owner && $owner =~ /^\d+$/);
|
||||||
|
$pos_search->{start_time} = ">=::$start_itime" if($start_itime);
|
||||||
|
$pos_search->{end_time} = "<::$end_itime" if($end_itime);
|
||||||
|
my $pos = $dbt->fetch_tablerecord($dbh,$pos_search);
|
||||||
|
|
||||||
|
#Loop rental positions alias Mietjournal
|
||||||
|
foreach my $id (sort { $pos->{$a}->{mtime} cmp $pos->{$b}->{mtime} }keys (%$pos)){
|
||||||
|
|
||||||
|
($pricing->{$id},my $counting) = $pri->counting_rental(\%varenv,$pos->{$id});
|
||||||
|
|
||||||
|
#umsatz by tarif-nr in int09
|
||||||
|
if($pos->{$id}->{template_id} && $pos->{$id}->{template_id} == 205 && $pos->{$id}->{int09} && $pos->{$id}->{int35} && $pos->{$id}->{int10} == 1 && $pricing->{$id}->{rentalog}->{rental_minute_all} && $pricing->{$id}->{rentalog}->{rental_minute_all} > 0){
|
||||||
|
|
||||||
|
#if sharing type public-bonus = 5
|
||||||
|
if($pos->{$id}->{int18} && $pos->{$id}->{int18} == 5){
|
||||||
|
$swk_i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($pos->{$id}->{int06} && exists($start_station->{$pos->{$id}->{int06}})){
|
||||||
|
$start_station->{$pos->{$id}->{int06}} += 1;
|
||||||
|
}elsif($pos->{$id}->{int04} && exists($start_station->{$pos->{$id}->{int04}})){
|
||||||
|
$start_station->{$pos->{$id}->{int04}} += 1;
|
||||||
|
}
|
||||||
|
$end_station->{$pos->{$id}->{int04}} += 1 if($pos->{$id}->{int04} && exists($start_station->{$pos->{$id}->{int04}}));
|
||||||
|
$diff_station += 1 if($pos->{$id}->{int06} && $pos->{$id}->{int04} && $pos->{$id}->{int06} != $pos->{$id}->{int04});
|
||||||
|
|
||||||
|
$sum_minutes += $pricing->{$id}->{rentalog}->{rental_minute_all};
|
||||||
|
}
|
||||||
|
}#end Loop rental
|
||||||
|
|
||||||
|
#Service pos
|
||||||
|
my $pos_partref = {
|
||||||
|
table => "contenttranspos",
|
||||||
|
fetch => "all",
|
||||||
|
keyfield => "c_id",
|
||||||
|
int05 => "is::null",#not if sub workflow doc
|
||||||
|
start_itime => ">=::$start_itime",
|
||||||
|
end_itime => "<::$end_itime",
|
||||||
|
};
|
||||||
|
my $pos_part = $dbt->fetch_tablerecord($dbh,$pos_partref);
|
||||||
|
|
||||||
|
$sum_hours = $sum_minutes / 60 if($sum_minutes > 0);
|
||||||
|
$sum_hours = sprintf('%.2f',$sum_hours);
|
||||||
|
$sum_hours =~ s/\./,/;
|
||||||
|
$csv_amount->print($aamount, ["Gesamtnutzungsstunden im Gesamtsystem","$sum_hours"]);
|
||||||
|
print "Gesamtnutzungsstunden im Gesamtsystem: $sum_hours\n";
|
||||||
|
|
||||||
|
my $count_start = 0;
|
||||||
|
foreach my $stid (sort { $a <=> $b } (keys (%$start_station))){
|
||||||
|
$count_start += $start_station->{$stid};
|
||||||
|
my @start_station_line = ("start-Station $stid","$start_station->{$stid}");
|
||||||
|
$csv_start_station->print($sstation, \@start_station_line);#foreach line
|
||||||
|
}
|
||||||
|
print "Count start_station: $count_start\n";
|
||||||
|
|
||||||
|
my $count_end = 0;
|
||||||
|
foreach my $stid (sort { $a <=> $b } (keys (%$end_station))){
|
||||||
|
$count_end += $end_station->{$stid};
|
||||||
|
my @end_station_line = ("end-Station $stid","$end_station->{$stid}");
|
||||||
|
$csv_start_station->print($sstation, \@end_station_line);#foreach line
|
||||||
|
}
|
||||||
|
print "Count end_station: $count_end\n";
|
||||||
|
|
||||||
|
$csv_amount->print($aamount, ["APP Anmietungen","$count_start"]);
|
||||||
|
print "APP Anmietungen: $count_start\n";
|
||||||
|
|
||||||
|
$csv_amount->print($aamount, ["Gesamtanzahl Anmietungen im Gesamtsystem","$count_start"]);
|
||||||
|
print "Gesamtanzahl Anmietungen im Gesamtsystem: $count_start\n";
|
||||||
|
|
||||||
|
|
||||||
|
$csv_amount->print($aamount, ["One-Way-Fahrten","$diff_station"]);
|
||||||
|
print "\nAnteil One-Way-Fahrten: $diff_station\n";
|
||||||
|
|
||||||
|
if($swk_i){
|
||||||
|
$csv_amount->print($aamount, ["Anmietungen mit Bonusnummer","$swk_i"]);
|
||||||
|
print "Anmietungen mit Bonusnummer: $swk_i\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
../../../../../sharee.bike/copri-bike/main/src/scripts/statistik_dailystation.pl
|
|
81
copri4/main/src/scripts/statistik_dailystation.pl
Executable file
81
copri4/main/src/scripts/statistik_dailystation.pl
Executable file
|
@ -0,0 +1,81 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
|
||||||
|
#
|
||||||
|
#./src/scripts/statistik_dailystation.pl shareedms-operator"
|
||||||
|
#
|
||||||
|
#
|
||||||
|
use vars qw($syshost);
|
||||||
|
|
||||||
|
BEGIN {
|
||||||
|
$syshost = $ARGV[0] || exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
use lib "/var/www/copri-bike/$syshost/src";
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use POSIX;
|
||||||
|
use CGI ':standard';
|
||||||
|
use Lib::Config;
|
||||||
|
use Scalar::Util qw(looks_like_number);
|
||||||
|
use DateTime;
|
||||||
|
use DateTime::Format::Pg;
|
||||||
|
use Mod::DBtank;
|
||||||
|
use Data::Dumper;
|
||||||
|
|
||||||
|
my $q = new CGI;
|
||||||
|
my $cf = new Config;
|
||||||
|
my $dbt = new DBtank;
|
||||||
|
|
||||||
|
my $dbh = "";
|
||||||
|
my $now_dt = strftime "%Y-%m-%d", localtime;
|
||||||
|
|
||||||
|
my $pref_st = {
|
||||||
|
table => "content",
|
||||||
|
fetch => "all",
|
||||||
|
keyfield => "int04",
|
||||||
|
template_id => "225",
|
||||||
|
};
|
||||||
|
my $ct4rel_st = $dbt->fetch_record($dbh,$pref_st);
|
||||||
|
|
||||||
|
my $pref_bi = {
|
||||||
|
table => "content",
|
||||||
|
fetch => "all",
|
||||||
|
keyfield => "barcode",
|
||||||
|
template_id => "205",
|
||||||
|
};
|
||||||
|
my $ct4rel = $dbt->fetch_record($dbh,$pref_bi);
|
||||||
|
|
||||||
|
my $station_bikes = {};
|
||||||
|
|
||||||
|
#foreach station
|
||||||
|
foreach my $st (sort { $ct4rel_st->{$a}->{int04} <=> $ct4rel_st->{$b}->{int04} } keys (%$ct4rel_st)){
|
||||||
|
$station_bikes->{$ct4rel_st->{$st}->{int04}}->{on}->{bikes} = "";
|
||||||
|
$station_bikes->{$ct4rel_st->{$st}->{int04}}->{off}->{bikes} = "";
|
||||||
|
|
||||||
|
#foreach bike
|
||||||
|
foreach my $cpid (sort { $ct4rel->{$a}->{barcode} <=> $ct4rel->{$b}->{barcode} } keys (%$ct4rel)){
|
||||||
|
if(($ct4rel->{$cpid}->{barcode} && $ct4rel->{$cpid}->{barcode} > 0) && ($ct4rel->{$cpid}->{int04} && $ct4rel_st->{$st}->{int04} == $ct4rel->{$cpid}->{int04})){
|
||||||
|
|
||||||
|
if($ct4rel->{$cpid}->{int10} && $ct4rel->{$cpid}->{int10} =~ /1|2|3/){
|
||||||
|
$station_bikes->{$ct4rel_st->{$st}->{int04}}->{on}->{bikes} .= "$ct4rel->{$cpid}->{barcode},";
|
||||||
|
}elsif($ct4rel->{$cpid}->{int10} && $ct4rel->{$cpid}->{int10} =~ /4|5/){
|
||||||
|
$station_bikes->{$ct4rel_st->{$st}->{int04}}->{off}->{bikes} .= "$ct4rel->{$cpid}->{barcode},";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$station_bikes->{$ct4rel_st->{$st}->{int04}}->{on}->{bikes} =~ s/,$// if($station_bikes->{$ct4rel_st->{$st}->{int04}}->{on}->{bikes});
|
||||||
|
$station_bikes->{$ct4rel_st->{$st}->{int04}}->{off}->{bikes} =~ s/,$// if($station_bikes->{$ct4rel_st->{$st}->{int04}}->{off}->{bikes});
|
||||||
|
|
||||||
|
print "Registered on station: $ct4rel_st->{$st}->{int04} --> bikes_on: $station_bikes->{$ct4rel_st->{$st}->{int04}}->{on}->{bikes} --> bikes_off: $station_bikes->{$ct4rel_st->{$st}->{int04}}->{off}->{bikes}\n";
|
||||||
|
my $sethash = {
|
||||||
|
station => $ct4rel_st->{$st}->{int04},
|
||||||
|
bikes_on => "$station_bikes->{$ct4rel_st->{$st}->{int04}}->{on}->{bikes}",
|
||||||
|
bikes_off => "$station_bikes->{$ct4rel_st->{$st}->{int04}}->{off}->{bikes}",
|
||||||
|
};
|
||||||
|
$dbt->insert_contenthash($dbh,"statistik",$sethash);
|
||||||
|
}
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
../../../../../sharee.bike/copri-bike/main/src/scripts/statistik_monthlyCSV.pl
|
|
|
@ -1 +0,0 @@
|
||||||
../../../../../sharee.bike/copri-bike/main/src/scripts/statistik_occubike_stationCSV.pl
|
|
279
copri4/main/src/scripts/statistik_occubike_stationCSV.pl
Executable file
279
copri4/main/src/scripts/statistik_occubike_stationCSV.pl
Executable file
|
@ -0,0 +1,279 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
#
|
||||||
|
## SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
|
||||||
|
#
|
||||||
|
#csv/Statistik-average_bike_*
|
||||||
|
#csv/Statistik-occubike_station_*
|
||||||
|
#csv/Statistik-average_user_*
|
||||||
|
#
|
||||||
|
#Example citybike
|
||||||
|
#./src/scripts/statistik_occubike_stationCSV.pl shareedms-operator '2022-01-01' '2022-02-01' '300103'
|
||||||
|
#
|
||||||
|
#Example cargobike
|
||||||
|
#Without date defaults to duration of last 1 month up to now
|
||||||
|
#./src/scripts/statistik_occubike_stationCSV.pl shareedms-operator '' '' '300101'
|
||||||
|
#
|
||||||
|
#
|
||||||
|
use vars qw($syshost);
|
||||||
|
|
||||||
|
BEGIN {
|
||||||
|
$syshost = $ARGV[0] || exit 1;
|
||||||
|
}
|
||||||
|
use lib "/var/www/copri-bike/$syshost/src";
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use feature qw(say);
|
||||||
|
use POSIX;
|
||||||
|
use CGI ':standard';
|
||||||
|
use Lib::Config;
|
||||||
|
use Scalar::Util qw(looks_like_number);
|
||||||
|
use DateTime;
|
||||||
|
use DateTime::Format::Pg;
|
||||||
|
use Text::CSV_XS;
|
||||||
|
use Mod::DBtank;
|
||||||
|
use Mod::Pricing;
|
||||||
|
|
||||||
|
use Data::Dumper;
|
||||||
|
|
||||||
|
my $q = new CGI;
|
||||||
|
my $cf = new Config;
|
||||||
|
my %varenv = $cf->envonline();
|
||||||
|
my $dbt = new DBtank;
|
||||||
|
my $pri = new Pricing;
|
||||||
|
|
||||||
|
my $dbh = $dbt->dbconnect();
|
||||||
|
|
||||||
|
my $start_itime = "";
|
||||||
|
my $end_itime = "";
|
||||||
|
my $filename = "";
|
||||||
|
|
||||||
|
#If NO date on command then now
|
||||||
|
my $dt1 = DateTime->now(time_zone => 'Europe/Berlin');
|
||||||
|
if($ARGV[2] && $ARGV[2] =~ /(\d{4})-(\d{2})-(\d{2})/){
|
||||||
|
$end_itime = DateTime->new(
|
||||||
|
year => $1,
|
||||||
|
month => $2,
|
||||||
|
day => $3,
|
||||||
|
time_zone => 'Europe/Berlin',
|
||||||
|
);
|
||||||
|
}else{
|
||||||
|
$end_itime = $dt1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($ARGV[1] && $ARGV[1] =~ /(\d{4})-(\d{2})-(\d{2})/){
|
||||||
|
$start_itime = DateTime->new(
|
||||||
|
year => $1,
|
||||||
|
month => $2,
|
||||||
|
day => $3,
|
||||||
|
time_zone => 'Europe/Berlin',
|
||||||
|
);
|
||||||
|
}else{
|
||||||
|
$start_itime = $end_itime->clone->add(months => -1, end_of_month => 'preserve');
|
||||||
|
}
|
||||||
|
|
||||||
|
#2022-08-03 changed $bikesys int12 select to $bike_type_id int29
|
||||||
|
my $bike_type_id = $ARGV[3] || "";
|
||||||
|
my $flotte = "";
|
||||||
|
if($bike_type_id == 300101){
|
||||||
|
$flotte = "Lastenrad";
|
||||||
|
}elsif($bike_type_id == 300103){
|
||||||
|
$flotte = "Stadtrad";
|
||||||
|
}else{
|
||||||
|
print "Failure, bike_type_id must be nodes.type_id number of Flot\n\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $month = $start_itime->month;
|
||||||
|
$month = sprintf('%.2d',$month);
|
||||||
|
my $year = $start_itime->year;
|
||||||
|
|
||||||
|
my $sendref = {
|
||||||
|
mail_from => "",
|
||||||
|
mail_to => "ragu\@gnu-systems.de",
|
||||||
|
subject => "$syshost $bike_type_id statistik_occubike_stationCSV $year-$month",
|
||||||
|
message => "",
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
$sendref->{message} .= "\nCSV Generation and debugging\n$syshost $bike_type_id $flotte Statistik occupied bike on station $start_itime - $end_itime\n";
|
||||||
|
$sendref->{message} .= "CSV Attachemnt will be sent by loop_statistik_monthly.pl after CSV generation to get it\n\n";
|
||||||
|
|
||||||
|
my $month_days = DateTime->last_day_of_month(
|
||||||
|
year => $year,
|
||||||
|
month => $month,
|
||||||
|
);
|
||||||
|
my $days = $1 if($month_days =~ /\d{4}-\d{2}-(\d{2})/);
|
||||||
|
$sendref->{message} .= "occubike on station\n";
|
||||||
|
|
||||||
|
#fetch stations
|
||||||
|
my $pref = {
|
||||||
|
table => "content",
|
||||||
|
fetch => "all",
|
||||||
|
keyfield => "int04",
|
||||||
|
main_id => "=::300016",
|
||||||
|
template_id => "225",
|
||||||
|
int04 => "!=::99",
|
||||||
|
int10 => 1, #available
|
||||||
|
txt01 => "not ilike::%Contributor%",
|
||||||
|
};
|
||||||
|
my $station_rec = $dbt->fetch_record($dbh,$pref);
|
||||||
|
|
||||||
|
#fetch all bikes
|
||||||
|
my $pref_b = {
|
||||||
|
table => "content",
|
||||||
|
fetch => "all",
|
||||||
|
keyfield => "barcode",
|
||||||
|
barcode => ">::0",
|
||||||
|
template_id => "205",
|
||||||
|
};
|
||||||
|
my $bikes_rec = $dbt->fetch_record($dbh,$pref_b);
|
||||||
|
my $bike_stat = {};
|
||||||
|
my $adr_stat = {};
|
||||||
|
|
||||||
|
|
||||||
|
#fetch contenttranspos
|
||||||
|
my $pos_search = {
|
||||||
|
table => "contenttranspos",
|
||||||
|
fetch => "all",
|
||||||
|
keyfield => "c_id",
|
||||||
|
#int04 => "!=::99",#virtuel end-station
|
||||||
|
int05 => "is::null",#not if sub workflow doc
|
||||||
|
int06 => "!=::99",#virtuel start-station
|
||||||
|
int29 => "$bike_type_id",#nodes.type_id
|
||||||
|
int34 => "is::null",#not if staff
|
||||||
|
};
|
||||||
|
$pos_search->{start_time} = ">=::$start_itime" if($start_itime);
|
||||||
|
$pos_search->{end_time} = "<::$end_itime" if($end_itime);
|
||||||
|
my $pos = $dbt->fetch_tablerecord($dbh,$pos_search);
|
||||||
|
|
||||||
|
#print "fetching bookings: Start >= $start_itime End < $end_itime\n";
|
||||||
|
|
||||||
|
my @stations = ("$year-$month Mietmenge Rad/Station");
|
||||||
|
foreach my $int04_id (sort { $station_rec->{$a}->{int04} <=> $station_rec->{$b}->{int04} } keys (%$station_rec)){
|
||||||
|
push(@stations,$station_rec->{$int04_id}->{int04});
|
||||||
|
}
|
||||||
|
|
||||||
|
#Statistik-occubike_station
|
||||||
|
my $csv = Text::CSV_XS->new ({ binary => 1, sep_char => ";", eol => "\r\n" });
|
||||||
|
my $filename_fhda = "Statistik-occubike_station_$year-$month-$flotte.csv";
|
||||||
|
open my $fhda, ">", "$varenv{csv}/$filename_fhda" or die "$filename_fhda: $!\n";
|
||||||
|
$csv->print($fhda, \@stations);#Stations CSV header
|
||||||
|
|
||||||
|
#Statistik-average_bike
|
||||||
|
my $csv_average_bike = Text::CSV_XS->new ({ binary => 1, sep_char => ";", eol => "\r\n" });
|
||||||
|
my $filename_average_bike = "Statistik-average_bike_$year-$month-$flotte.csv";
|
||||||
|
open my $abike, ">", "$varenv{csv}/$filename_average_bike" or die "$filename_average_bike: $!\n";
|
||||||
|
my @average_bike = ("$year-$month Nutzung/Rad","Anzahl","Gesamt Std","Durchschnitt Std","Gesamt KM","Durchschnitt KM");
|
||||||
|
$csv_average_bike->print($abike, \@average_bike);#$average_bike CSV header
|
||||||
|
|
||||||
|
#Statistik-average_user
|
||||||
|
my $csv_average_user = Text::CSV_XS->new ({ binary => 1, sep_char => ";", eol => "\r\n" });
|
||||||
|
my $filename_average_user = "Statistik-average_user_$year-$month-$flotte.csv";
|
||||||
|
open my $auser, ">", "$varenv{csv}/$filename_average_user" or die "$filename_average_user: $!\n";
|
||||||
|
my @average_user = ("$year-$month Nutzung/Nutzer","Anzahl","Gesamt Std","Durchschnitt Std");
|
||||||
|
$csv_average_user->print($auser, \@average_user);#$average_user CSV header
|
||||||
|
|
||||||
|
|
||||||
|
if(1==1){
|
||||||
|
my $pricing = {};
|
||||||
|
my $rental = {};
|
||||||
|
#loop bookings
|
||||||
|
foreach my $c_id (sort { $pos->{$a}->{barcode} <=> $pos->{$b}->{barcode} } keys (%$pos)){
|
||||||
|
($pricing->{$c_id},my $counting) = $pri->counting_rental(\%varenv,$pos->{$c_id});
|
||||||
|
|
||||||
|
if($pos->{$c_id}->{int10} == 1 && $pricing->{$c_id}->{rentalog}->{rental_minute_all} && $pricing->{$c_id}->{rentalog}->{rental_minute_all} > 0){
|
||||||
|
#print "$pos->{$c_id}->{barcode} --> rental_minute_all: $pricing->{$c_id}->{rentalog}->{rental_minute_all}\n";
|
||||||
|
|
||||||
|
if($pos->{$c_id}->{ca_id}){
|
||||||
|
|
||||||
|
#if($adr_one->{c_id}){
|
||||||
|
if(1==1){
|
||||||
|
$adr_stat->{$pos->{$c_id}->{ca_id}}->{c_id} = $pos->{$c_id}->{ca_id};
|
||||||
|
$adr_stat->{$pos->{$c_id}->{ca_id}}->{counter}++;
|
||||||
|
$adr_stat->{$pos->{$c_id}->{ca_id}}->{minutes} += $pricing->{$c_id}->{rentalog}->{rental_minute_all};
|
||||||
|
$adr_stat->{$pos->{$c_id}->{ca_id}}->{hours} = $adr_stat->{$pos->{$c_id}->{ca_id}}->{minutes} / 60 if($adr_stat->{$pos->{$c_id}->{ca_id}}->{minutes});
|
||||||
|
|
||||||
|
|
||||||
|
$bike_stat->{$pos->{$c_id}->{barcode}}->{counter}++;
|
||||||
|
$bike_stat->{$pos->{$c_id}->{barcode}}->{minutes} += $pricing->{$c_id}->{rentalog}->{rental_minute_all};
|
||||||
|
$bike_stat->{$pos->{$c_id}->{barcode}}->{hours} = $bike_stat->{$pos->{$c_id}->{barcode}}->{minutes} / 60 if($bike_stat->{$pos->{$c_id}->{barcode}}->{minutes});
|
||||||
|
$bike_stat->{$pos->{$c_id}->{barcode}}->{km} += $pos->{$c_id}->{int26} if($pos->{$c_id}->{int26});
|
||||||
|
|
||||||
|
foreach my $int04_id (sort { $station_rec->{$a}->{int04} <=> $station_rec->{$b}->{int04} } keys (%$station_rec)){
|
||||||
|
|
||||||
|
if(($pos->{$c_id}->{int06} && $station_rec->{$int04_id}->{int04}) && ($pos->{$c_id}->{int06} == $station_rec->{$int04_id}->{int04})){
|
||||||
|
$rental->{$pos->{$c_id}->{barcode}}->{$station_rec->{$int04_id}->{int04}}++;#counter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#print Dumper($rental) . "\n";
|
||||||
|
|
||||||
|
#Durchschnittliche Gesamtnutzungsdauer pro NutzerIn";
|
||||||
|
foreach my $a_id (sort { $adr_stat->{$a}->{c_id} <=> $adr_stat->{$b}->{c_id} } keys(%$adr_stat)){
|
||||||
|
if($adr_stat->{$a_id}->{hours} > 0 && $adr_stat->{$a_id}->{counter} > 0){
|
||||||
|
my $hours = sprintf('%.2f',$adr_stat->{$a_id}->{hours});
|
||||||
|
my $average = sprintf('%.2f',$hours / $adr_stat->{$a_id}->{counter});
|
||||||
|
$hours =~ s/\./,/;
|
||||||
|
$average =~ s/\./,/;
|
||||||
|
|
||||||
|
my @average_user_line = ("Nutzer ID:$adr_stat->{$a_id}->{c_id}","$adr_stat->{$a_id}->{counter}","$hours","$average");
|
||||||
|
$csv_average_user->print($auser, \@average_user_line);#foreach user one line
|
||||||
|
|
||||||
|
$sendref->{message} .= "Nutzer ID:$adr_stat->{$a_id}->{c_id}, $hours Std / $adr_stat->{$a_id}->{counter} Menge = $average Std im Durchschnitt\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#Generate bike/station CSV-lines
|
||||||
|
foreach my $b_id (sort { $bikes_rec->{$a}->{barcode} <=> $bikes_rec->{$b}->{barcode} } keys(%$bikes_rec)){
|
||||||
|
if($bikes_rec->{$b_id}->{type_id} == $bike_type_id && $bikes_rec->{$b_id}->{node_name} !~ /Contributor/i){
|
||||||
|
|
||||||
|
#Durchschnittliche Nutzungsdauer pro Rad
|
||||||
|
my $km = $bike_stat->{$b_id}->{km} || 0;
|
||||||
|
my $km_average = 0;
|
||||||
|
my $hours = $bike_stat->{$b_id}->{hours} || 0;
|
||||||
|
my $counter = $bike_stat->{$b_id}->{counter} || 0;
|
||||||
|
my $average = 0;
|
||||||
|
if($hours > 0){
|
||||||
|
$hours = sprintf('%.2f',$bike_stat->{$b_id}->{hours});
|
||||||
|
$average = sprintf('%.2f',$hours / $counter);
|
||||||
|
$hours =~ s/\./,/;
|
||||||
|
$average =~ s/\./,/;
|
||||||
|
}
|
||||||
|
if($km > 0){
|
||||||
|
$km = sprintf('%.2f',$bike_stat->{$b_id}->{km});
|
||||||
|
$km_average = sprintf('%.2f',$km / $counter);
|
||||||
|
$km =~ s/\./,/;
|
||||||
|
$km_average =~ s/\./,/;
|
||||||
|
}
|
||||||
|
|
||||||
|
my @average_bike_line = ("$bikes_rec->{$b_id}->{txt01} Nr. $b_id","$counter","$hours","$average","$km","$km_average");
|
||||||
|
$csv_average_bike->print($abike, \@average_bike_line);#foreach bike one line
|
||||||
|
|
||||||
|
$sendref->{message} .= "$bikes_rec->{$b_id}->{txt01} Nr. $b_id, $hours Std / $counter Miete = $average Std im Durchschnitt\n";
|
||||||
|
|
||||||
|
my @bike_station_array = ("$bikes_rec->{$b_id}->{txt01}, Nr. $b_id");
|
||||||
|
my $i = 0;
|
||||||
|
foreach my $int04_id (sort { $station_rec->{$a}->{int04} <=> $station_rec->{$b}->{int04} } keys (%$station_rec)){
|
||||||
|
$i++;
|
||||||
|
if($rental->{$b_id}->{$int04_id}){
|
||||||
|
#print "bike: $b_id, station: $int04_id --> count: $rental->{$b_id}->{$int04_id}\n";
|
||||||
|
#print "-> Stations count: " . Dumper($rental->{$b_id}->{$int04_id}) . "\n";
|
||||||
|
$bike_station_array[$i] = $rental->{$b_id}->{$int04_id} || 0;#Stations count
|
||||||
|
#print "--> Stations count: " . Dumper(\@bike_station_array) . "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$csv->print($fhda, \@bike_station_array);#foreach bike one line
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}#end if
|
||||||
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
../../../../../sharee.bike/copri-bike/main/src/scripts/statistik_occubike_stationCSV_innofact.pl
|
|
|
@ -1 +0,0 @@
|
||||||
../../../../../sharee.bike/copri-bike/main/src/scripts/statistik_userevaluation.pl
|
|
117
copri4/main/src/scripts/statistik_userevaluation.pl
Executable file
117
copri4/main/src/scripts/statistik_userevaluation.pl
Executable file
|
@ -0,0 +1,117 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
|
||||||
|
#
|
||||||
|
#with date range
|
||||||
|
#./src/scripts/statistik_userevaluation.pl shareedms-operator '2022-01-01' '2022-02-01'
|
||||||
|
#
|
||||||
|
#Without date defaults to duration of last 1 month up to now
|
||||||
|
#./src/scripts/statistik_userevaluation.pl shareedms-operator '' ''
|
||||||
|
#
|
||||||
|
#
|
||||||
|
use vars qw($syshost);
|
||||||
|
|
||||||
|
BEGIN {
|
||||||
|
$syshost = $ARGV[0] || exit 1;
|
||||||
|
}
|
||||||
|
use lib "/var/www/copri-bike/$syshost/src";
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
#use warnings;
|
||||||
|
use feature qw(say);
|
||||||
|
use POSIX;
|
||||||
|
use CGI ':standard';
|
||||||
|
use Lib::Config;
|
||||||
|
use Scalar::Util qw(looks_like_number);
|
||||||
|
use DateTime;
|
||||||
|
use DateTime::Format::Pg;
|
||||||
|
use Text::CSV_XS;
|
||||||
|
use Mod::Libenz;
|
||||||
|
use Mod::DBtank;
|
||||||
|
|
||||||
|
use Data::Dumper;
|
||||||
|
|
||||||
|
my $q = new CGI;
|
||||||
|
my $cf = new Config;
|
||||||
|
my $lb = new Libenz;
|
||||||
|
my $dbt = new DBtank;
|
||||||
|
my %varenv = $cf->envonline();
|
||||||
|
|
||||||
|
my $dbh = $dbt->dbconnect();
|
||||||
|
|
||||||
|
my $start_itime = "";
|
||||||
|
my $end_itime = "";
|
||||||
|
my $filename = "";
|
||||||
|
|
||||||
|
#If NO date on command then now
|
||||||
|
my $dt1 = DateTime->now(time_zone => 'Europe/Berlin');
|
||||||
|
if($ARGV[2] && $ARGV[2] =~ /(\d{4})-(\d{2})-(\d{2})/){
|
||||||
|
$end_itime = DateTime->new(
|
||||||
|
year => $1,
|
||||||
|
month => $2,
|
||||||
|
day => $3,
|
||||||
|
time_zone => 'Europe/Berlin',
|
||||||
|
);
|
||||||
|
}else{
|
||||||
|
$end_itime = $dt1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($ARGV[1] && $ARGV[1] =~ /(\d{4})-(\d{2})-(\d{2})/){
|
||||||
|
$start_itime = DateTime->new(
|
||||||
|
year => $1,
|
||||||
|
month => $2,
|
||||||
|
day => $3,
|
||||||
|
time_zone => 'Europe/Berlin',
|
||||||
|
);
|
||||||
|
}else{
|
||||||
|
$start_itime = $end_itime->clone->add(months => -1, end_of_month => 'preserve');
|
||||||
|
}
|
||||||
|
|
||||||
|
my $month = $start_itime->month;
|
||||||
|
$month = sprintf('%.2d',$month);
|
||||||
|
my $year = $start_itime->year;
|
||||||
|
|
||||||
|
my $month_days = DateTime->last_day_of_month(
|
||||||
|
year => $year,
|
||||||
|
month => $month,
|
||||||
|
);
|
||||||
|
my $days = $1 if($month_days =~ /\d{4}-\d{2}-(\d{2})/);
|
||||||
|
|
||||||
|
#fetch contentadrpos
|
||||||
|
my $pref_adr = {
|
||||||
|
table => "contentadrpos",
|
||||||
|
fetch => "all",
|
||||||
|
keyfield => "c_id",
|
||||||
|
template_id => 602,#evaluation template_id
|
||||||
|
txt10 => "IN::('MAK','SX','CAD','LEC')",#operators
|
||||||
|
start_mtime => ">=::$start_itime",
|
||||||
|
end_mtime => "<=::$end_itime",
|
||||||
|
};
|
||||||
|
my $adr_rec = $dbt->fetch_tablerecord($dbh,$pref_adr);
|
||||||
|
|
||||||
|
my $csv_minianswer = Text::CSV_XS->new ({ binary => 1, sep_char => ";", eol => "\r\n" });
|
||||||
|
my $filename_minianswer = "Statistik-LastenradBayern-evaluation_$year-$month.csv";
|
||||||
|
open my $auser, ">", "$varenv{csv}/$filename_minianswer" or die "$filename_minianswer: $!\n";
|
||||||
|
my @minianswer = ("$year-$month ID","Zeitstempel","Operator","Antwort zu 1.","Antwort zu 2.","Antwort zu 3.","KM");
|
||||||
|
$csv_minianswer->print($auser, \@minianswer);#CSV header
|
||||||
|
|
||||||
|
|
||||||
|
if(1==1){
|
||||||
|
|
||||||
|
foreach my $a_id (sort { $adr_rec->{$a}->{c_id} <=> $adr_rec->{$b}->{c_id} } keys(%$adr_rec)){
|
||||||
|
#if($adr_rec->{$a_id}->{txt01} || $adr_rec->{$a_id}->{txt02} || $adr_rec->{$a_id}->{txt03}){
|
||||||
|
my $mtime = $lb->time4de($adr_rec->{$a_id}->{mtime},"","");
|
||||||
|
my @minianswer_line = ("$adr_rec->{$a_id}->{c_id}","$mtime","$adr_rec->{$a_id}->{txt10}","$adr_rec->{$a_id}->{txt01}","$adr_rec->{$a_id}->{txt02}","$adr_rec->{$a_id}->{txt03}","$adr_rec->{$a_id}->{int02}");
|
||||||
|
print "\n";
|
||||||
|
foreach (@minianswer_line){
|
||||||
|
print $_ . ";";
|
||||||
|
}
|
||||||
|
print "\n";
|
||||||
|
$csv_minianswer->print($auser, \@minianswer_line);#foreach one line
|
||||||
|
|
||||||
|
#}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
../../../../../sharee.bike/copri-bike/main/src/scripts/statistik_zip_transport.pl
|
|
63
copri4/main/src/scripts/statistik_zip_transport.pl
Executable file
63
copri4/main/src/scripts/statistik_zip_transport.pl
Executable file
|
@ -0,0 +1,63 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
|
||||||
|
#
|
||||||
|
#Just CSV attachment zipping
|
||||||
|
#
|
||||||
|
|
||||||
|
#with start_time and end_time
|
||||||
|
#./src/scripts/statistik_zip_transport.pl shareedms-operator '2022-01-01' '2022-02-01'
|
||||||
|
#
|
||||||
|
#defaults now()
|
||||||
|
#./src/scripts/statistik_zip_transport.pl shareedms-operator
|
||||||
|
#
|
||||||
|
use vars qw($syshost);
|
||||||
|
|
||||||
|
BEGIN {
|
||||||
|
$syshost = $ARGV[0] || exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
use lib "/var/www/copri-bike/$syshost/src";
|
||||||
|
|
||||||
|
my $start_itime = $ARGV[1] || "";
|
||||||
|
my $end_itime = $ARGV[2] || "";
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use utf8;
|
||||||
|
use POSIX;
|
||||||
|
use CGI ':standard';
|
||||||
|
use Lib::Config;
|
||||||
|
use Scalar::Util qw(looks_like_number);
|
||||||
|
use DateTime;
|
||||||
|
use DateTime::Format::Pg;
|
||||||
|
use Sys::Hostname;
|
||||||
|
my $hostname = hostname;
|
||||||
|
|
||||||
|
use Data::Dumper;
|
||||||
|
|
||||||
|
my $q = new CGI;
|
||||||
|
my $cf = new Config;
|
||||||
|
my %varenv = $cf->envonline();
|
||||||
|
|
||||||
|
my $dt1 = DateTime->now(time_zone => 'Europe/Berlin');
|
||||||
|
if(!$end_itime){
|
||||||
|
$end_itime = $dt1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$start_itime){
|
||||||
|
$start_itime = $dt1->clone->add(months => -1, end_of_month => 'preserve');
|
||||||
|
}
|
||||||
|
|
||||||
|
my $month = $1 if($start_itime =~ /\d{4}-(\d{2})-\d{2}/);
|
||||||
|
$month = sprintf('%.2d',$month);
|
||||||
|
my $year = $1 if($start_itime =~ /(\d{4})-\d{2}-\d{2}/);
|
||||||
|
my $filename = "Statistik_$year-$month.zip";
|
||||||
|
|
||||||
|
#zip it
|
||||||
|
`cd $varenv{csv} && rm -f $filename && /usr/bin/zip $filename *$year-$month*.csv && sync`;
|
||||||
|
|
||||||
|
#`$varenv{basedir}/src/scripts/ftpSWKstatistik.pl $filename`;
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,14 @@
|
||||||
#
|
#
|
||||||
# velofaktur per REST JSON Payload with Bearer Token
|
# velofaktur per REST JSON Payload with Bearer Token
|
||||||
#
|
#
|
||||||
|
#Examples
|
||||||
# Abrufen einer Liste mit Stationen, Anzahl Slots + Name
|
# Abrufen einer Liste mit Stationen, Anzahl Slots + Name
|
||||||
# sudo su www-data -c "./src/scripts/velofaktur_client.pl shareedms-fr01 get_velo"
|
# ./src/scripts/velofaktur_client.pl shareedms-operator get_velo
|
||||||
#
|
#
|
||||||
# bike ID Statusabfrage | Freigeben
|
# bike ID Statusabfrage | Freigeben
|
||||||
# sudo su www-data -c "./src/scripts/velofaktur_client.pl shareedms-fr01 post_velo 8 1 200008 Statusabfrage"
|
# ./src/scripts/velofaktur_client.pl shareedms-operator post_velo 8 1 200008 Statusabfrage
|
||||||
# will be sent by booking_update $lock_state eq "unlocked"
|
# will be sent by booking_update $lock_state eq "unlocked"
|
||||||
# sudo su www-data -c "./src/scripts/velofaktur_client.pl shareedms-fr01 post_velo 8 1 200008 Freigeben "$record_pos->{c_id}""
|
# ./src/scripts/velofaktur_client.pl shareedms-operator post_velo 8 1 200008 Freigeben "$record_pos->{c_id}"
|
||||||
#
|
#
|
||||||
use vars qw($syshost);
|
use vars qw($syshost);
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,18 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
|
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
|
||||||
|
|
||||||
echo "YOur working directory:";
|
echo "YOur working directory:"
|
||||||
pwd
|
pwd
|
||||||
|
|
||||||
|
echo "Creating some empty directories:"
|
||||||
|
mkdir -vp shareedms-operator/cache
|
||||||
|
mkdir -vp shareedms-operator/csv
|
||||||
|
mkdir -vp shareedms-operator/data
|
||||||
|
mkdir -vp shareedms-operator/json
|
||||||
|
mkdir -vp shareedms-operator/pdf
|
||||||
|
mkdir -vp shareedms-operator/site
|
||||||
|
mkdir -vp shareedms-operator/xml
|
||||||
|
|
||||||
echo "Set up file access rights. Please also check if it meets your needs"
|
echo "Set up file access rights. Please also check if it meets your needs"
|
||||||
|
|
||||||
chgrp -R www-data *
|
chgrp -R www-data *
|
||||||
|
|
|
@ -30,6 +30,12 @@
|
||||||
Header set Access-Control-Allow-Origin "example.tld"
|
Header set Access-Control-Allow-Origin "example.tld"
|
||||||
</FilesMatch>
|
</FilesMatch>
|
||||||
|
|
||||||
|
<Directory /var/www/copri4/shareeapp-primary/json>
|
||||||
|
Options -Indexes +FollowSymLinks -ExecCGI
|
||||||
|
Order allow,deny
|
||||||
|
Allow from all
|
||||||
|
</Directory>
|
||||||
|
|
||||||
<Directory /var/www/copri4/shareeapp-operator/site>
|
<Directory /var/www/copri4/shareeapp-operator/site>
|
||||||
Options -Indexes +FollowSymLinks -ExecCGI
|
Options -Indexes +FollowSymLinks -ExecCGI
|
||||||
Order allow,deny
|
Order allow,deny
|
||||||
|
@ -77,6 +83,12 @@
|
||||||
PerlResponseHandler Mod::APIjsonserver
|
PerlResponseHandler Mod::APIjsonserver
|
||||||
</Location>
|
</Location>
|
||||||
|
|
||||||
|
<Location /GBFSout>
|
||||||
|
SetHandler perl-script
|
||||||
|
PerlInitHandler Apache2::Reload
|
||||||
|
PerlResponseHandler Mod::GBFSout
|
||||||
|
</Location>
|
||||||
|
|
||||||
<Location /FileOut>
|
<Location /FileOut>
|
||||||
SetHandler perl-script
|
SetHandler perl-script
|
||||||
PerlInitHandler Apache2::Reload
|
PerlInitHandler Apache2::Reload
|
||||||
|
@ -87,7 +99,7 @@
|
||||||
RewriteEngine On
|
RewriteEngine On
|
||||||
RedirectMatch ^/$ /app/Anmelden
|
RedirectMatch ^/$ /app/Anmelden
|
||||||
SSLProxyEngine On
|
SSLProxyEngine On
|
||||||
RewriteCond %{REQUEST_URI} ^/(site|img|data|css|js|jquery)
|
RewriteCond %{REQUEST_URI} ^/(site|img|data|css|js)
|
||||||
RewriteRule ^(.*)$ https://shareeapp-operator1.example.tld/$1 [P,L]
|
RewriteRule ^(.*)$ https://shareeapp-operator1.example.tld/$1 [P,L]
|
||||||
</IfModule>
|
</IfModule>
|
||||||
|
|
||||||
|
|
1
copri4/shareeapp-operator/cache
Symbolic link
1
copri4/shareeapp-operator/cache
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../shareedms-operator/cache
|
|
@ -97,7 +97,7 @@ Weitere Personen aus Ihrem Haushalt profitieren jedoch ebenfalls, falls Sie weit
|
||||||
$ctrel = $users_sharee if(ref($users_sharee) eq "HASH" && $users_sharee->{c_id});
|
$ctrel = $users_sharee if(ref($users_sharee) eq "HASH" && $users_sharee->{c_id});
|
||||||
#
|
#
|
||||||
#collect rentals on operators and get operator hash with dbname->uri_operator
|
#collect rentals on operators and get operator hash with dbname->uri_operator
|
||||||
$q->param(-name=>'month',-value=>"1");
|
#$q->param(-name=>'month',-value=>"1");
|
||||||
my ($cttpos,$operator_hash) = $apif->user_rentals_history($q,$ctrel);
|
my ($cttpos,$operator_hash) = $apif->user_rentals_history($q,$ctrel);
|
||||||
#print Dumper($cttpos);
|
#print Dumper($cttpos);
|
||||||
|
|
||||||
|
@ -344,7 +344,7 @@ Nach Abschluss der Registrierung erhalten Sie sowohl auf die von Ihnen hinterleg
|
||||||
}elsif($key =~ /barcode/){
|
}elsif($key =~ /barcode/){
|
||||||
|
|
||||||
if($cttpos_count){
|
if($cttpos_count){
|
||||||
print $q->div({-style=>'padding-top:1.5em;font-weight:bold;'},"Folgende Positionen liegen zur nächsten Abbuchung vor (max. 1 Monat)"),"\n";
|
print $q->div({-style=>'padding-top:1.5em;font-weight:bold;'},"Folgende Positionen liegen zur nächsten Abbuchung vor"),"\n";
|
||||||
|
|
||||||
my @tpl_posorder = ("txt01=Beschreibung","int04=Station","ct_name=(Rad) Nummer","int26=CO2","int02=Betrag");
|
my @tpl_posorder = ("txt01=Beschreibung","int04=Station","ct_name=(Rad) Nummer","int26=CO2","int02=Betrag");
|
||||||
|
|
||||||
|
|
|
@ -195,8 +195,8 @@
|
||||||
logdir = "/var/log/copri4"
|
logdir = "/var/log/copri4"
|
||||||
basedir = "/var/www/copri4"
|
basedir = "/var/www/copri4"
|
||||||
<type_id>
|
<type_id>
|
||||||
300101 = "Lastenrad"
|
300101 = "cargo"
|
||||||
300103 = "Stadtrad"
|
300103 = "city"
|
||||||
</type_id>
|
</type_id>
|
||||||
<sharing_type>
|
<sharing_type>
|
||||||
2 = "public"
|
2 = "public"
|
||||||
|
|
Binary file not shown.
|
@ -32,7 +32,13 @@
|
||||||
</FilesMatch>
|
</FilesMatch>
|
||||||
|
|
||||||
<Directory /var/www/copri4/shareedms-operator/site>
|
<Directory /var/www/copri4/shareedms-operator/site>
|
||||||
Options +Indexes +FollowSymLinks -ExecCGI
|
Options -Indexes +FollowSymLinks -ExecCGI
|
||||||
|
Order allow,deny
|
||||||
|
Allow from all
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
<Directory /var/www/copri4/shareedms-primary/json>
|
||||||
|
Options -Indexes +FollowSymLinks -ExecCGI
|
||||||
Order allow,deny
|
Order allow,deny
|
||||||
Allow from all
|
Allow from all
|
||||||
</Directory>
|
</Directory>
|
||||||
|
@ -59,7 +65,6 @@
|
||||||
ServerAdmin admin@example.tld
|
ServerAdmin admin@example.tld
|
||||||
DocumentRoot /var/www/copri4/shareedms-operator
|
DocumentRoot /var/www/copri4/shareedms-operator
|
||||||
|
|
||||||
|
|
||||||
PerlOptions +Parent
|
PerlOptions +Parent
|
||||||
PerlRequire /var/www/copri4/shareedms-operator/startup.pl
|
PerlRequire /var/www/copri4/shareedms-operator/startup.pl
|
||||||
<Location />
|
<Location />
|
||||||
|
|
1
copri4/shareedms-operator/pdf/pdfinvoice
Symbolic link
1
copri4/shareedms-operator/pdf/pdfinvoice
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
pdfinvoice
|
|
@ -2,7 +2,6 @@
|
||||||
ServerName shareeweb-project.example.tld
|
ServerName shareeweb-project.example.tld
|
||||||
ServerAlias shareeweb-project1.example.tld
|
ServerAlias shareeweb-project1.example.tld
|
||||||
|
|
||||||
ServerAdmin info@gnu-systems.de
|
|
||||||
DocumentRoot /var/www/copri4/shareeweb-project
|
DocumentRoot /var/www/copri4/shareeweb-project
|
||||||
|
|
||||||
ErrorLog /var/log/apache2/shareeweb-project-error.log
|
ErrorLog /var/log/apache2/shareeweb-project-error.log
|
||||||
|
@ -18,7 +17,6 @@
|
||||||
<VirtualHost *:443>
|
<VirtualHost *:443>
|
||||||
ServerName shareeweb-project1.example.tld
|
ServerName shareeweb-project1.example.tld
|
||||||
|
|
||||||
ServerAdmin info@gnu-systems.de
|
|
||||||
DocumentRoot /var/www/copri4/shareeweb-project
|
DocumentRoot /var/www/copri4/shareeweb-project
|
||||||
AddHandler cgi-script .cgi .sh .pl
|
AddHandler cgi-script .cgi .sh .pl
|
||||||
|
|
||||||
|
@ -57,7 +55,6 @@
|
||||||
<VirtualHost *:443>
|
<VirtualHost *:443>
|
||||||
ServerName shareeweb-project.example.tld
|
ServerName shareeweb-project.example.tld
|
||||||
|
|
||||||
ServerAdmin info@gnu-systems.de
|
|
||||||
DocumentRoot /var/www/copri4/shareeweb-project
|
DocumentRoot /var/www/copri4/shareeweb-project
|
||||||
|
|
||||||
PerlOptions +Parent
|
PerlOptions +Parent
|
||||||
|
@ -95,7 +92,7 @@
|
||||||
RewriteEngine On
|
RewriteEngine On
|
||||||
RedirectMatch ^/$ /frame/Karte
|
RedirectMatch ^/$ /frame/Karte
|
||||||
SSLProxyEngine On
|
SSLProxyEngine On
|
||||||
RewriteCond %{REQUEST_URI} ^/(site|img|data|css|js|jquery)
|
RewriteCond %{REQUEST_URI} ^/(site|img|data|css|js)
|
||||||
RewriteRule ^(.*)$ https://shareeweb-project1.example.tld/$1 [P,L]
|
RewriteRule ^(.*)$ https://shareeweb-project1.example.tld/$1 [P,L]
|
||||||
</IfModule>
|
</IfModule>
|
||||||
|
|
||||||
|
|
1
copri4/shareeweb-project/cache
Symbolic link
1
copri4/shareeweb-project/cache
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../shareedms-operator/cache
|
Loading…
Add table
Reference in a new issue