operator accounting init

This commit is contained in:
ragu 2022-10-11 07:00:25 +02:00
parent 663dfd8c13
commit dd84259e6d
14 changed files with 130 additions and 633 deletions

View file

@ -970,7 +970,7 @@ sub booking_request(){
my $response_text = "";
#state and lock_state is only defined if requestes incl. occupied
$bw->log("booking_request bike to state | $bike | $state | $lock_state, tarif $ct_tariff->{barcode}, auth:",$auth->{c_id},"");
$bw->log("booking_request bike to state $bike | $state | $lock_state, tarif $ct_tariff->{barcode}, auth:$auth->{c_id}",$auth->{c_id},"");
my $update_adr = {
table => "contentadr",
@ -1155,7 +1155,7 @@ sub booking_update(){
my $record_cc = { c_id => 0 };
$record_cc = $dbt->fetch_record($dbh,$pref_cc) if($q->param('bike'));
$bw->log("booking_update bike to state | $bike | $state | $lock_state, auth:",$auth->{c_id},"");
$bw->log("booking_update bike to state $bike | $state | $lock_state, auth:$auth->{c_id}",$auth->{c_id},"");
my $update_cc = {
table => "content",
@ -1230,7 +1230,8 @@ sub booking_update(){
if($state_key == 6 && $record_pos->{int10} == 2 && $record_pos->{int20} == 1){
$rows = $dbt->delete_content($dbh,"contenttranspos",$record_pos->{c_id});
if($rows > 0){
$update_cc->{int10} = 1;
$update_cc->{int10} = 1 if($record_cc->{int10} == 2);#only if still requested
$booking_values->{response_state} = "OK: canceled bike " . $q->param('bike');
$booking_values->{response_text} = "Fahrrad Nr. " . $q->param('bike') . " wurde erfolgreich storniert";
$booking_values->{state} = "available";

View file

@ -24,6 +24,7 @@ my $icon = "/icon";
sub ibuttons(){
my $self = shift;
my %ib = (
'operator_accounting' => 'Betreiber Abrechnung',
'service_done' => 'Wartungsprotokoll für ausgewähltes Rad einfügen/bearbeiten',
'post_email' => 'submit',
'barcode' => 'Barcode Label drucken',
@ -67,8 +68,6 @@ sub ibuttons(){
'search' => 'suchen',
'search_product' => 'Search',
'search_calendar' => 'anzeigen',
'search_export' => 'suchen /
auswerten',
'search_adr' => 'Kunden suchen',
'search_extrakt' => 'extrakt',
'change_login' => 'ID',
@ -554,16 +553,17 @@ sub singlesubmit10(){
return $button;
}
# international hack. Vorsicht, aendert Parameter
sub singlesubmit1(){
my $self = shift;
my ($function,$b_name,$class,$style,$title) = @_;
$class = "ebutton" if(!$class);
my ($key,$val,$ibv);
while (($key,$val) = each(%ib)) {
$ibv = $val if($b_name eq $key);
my $function = shift;
my $button_key = shift;
my $class = shift || "ebutton";
my $style = shift || "";
my $ib_view = $button_key;
while (my($key,$val) = each(%ib)) {
$ib_view = $val if($key eq $button_key);
}
my $button = "<input type='submit' class='$class' style='$style' name='$function' value='$ibv' title='$title'>";
my $button = "<button type='submit' class='$class' style='$style' name='$function' value='$button_key' title=''>$ib_view</button>";
return $button;
}

View file

@ -375,6 +375,8 @@ sub handler {
$db->update_users4trans($R::c_id4trans,$R::tpl_id4trans,"",$users_dms->{u_id}) if(looks_like_number($R::c_id4trans) && looks_like_number($R::tpl_id4trans));
if($R::ct_trans =~ /set_workflow2invoice|set_workflow2storno/){
$return = $pl->set_workflow($users_dms,$R::c_id4trans,$R::set_main_id4workflow) if(looks_like_number($R::c_id4trans) && looks_like_number($R::tpl_id4trans) && looks_like_number($R::set_main_id4workflow));
}elsif($R::detail_search && $R::detail_search eq "operator_accounting"){
$return = $pl->operator_accounting($users_dms,$users_sharee,$R::accounting_type,$R::ck4ex);
}else{
$return .= "|";
$return .= $pre->preinit($users_dms,$lang);#transactions logic

View file

@ -1402,7 +1402,7 @@ sub search_content3(){
$valref->{$key} = $q->escapeHTML($valref->{$key});
#print $key . ":" . $opref->{$key} . ":" . $valref->{$key} . "\n";
if(($v_journal =~ /_parts/ && $kontext eq "Waren") || $table_pos =~ /contentpos|contentadrpos|users/){
if($table_pos =~ /contentpos|contentadrpos|users/){
#my $tinfo = &table_info("","contenttranspos");
if($key =~ /ct_name/){
$cptxt_where .= " and cp.$key ilike '$valref->{$key}'";
@ -1435,7 +1435,7 @@ sub search_content3(){
}
}
if($key =~ /end_itime|end_mtime|end_date_time/){
if($key =~ /end_itime|end_mtime|end_date_time|pay_time/){
$valref->{$key} .= " 23:59" if($valref->{$key} !~ /\d:\d/);
}
@ -1472,19 +1472,14 @@ sub search_content3(){
if($key =~ /end_mtime/ && $valref->{$key} =~ /\d+\.\d+\.\d+/){
$txt_where .= " and ct.mtime < '$valref->{$key}'";
}
}
if($v_journal !~ /_parts/ || $kontext eq "Waren"){
if($key =~ /long_rent/ && $valref->{$key} =~ /^\d+ (day|hour)/){
$cptxt_where .= " and cp.end_time >= (cp.start_time + interval '$valref->{$key}')";
if($key =~ /start_pay_time/ && $valref->{$key} =~ /\d+\.\d+\.\d+/){
$txt_where .= " and ct.pay_time >= '$valref->{$key}'";
}
if($key =~ /end_pay_time/ && $valref->{$key} =~ /\d+\.\d+\.\d+/){
$txt_where .= " and ct.pay_time < '$valref->{$key}'";
}
if($key =~ /start_date_time/ && $valref->{$key} =~ /^\d+\.\d+\.\d+/){
$cptxt_where .= " and cp.start_time >= '$valref->{$key}'";
}
if($key =~ /end_date_time/ && $valref->{$key} =~ /^\d+\.\d+\.\d+/){
$cptxt_where .= " and cp.end_time <= '$valref->{$key}'";
}
}
}
@ -1508,7 +1503,7 @@ sub search_content3(){
#print "txt_where: $txt_where<br>\n";
#print "cptxt_where: $cptxt_where<br>\n";
my $sth;
my $sth = "";
my $updown = "ASC";
$updown = "DESC" if($sort_updown eq "down");
if($v_journal =~ /_parts/){#collects ct_ids
@ -1518,7 +1513,6 @@ sub search_content3(){
}elsif($valref->{long_rent} || $valref->{start_date_time} =~ /^\d+\.\d+\.\d+/ || $valref->{end_date_time} =~ /^\d+\.\d+\.\d+/ || $cpgroup_where){
$sth = $dbh->prepare("SELECT * FROM relation rel, $table ct WHERE rel.content_id=ct.c_id and rel.main_id IN ($main_ids) and rel.template_id IN ($tplids) and rel.lang='$lang' $txt_where and c_id IN (SELECT cp.ct_id from contenttranspos cp WHERE 1=1 $cptxt_where $cpgroup_where) ORDER BY $scol $updown LIMIT $limit OFFSET $offset");
}elsif($v_journal && $ct_ids){#and executes ct_ids
$txt_where = "" if($kontext eq "Waren");
$ct_ids = 0 if(!$ct_ids);
$sth = $dbh->prepare("SELECT * FROM relation rel, $table ct WHERE rel.content_id=ct.c_id and rel.main_id IN ($main_ids) and rel.template_id IN ($tplids) and rel.content_id IN ($ct_ids) and rel.lang='$lang' $txt_where ORDER BY $scol $updown LIMIT $limit OFFSET $offset");
@ -1547,8 +1541,7 @@ sub search_content3(){
#my $save_query = $q->escapeHTML("$txt_where");
#CSV/FiBu Export###
if($export && (("$kontext" ne "Waren" && "$export" ne "FiBu" && $v_journal !~ /_parts/) || ("$export" eq "FiBu" && $v_journal =~ /_parts/) || ("$kontext" eq "Waren" && $v_journal =~ /_parts/))){
#print "$v_journal,$time,$kontext,$export<br>";
if($export){
my $ctf = &get_content1("","contentuser","$mandant_id");
my @tpl_order = split /,/,$node_meta->{tpl_order};
@ -1561,18 +1554,6 @@ sub search_content3(){
$what = "$export-" if($export =~ /CSV|FIBU/);
open(CSV, "> $varenv{pdf}/$what$owner-$time.csv") or die "Can't open $varenv{pdf}/$owner-$time.csv\n";
#workaround 2015-11-23 for formated FiBu export
$export = "FiBu" if("$kontext" eq "Waren" && $v_journal =~ /_parts/);
if("$export" eq "FiBu"){
foreach my $id (keys (%$search)){
$aw_ids .= "$search->{$id}->{ct_id}|" if("$search->{$id}->{ct_name}" eq "$ctf->{txt51}");
}
#SOLL Zahlungsart
$ctt = &Libenzdb::collect_content2("","contenttrans");
#$ctadr = &collect_content3("","contentadr");#wg Debitor/Kreditor
print CSV "SOLL;UMSATZ;USTNR;HABEN;GVC;BELDAT;BELEG;OPBELEG;SKONTO;KOSTNR;TEXT;TEXT2\n";
}else{
#CSV Table Header
my $col_header="Ordner";
foreach(@tpl_order){
@ -1584,10 +1565,7 @@ sub search_content3(){
}
}
print CSV "$col_header\n";
}
#sort=ct_id nach Geschäftsvorgang
$scol = "ct_id" if("$export" eq "FiBu");
foreach my $id (sort {
if($sort_updown eq "down"){
if ($scol =~ /barcode|int/) {

View file

@ -122,10 +122,6 @@ EOF
require "Mod/RelationEdit.pm";
&RelationEdit::tpl($node_meta,$users_dms,$mode,$return);
}
elsif($mode eq "supervisor"){
require "Tpl/AttributEdit.pm";
&AttributEdit::tpl($node_meta,$users_dms,$mode,$return);
}
elsif(($R::node2edit && $R::node2edit =~ /editpart/) || ($R::base_edit && $R::base_edit !~ /delete/)){
require "Tpl/BaseEdit.pm";
&BaseEdit::tpl($node_meta,$users_dms,$mode,$return);

View file

@ -567,7 +567,7 @@ sub save_relation {
#type_id and energy_id by node_name pattern match.
#TODO, should be editable by NodeEditor
my $type_id = 300101;#if Lastenrad
$type_id = 300102 if($node_name =~ /E-Lastenrad/);
$type_id = 300101 if($node_name =~ /E-Lastenrad/);
$type_id = 300103 if($node_name =~ /Stadtrad/);
$u_rows = $dbt->update_one($dbh,$update_node,"type_id=$type_id");
my $energy_id = 0;
@ -812,4 +812,60 @@ sub save_service_desc {
return $rows;
}
#Operator Accounting
sub operator_accounting {
my $self = shift;
my $users_dms = shift;
my $users_sharee = shift;
my $accounting_type = shift || "";
my $ck4ex = shift || "";
my $dbh = "";
my %varenv = $cf->envonline();
my $print_return = "";
my $exit_code = 1;
my $ctt = {
ct_name => "Abrechnung-123",
txt00 => "Abrechnung",
};
my $praefix = "$ctt->{txt00}-$varenv{praefix}";
my $accounting_main_id = 300029;
if(1==1){#TODO
my $auth = $users_sharee;#workaround, must be operator addr.
my $ct_id = $dbt->insert_contenttrans($dbh,$auth,$accounting_main_id,"208","----",$users_dms->{u_id});
my $pref = {
table => "contenttrans",
fetch => "one",
main_id => $accounting_main_id,
template_id => 208,
c_id => $ct_id
};
$ctt = $dbt->fetch_record($dbh,$pref);
$bw->log("operator_accounting used invoice c_id:",$ctt->{c_id},"");
my $psize="A4";
my $wc_line=0;
#$wc_line= $ctt->{int04};#Adresse.Tabelle
my $topdf = "$varenv{basedir}/src/wkhtmltopdf-amd64";
$print_return = `$topdf --page-size $psize "$varenv{wwwhost}/Printpreview?printer_id=operator_accounting\&mandant_main_id=$dbt->{shareedms_conf}->{parent_id}\&main_id=$accounting_main_id\&ct_name2print=$ctt->{ct_name}\&c_id4trans=$ctt->{c_id}\&u_id=$users_dms->{u_id}\&wc=$wc_line" $varenv{pdf}/$praefix-$ctt->{ct_name}.pdf 2>&1`;
$exit_code = $?;
my $filesize = -s "$varenv{pdf}/$praefix-$ctt->{ct_name}.pdf";
open(EMA, ">> $varenv{logdir}/copri-print.log");
print EMA "$now_dt\n$topdf --page-size $psize $varenv{wwwhost}/Printpreview?printer_id=operator_accounting\&mandant_main_id=$dbt->{shareedms_conf}->{parent_id}\&main_id=$accounting_main_id\&ct_name2print=$ctt->{ct_name}\&c_id4trans=$ctt->{c_id}\&u_id=$users_dms->{u_id}\&wc=$wc_line $varenv{pdf}/$praefix-$ctt->{ct_name}.pdf\n $print_return\nfilesize: $filesize\nexit_code: $exit_code\n\n";
close EMA;
#exit 0;
}
if( -f "$varenv{basedir}/pdf/$praefix-$ctt->{ct_name}.pdf"){
print "<script type=\"text/javascript\">window.open('$varenv{wwwhost}/pdf/$praefix-$ctt->{ct_name}.pdf');</script>";
}else{
return "failure::PDF konnte nicht generiert werden\n $varenv{wwwhost}/pdf/$praefix-$ctt->{ct_name}.pdf";
}
return;
}
1;

View file

@ -266,159 +266,6 @@ sub maininit(){
}
###
#new Attribute for template as tpl_order
if($ib_key =~ /new_attrtpl_(\w+)/){
my $key = $1;
my $debug=1;
open(ATTR,">>$varenv{logdir}/attr.log") if($debug);
print ATTR "\n----- $now_time -------\n" if($debug);
foreach(@keywords){
$val = $q->param($_);
print ATTR "$_: $val\n" if($debug);
}
my $table = "template";
my $tpl_id = "400";#Master template
my $tpl_master = $db->get_tpl($tpl_id);
my @tpl_masterorder = split /,/,$tpl_master->{tpl_order};
my $num=1;
my $next=1;
my $size=15;
foreach (@tpl_masterorder){
my ($m_key,$m_des,$m_size) = split /=/,$_;
if($m_key =~ /$key(\d+)/){
$num = $1;
$size = $m_size if($m_size);
$next = $num if($next < $num);
print ATTR "$next = $num if($next < $num)\n" if($debug);
}
}
$next++;
print ATTR "next: $next\n" if($debug);
if($key && $next > 20){
return "failure:: Abbruch, die maximale Menge der Datenfelder wurde erreicht.";
}
$next = sprintf("%.2d", $next);
$tpl_master->{tpl_order} .= ",$key$next=new$users_dms->{u_id}=$size";
$i_rows += $db->updater("$table","tpl_id",$tpl_id,"tpl_order","$tpl_master->{tpl_order}",$users_dms->{u_id});
$path =~ s/\/\//\//;
$path .= "/supervisor" if($path !~ /supervisor/);
print ATTR "$varenv{wwwhost}$script$path?node2edit=edit_template\&tpl_id=$tpl_id\&key=$key$next\n" if($debug);
close(ATTR) if($debug);
print redirect("$varenv{wwwhost}$script$path?node2edit=edit_template\&tpl_id=$tpl_id\&key=$key$next");
exit;
}
###
#save Attribute for template as tpl_order
if($ib_key =~ /save_attrtpl/ && $R::key && $R::key_typ && $R::des && $R::asort){
my $debug=1;
open(ATTR,">>$varenv{logdir}/attr.log") if($debug);
print ATTR "\n----- $now_time -------\n" if($debug);
foreach(@keywords){
$val = $q->param($_);
print ATTR "$_: $val\n" if($debug);
}
my $template;
if($users_dms->{mandant_id} && $users_dms->{mandant_id} < "200000"){
my $ctf = $db->get_content1("contentuser","$users_dms->{mandant_id}");
$template = $db->collect_tpl("$ctf->{txt35}","$R::key") if($ctf->{txt35});#TINK master template_id=400
}
#change all templates if $R::key
foreach my $id (keys(%$template)){
my $asort = $R::asort;
my @new_order;
my @tpl_order = split /,/,$template->{$id}->{tpl_order};
#1. extract array-skalar without $R::key
#print "1. @tpl_order<br>";
foreach (@tpl_order){
my ($m_key,$m_des,$m_size) = split /=/,$_;
if($m_key !~ /$R::key/){
push @new_order,$_;
}
}
#3. put in new key=des=size value at asort
my $new_tpl_order;
my $size=15;
my $new_key = $R::key_typ;
($new_key,$size) = split(/_/,$R::key_typ) if($R::key_typ =~ /_/);
my $i=0;
my $ok=0;
foreach (@new_order){
$i++;
if($i == $asort){
$ok++;
$new_tpl_order .= "$R::key=$R::des=$size,";
}
$new_tpl_order .= "$_,";
}
$new_tpl_order .= "$R::key=$R::des=$size," if(!$ok);#last chance
$new_tpl_order =~ s/,$//;
$i_rows += $db->updater("template","tpl_id",$template->{$id}->{tpl_id},"tpl_order","$new_tpl_order",$users_dms->{u_id});
}
close(ATTR) if($debug);
}
###
#remove and delete attribute with check
if($ib_key =~ /remove_chk4attr/ && $R::key){
return "failure::Wenn Sie die Eigenschaft-Definition loeschen, wird die Eigenschaft in allen Objekten geloescht. ::?rel_edit=delete_attrtpl\&exit_box2=1\&key=$R::key ::loeschen"
}
if($ib_key =~ /delete_attrtpl/ && $R::key){
my $template;
if($users_dms->{mandant_id} && $users_dms->{mandant_id} < "200000"){
my $ctf = $db->get_content1("contentuser","$users_dms->{mandant_id}");
$template = $db->collect_tpl("$ctf->{txt35}","$R::key") if($ctf->{txt35});#TINK master template_id=400
}
foreach my $id (keys(%$template)){
my $new_tpl_order;
my @tpl_order = split /,/,$template->{$id}->{tpl_order};
foreach (@tpl_order){
my ($m_key,$m_des,$m_size) = split /=/,$_;
if($m_key !~ /$R::key/){
$new_tpl_order .= "$_,";
}
}
$new_tpl_order =~ s/,$//;
$i_rows += $db->updater("template","tpl_id",$template->{$id}->{tpl_id},"tpl_order","$new_tpl_order",$users_dms->{u_id});
$i_rows += $db->updater($template->{$id}->{ct_table},"1","1","$R::key","null","","","","","no_time");#delete key-value in All content without mtime and user stamp
}
}
#packpos Packaging
if($R::rel_edit eq "add_packpos" && $R::c_id && $R::c_idpackpos){
my $ct = $db->get_content1("content",$R::c_id);
my $cp_ids = "$ct->{txt05}";
if($cp_ids !~ /^\d/){
$cp_ids = "$R::c_idpackpos";
}else{
$cp_ids .= ",$R::c_idpackpos";
}
$u_rows += $db->updater("content","c_id",$R::c_id,"txt05","$cp_ids",$users_dms->{u_id});
}
if($R::rel_edit eq "remove_packpos" && $R::c_id && $R::c_idpackpos){
my $ct = $db->get_content1("content",$R::c_id);
my $cp_ids = "$ct->{txt05}";
$cp_ids =~ s/[,]?$R::c_idpackpos//;
$u_rows += $db->updater("content","c_id",$R::c_id,"txt05","$cp_ids",$users_dms->{u_id});
}
#save content
#if($ib_key =~ /save/ && $R::c_id && $R::rel_id){

View file

@ -1,146 +0,0 @@
package AttributEdit;
#
#
# SPDX-License-Identifier: AGPL-3.0-or-later
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
#
use strict;
use warnings;
use CGI::Carp qw(fatalsToBrowser);
use CGI ':standard';
use Lib::Config;
use Mod::Buttons;
use Mod::Libenz;
use Mod::Libenzdb;
use Mod::DBtank;
sub new {
my $class = shift;
my $self = {};
bless($self,$class);
return $self;
}
#Template
sub tpl(){
my $node_meta = shift;
my $users_dms = shift;
my $mode = shift;
my $return = shift;
my $q = new CGI;
my $cf = new Config;
my $lb = new Libenz;
my $db = new Libenzdb;
my $dbt = new DBtank;
my $but = new Buttons;
my %varenv = $cf->envonline();
my $script = $q->script_name();
my $path = $q->path_info();
my %ib = $but->ibuttons();
my $dbh = "";
my $tpl = $db->get_tpl($R::tpl_id);#Master template
my @tpl_order = split /,/,$tpl->{tpl_order};
my @_attr;
my $asort=0;
my $des_name;
my $key_txt;
my $checked_txt;
my $key_txtarea;
my $checked_txtarea;
my $key_int;
my $checked_int;
my $key_intcheck;
my $checked_intcheck;
my ($key,$des,$size);
foreach (@tpl_order){
$asort++;
($key,$des,$size) = split /=/,$_;
#push (@_attr, "$key") if($key);
if("$key" eq "$R::key"){
$des_name = $des;
if($key =~ /ct_name/){
last;
}
elsif($key =~ /txt(\d+)/ && $size =~ /area/){
$key_txtarea = $1;
$checked_txtarea = "checked";
last;
}
elsif($key =~ /txt(\d+)/){
$key_txt = $1;
$checked_txt = "checked";
last;
}
elsif($key =~ /int(\d+)/ && $size =~ /checkbox/){
$key_intcheck = $1;
$checked_intcheck = "checked";
last;
}
elsif($key =~ /int(\d+)/){
$key_int = $1;
$checked_int = "checked";
last;
}
}
}
$tpl->{change} = $lb->time4de($tpl->{change},"1") if($tpl->{change});
my $u_name = $tpl->{owner};
$u_name = $dbt->sys_username($dbh,$tpl->{owner});
print "<div style='border: 0px solid gray;margin: 0 auto;padding: 0;min-width: 100%;min-height: 150px;font-size: 14px;'>";
print $q->hidden(-name=>'key', -value=>"$R::key",-override=>'1');
print $q->start_table({-class=>'list', -border=>'0', -width=>'100%', -align=>'left', -cellpadding=>'3', -cellspacing=>'3'});
#Buttons
print $q->Tr();
print "<td style='background:$varenv{background_color2};margin:1px 0;padding:2px;' colspan='2' nowrap>\n";
print $but->singlesubmit7("rel_edit","save_attrtpl","","");
print $but->singlesubmit7("rel_edit","remove_chk4attr","","margin-left:10px;");
#print $but->singlesubmit9("dummy","zurück","","ebutton","","");
print $q->span({-style=>'margin-left:5em; font-size:0.91em;'}, "$u_name / $tpl->{change}");
print "</td>\n";
print $q->Tr();
print $q->td({-colspan=>'2'},"&nbsp;");
print $q->Tr();
print $q->td({-class=>'tdescr'}, "Service Datenfeldname"),"\n";
print $q->td({-class=>'tdval'},$q->textfield(-class=>'etxt',-name=>"des", -override=>'1',-default=>"$des_name")),"\n";
if($key =~ /txt|int/){
print $q->Tr();
print $q->td({-class=>'tdescr'}, "Datentyp"),"\n";
print "<td class='tdval'>\n";
if($R::key =~ /txt/){
print $but->radiobox("txt","key_typ","$checked_txt"),"Textzeile\n";
print $but->radiobox("txt_area","key_typ","$checked_txtarea"),"Textarea\n";
}elsif($R::key =~ /int/){
print $but->radiobox("int","key_typ","$checked_int"),"Dezimalzahl\n";
print $but->radiobox("int_checkbox","key_typ","$checked_intcheck"),"Checkbox\n";
}
print "</td>\n";
}
print $q->Tr();
print $q->td({-class=>'tdescr'},"Sortierung"),"\n";
print $q->td({-class=>'tdval'},$q->textfield(-class=>'etxt', -name=>"asort", -default=>"$asort")),"\n";
#print $q->Tr();
#print $q->td({-class=>'tdescr'},"Text Vorauswahl"),"\n";
#my $pre_values = $q->unescapeHTML("$ctf->{$R::key}");
#print $q->td({-class=>'tdval'},$q->textarea(-id=>"prev", -class=>'etxt',-style=>"width:300px;",-rows=>"1", -name=>"pre_values",-default=>"$pre_values", -override=>'1')),"\n";
#print "<script>\$(\"textarea#prev\").autoResize({extraSpace:10});</script>";
#print $q->hidden(-name=>'cuid_glob', -value=>"$cuid_glob",-override=>'1');
#print $q->Tr();
#print $q->td({-class=>'tdescr',-colspan=>'2'},""),"\n";
#print $q->Tr();
#print $q->td({-class=>'tdescr',-colspan=>'2'},"Achtung, das löschen oder ändern verursacht Datenverlust."),"\n";
print $q->end_table;
print "</div>";
}
1;

View file

@ -1,205 +0,0 @@
package AttributMatrix;
#
#
# SPDX-License-Identifier: AGPL-3.0-or-later
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
#
use strict;
use warnings;
use CGI::Carp qw(fatalsToBrowser);
use CGI ':standard';
use Lib::Config;
use Mod::Buttons;
use Mod::Libenz;
use Mod::Libenzdb;
use Mod::DBtank;
sub new {
my $class = shift;
my $self = {};
bless($self,$class);
return $self;
}
#Template
sub tpl(){
my $node_meta = shift;
my $users_dms = shift;
my $mode = shift;
my $return = shift;
my $q = new CGI;
my $cf = new Config;
my $lb = new Libenz;
my $db = new Libenzdb;
my $but = new Buttons;
my $dbt = new DBtank;
my %varenv = $cf->envonline();
my $script = $q->script_name();
my $path_info = $q->path_info();
my $path = $path_info;
if("$varenv{metahost}"){
$path = "$script" . "$path_info";
$script="";
}
my $dbh = "";
my $lang = "de";
my %ib = $but->ibuttons_arch();
my @viewsel = split /\//,$1 if($path =~ /^\/(.*)/);
my $tpl_master = $db->get_tpl("400");
my @tpl_masterorder = ();
my $node = {};
if($users_dms->{int08} == 2){
print<<EOF
<script>
\$(function() {
function postValues() {
var data = \$("input[type='checkbox'], input[type='text'], input[type='hidden']").serialize();
\$.ajax({
url: '$varenv{wwwhost}/ajax_post',
type: 'POST',
async: true,
cache: false,
data: data,
});
}
\$("input[type='checkbox']").on( "click", postValues );
\$("input[type='text']").on( "change", postValues );
});
</script>
EOF
;
}
if($users_dms->{int08} >= 1){
@tpl_masterorder = split /,/,$tpl_master->{tpl_order};
my $pref = { template_id1 => 401,
template_id2 => 499,
fetch => "all",
keyfield => "main_id",
};
$node = $dbt->fetch_rel4tpl4nd($dbh,$pref);
}else{
$return = "failure::Abbruch. Keine Zugriffsberechtigung";
}
sub checkbox_style2() {
my ($sid_key,$dialog) = @_;
my $ck_style = "<style type='text/css'><!--
.sq_$dialog$sid_key {margin:auto;position: relative;width: 16px;height: 16px;}
.sq_$dialog$sid_key label {cursor: pointer;position: absolute;width: 16px;height: 16px;background:#cccccc;top: 0%;left: 0%;}
.sq_$dialog$sid_key :checked + label {content: '';position: absolute;width: 16px;height: 16px;background: #333333;top: 0%;left: 0%;}
//--></style>\n";
return $ck_style;
}
print "<div id='Content4list'>\n";
print $q->div({-class=>"copri_header",-style=>"background-color:#cccccc;"},"$path",$q->span("(shareetool Datenfeld Matrix)"));
print $q->start_form();
print $q->hidden(-name=>'mode', -override=>1, -value=>"supervisor");
#table header
print $q->start_table({-border=>'0', -width=>'100%',-align=>'center', -cellpadding=>'0', -cellspacing=>'0'});
print $q->Tr();
if($users_dms->{int08} == 2){
#print $q->th({-style=>'text-align:right;padding:1px 3px;font-size:1em;'},"Datenfeld", $but->singlesubmit2("rel_edit","new_attrtpl_int","$ib{new_attrtpl_int}","background-color:silver;"), $but->singlesubmit2("rel_edit","new_attrtpl_txt","$ib{new_attrtpl_txt}","background-color:silver;")),"\n";
print $q->th({-style=>'text-align:right;padding:1px 3px;font-size:1em;'},"Datenfeld", $but->singlesubmit2glyph("rel_edit","new_attrtpl_int","$ib{new_attrtpl_int}","background-color:silver;")),"\n";
}else{
print $q->th({-style=>'text-align:right;padding:1px 3px;font-size:1em;'},""),"\n";
}
#foreach my $id (sort {$node->{$a}->{n_sort} <=> $node->{$b}->{n_sort}} keys (%$node)){
foreach my $id (sort {$node->{$a}->{node_name} cmp $node->{$b}->{node_name}} keys (%$node)){
if($node->{$id}->{template_id}){
if($node->{$id}->{main_id} == $node_meta->{main_id}){
print $q->hidden(-name=>'template_id',-override=>'1', -value=>"$node->{$id}->{template_id}");
print $q->th({-class=>'thmatrix',-nowrap=>1,-colspan=>2}, $q->b("$node->{$id}->{node_name}")),"\n";
}else{
if($users_dms->{int08} == 2){
my $uri_path = $dbt->recurse_node($dbh,$node->{$id}->{main_id});
print $q->th({-class=>'thmatrix',-nowrap=>1,-colspan=>2}, $q->a({-class=>"sortnav",-href=>"/$uri_path/supervisor",-title=>'aktivieren'}, "$node->{$id}->{node_name}")),"\n";
}else{
print $q->th({-class=>'thmatrix',-nowrap=>1,-colspan=>2},"$node->{$id}->{node_name}"),"\n";
}
}
}
}
#table content
my $j=0;
my $set_style;
my $checked="";
#tpl_id=400
foreach (@tpl_masterorder){
$j++;
$set_style = "background-color:#fcfdfb;";
$set_style = "background-color:#f4f1ee;" if($j %= 2);
print $q->Tr();
my ($m_key,$m_des,$m_size) = split /=/,$_;
if($m_key !~ /img|time|c_id|barcode|int04|owner/){#static
print $q->td({-class=>'tdtxtw', -style=>"$set_style"},$q->a({-class=>'sortnav',-href=>"/$viewsel[0]/$viewsel[1]/$viewsel[2]/supervisor?node2edit=edit_template\&tpl_id=$tpl_master->{tpl_id}\&key=$m_key", -title=>"edit ($j)"},"$m_des")),"\n";
}else{
print $q->td({-class=>'tdtxtw', -style=>"$set_style"},$q->a({-class=>'sortnav',-href=>"#", -title=>"static"},"$m_des")),"\n";
}
foreach my $id (sort {$node->{$a}->{node_name} cmp $node->{$b}->{node_name}} keys (%$node)){
my $cat_off="";
my $m_style="margin:auto;width:16px;height:16px;background-color:#cccccc;";
my $interval="";
#tpl_id > 400 and depends on node
if($node->{$id}->{tpl_order} =~ /$m_key=[a-z0-9-_ ]+=[a-z0-9-_]+=(\d+)/i){
$interval = $1;
}
my $service_type="";
if($node->{$id}->{tpl_order} =~ /$m_key=[a-z0-9-_ ]+=[a-z0-9-_]+=\d+=(\d+)/i){
$service_type = $1;
}
if($node->{$id}->{main_id} == $node_meta->{main_id}){
my $ck_style = &checkbox_style2($m_key,"attr");
print "$ck_style";
$checked="";
$checked="checked" if($node->{$id}->{tpl_order} =~ /$m_key/);
}else{
$cat_off=1;
$m_style="margin:auto;width:16px;height:16px;background-color:#717171;" if($node->{$id}->{tpl_order} =~ /$m_key/);
}
#my @tpl_node = split /,/,$node->{$id}->{tpl_order};
foreach (@tpl_masterorder){
my ($key,$des,$size) = split /=/,$_;
if($m_key eq $key){
if($cat_off){
my $itext = "";
my $ytext = "";
if($interval){
$itext = "$interval Tage Intervall";
$ytext = "";
$ytext = " | weich=1" if($service_type eq 1);
}
$ytext = " | hart=2" if($service_type eq 2);
print $q->td({-class=>'tdtxtc', -style=>"$set_style"},$q->div({-style=>"$m_style"},"")),"\n";
print $q->td({-class=>'tdtxtc', -style=>"$set_style text-align:left"},$q->div({-style=>""},"$itext $ytext")),"\n";
}else{
#print $q->td({-class=>'tdtxtc', -style=>"$set_style"},$q->div({ -class => "sq_attr$key" },"<input type='checkbox' id='sq_attr$key' name='matrix_template' value='$key=$des=$size' $checked><label for='sq_attr$key'></label>")),"\n";
print $q->td({-class=>'tdtxtc', -style=>"$set_style"},$q->div({ -class => "sq_attr$key" },"<input type='checkbox' id='sq_attr$key' name='matrix_template' value='$key=$des=$size' $checked><label for='sq_attr$key'></label>")),"\n";
print $q->td({-class=>'tdtxtc', -style=>"$set_style text-align:left;"}, $q->textfield(-class=>'etxt',-size=>'1',-name=>"interval_$key", -override=>'1',-default=>"$interval"), "Tage Intervall | Typ ", $q->textfield(-class=>'etxt',-size=>'1',-name=>"servicetype_$key", -override=>'1',-default=>"$service_type")),"\n";
}
}
}
}
}
print $q->end_table;
print $q->end_form;
print "</div>\n";
return $return;
}
1;

View file

@ -42,7 +42,7 @@ sub tpl(){
my $pri = new Pricing;
my $lang = "de";
my @tpl_order = ('date_time=Mietzeit','txt08=Name=15','int06=Start Station=5','int04=End Station=5','barcode=Bike Nr.=5','int12=Flotte=select','int10=Rental State=select','int20=Lock State=select','owner=User=select','txt23=Comment=15');
my @tpl_order = ('c_id=ID=5=Datensatz ID (nur intern),date_time=Mietzeit','txt08=Name=15','int06=Start Station=5','int04=End Station=5','barcode=Bike Nr.=5','int12=Flotte=select','int10=Rental State=select','int20=Lock State=select','owner=User=select','txt23=Comment=15');
my %varenv = $cf->envonline();
my %ib = $but->ibuttons();
@ -158,6 +158,7 @@ sub tpl(){
$offset += $limit;
}
my $c_id = $R::cttpos_id || $R::c_id || "";
my $cttpos = {};
$R::ct_ct_name =~ s/\#//;
my $search = {
@ -167,9 +168,9 @@ sub tpl(){
};
if($R::ct_id && looks_like_number($R::ct_id)){
$search->{ct_id} = $q->escapeHTML("$R::ct_id");
}elsif($R::cttpos_id && looks_like_number($R::cttpos_id)){
$search->{cttpos_id} = $q->escapeHTML("$R::cttpos_id");
$search->{ct_id} = $R::ct_id;
}elsif($c_id && looks_like_number($c_id)){
$search->{cttpos_id} = $c_id;
}else{
$search->{start_date_time} = "$start_date_time";
$search->{end_date_time} = "$end_date_time";

View file

@ -231,11 +231,14 @@ sub tpl(){
my $searchref = {};
my $tplids = "$tpl_id," || 0;
my $opos = "";
my $main_ids = "";
#Faktura actions
if($node_meta->{template_id} =~ /209|218/){
$tplids = "209,218";#Faktura defaults
if($path =~ /OPOS/){
$main_id = $dbt->{shareedms_conf}->{faktura};
$tplids = "218";
if($node_meta->{node_name} =~ /OPOS/){
$R::detail_search="suchen";
$searchref->{int14} = ">=1";
$R::todo="Filter";
@ -245,16 +248,7 @@ sub tpl(){
$tplids = "209,218";
}
if($path =~ /langzeit/){
$R::detail_search="suchen";
$searchref->{long_rent}="1 day";
$R::todo="Filter";
$message .= ">>> langzeit Mieten (größer 1 Tag) sollten vor Faktura überprüft werden <<<";
$offset=0;
$limit=10000;
}
if(!$R::detail_search && -f $hashfile && $path =~ /letzte Suche/){
elsif(!$R::detail_search && -f $hashfile && $node_meta->{node_name} =~ /letzte Suche/){
$R::todo="Filter";
$message .= ">>> es wurden die letzten Suchparameter oder Filter geladen <<<";
$offset=0;
@ -262,31 +256,40 @@ sub tpl(){
$tplids = "209,218";
}
if($node_meta->{node_name} eq "Tagesbericht"){
elsif($node_meta->{node_name} eq "Tagesbericht"){
$R::detail_search="suchen";
$R::todo="Filter";
$offset=0;
$limit = "1000";
$R::detail_search="suchen";
$v_journal = $node_meta->{node_name};
$opos="null";
$tpl_id = 218;
$tplids = 218;
}
#on search take also journal
if($R::detail_search eq "suchen"){
elsif($node_meta->{node_name} eq "Verkaufsjournal"){
$main_id = $dbt->{shareedms_conf}->{invoicejournal};
$v_journal = $node_meta->{node_name};
$tplids = 209;
$offset=0;
$limit=10000;
}
elsif($node_meta->{node_name} eq "Rechnung"){
$main_id = $dbt->{shareedms_conf}->{invoice};
$tplids = 218;
}
elsif($node_meta->{node_name} eq "Storno"){
$main_id = 300009;
$tplids = 218;
}
elsif($R::detail_search eq "suchen"){
$tplids = "209,218";
}
}
$main_ids = "$main_id,";
$main_ids .= $db->collect_noderec($main_id,$lang,"nothing");
$main_ids =~ s/,$//;
my $max_timestamp = "";
$max_timestamp = "$1.$2.$3" if($ctf->{txt80} =~ /(\d{2})\.(\d{2})\.(\d{4})$/);
my $max_sum = $ctf->{int03} || "";
if($max_timestamp){
$limit = "2000";
$message .= ">>> Buchbare Rechnungspositionen laut Einstellungen bis Buchungsdatum: $max_timestamp <<<";
}
if($max_sum){
$message .= ">>> Buchbare Rechnungspositionen laut Einstellungen bis Verkaufssumme: $max_sum € <<<";
}
$message=$R::message if($R::message);
#CSV
@ -320,38 +323,17 @@ sub tpl(){
print $q->start_form(-name=>'searchform');
print $q->hidden(-name=>'offset', -value=>"$offset");
print $q->hidden(-name=>'main_id', -value=>"$node_meta->{main_id}");
print $q->hidden(-name=>'kind_of_trans', -value=>"$node_meta->{node_name}");
print $q->hidden(-name=>'mode', -value=>"manager");
print $q->hidden(-name=>'owner', -value=>"$users_dms->{u_id}");
print $q->hidden(-name=>'template_id', -value=>"$node_meta->{template_id}");
$tplids = "205,224,225,210,226,227,228,229" if(($table !~ /contentadr|contenttrans|contenttver|contentnel/) && !$export);
$tplids = 205 if($path =~ /Waren$/);#Defaults to only Verleih_list
$tplids = "205,224,225,210,226,227,228,229" if($table eq "content");
$tplids = 205 if($path =~ /Waren$/);#defaults to rental bikes
my $s_ct_name = $q->escapeHTML($R::s_ct_name) || "";
my $s_barcode = $q->escapeHTML($R::s_barcode) || "";
my $main_ids = "";
if($v_journal && $v_journal =~ /Verkaufsjournal/){
$main_ids = $dbt->{shareedms_conf}->{invoicejournal};
$tplids = 209;
}elsif($node_meta->{template_id} =~ /209|218/){
$main_id = $dbt->{shareedms_conf}->{faktura} if($node_meta->{node_name} eq "Faktura" || $R::todo);
# if($v_journal && $v_journal =~ /bericht/ || $R::todo);#starts at root
$main_ids = "$main_id,";
$main_ids .= $db->collect_noderec($main_id,$lang,"nothing");
}else{
$main_ids = "$main_id,";
$main_ids .= $db->collect_noderec($main_id,$lang,"nothing");
}
$main_ids =~ s/,$//;
if($v_journal){
$offset=0;
$limit=10000;
}
my $relnod = "";
$relnod = $db->collect_rel4nodes($main_ids,"","","rel_id");
@ -414,13 +396,8 @@ sub tpl(){
$c_id4trans = $users_dms->{c_id4trans};
}
#only for adding to active transaction, disabled because of not browser tab save
#$ctrel = $db->get_ctrel("contenttrans","",$lang,"",$users_dms->{c_id4trans},$users_dms->{tpl_id4trans});
#without limit it will takes only one dataset
if($node_meta->{ct_table} eq "contenttrans" && $c_id4trans && $c_id4trans =~ /^\d+$/){
#if(($R::rel_id && $R::rel_id =~ /^\d+$/) || ($c_id4trans && $c_id4trans =~ /^\d+$/)){
#if((($R::rel_id && $R::rel_id =~ /^\d+$/) || ($c_id4trans && $c_id4trans =~ /^\d+$/)) && ($limit > $varenv{limit})){
$ct4rel = $db->collect_cid($table,$lang,$tplids,$R::rel_id,$R::barcode,"c_id",$c_id4trans);
}
@ -483,15 +460,10 @@ sub tpl(){
}
$ct4rel = $db->search_content3($searchref,$table,$dbt->{shareedms_conf}->{parent_id},$node_meta,$users_dms->{u_id},$lang,"$main_ids","$tplids","$ct_ids",$v_journal,$time,$R::s_kontext,$scol,$users_dms->{sort_updown},$offset,$limit,$export,$R::todo,$ck4ex,$opos);
#TODO check
if($node_meta->{node_name} eq "Faktura" || $node_meta->{tpl_id} == 218 || $node_meta->{tpl_id} == 209){
if($node_meta->{node_name} eq "Faktura" || $node_meta->{tpl_id} == 218){
my $v_journalparts = "";
$v_journalparts = $v_journal . "_parts";
$ct4rel_parts = $db->search_content3($searchref,$table,$dbt->{shareedms_conf}->{parent_id},$node_meta,$users_dms->{u_id},$lang,"$main_ids","$tplids","$ct_ids",$v_journalparts,$time,$R::s_kontext,$scol,$users_dms->{sort_updown},$offset,$limit,$export,$R::todo,$ck4ex,$opos);
#collect invoice ids in kontext of parts
foreach my $cp_id (keys (%$ct4rel_parts)){
$ct_ids .= "$ct4rel_parts->{$cp_id}->{ct_id}," if($R::detail_search && ($R::s_kontext && $R::s_kontext eq "Waren" || $export eq "FiBu"));
}
}
}#end $ct4rel collect
@ -515,24 +487,18 @@ sub tpl(){
my $hstyle = "border-right: solid thin gray;border-bottom: solid thin gray;";
#if($v_journal && $v_journal =~ /journal/){
# print $q->div({-style=>"background-color:silver;$hstyle"},$but->singlesubmit1("detail_search","New methods xxxxxxxx","",""),"\n");
#}
if($v_journal && $v_journal =~ /journal/){
print $q->div({-style=>"background-color:silver;$hstyle"},$but->singlesubmit1("detail_search","operator_accounting","","margin:0 0 2px 20px;",""),$but->radiobox2("accounting_type","$R::accounting_type","","Pauschal (sig)","Reale Gebühren")),"\n";
}
print $q->hidden(-name=>'mandant_main_id', -value=>"$dbt->{shareedms_conf}->{parent_id}"),"\n";
print $q->hidden(-name=>'tpl_id4trans', -value=>"$node_meta->{tpl_id}"),"\n";
print $q->start_table({ -style=>'clear:both;', -border=>'0', -width=>'100%',-align=>'center', -cellpadding=>'0', -cellspacing=>'0'}),"\n";
#1. Zeile mit Suchfelder und NEU-Anlage
#table-switch!!!
my $sb_style = "";
my $search = "search";
if($v_journal =~ /journal/){
$search = "search_export";
$sb_style= "font-size:0.61em;";
}
#1. search line
print $q->Tr();
print $q->td({-style=>"background-color:silver;"},""),"\n";
print $q->td({-style=>"background-color:silver;$hstyle"},$but->singlesubmit1("detail_search","$search","","$sb_style;"),"\n");
print $q->td({-style=>"background-color:silver;$hstyle"},$but->singlesubmit1("detail_search","search","","width:100%;","")),"\n";
$edit="rel_edit";
$new_key="new_content";
@ -774,7 +740,7 @@ sub tpl(){
$sum_kasse = $ct4rel->{$id}->{int01} if($ct4rel->{$id}->{state} eq "Kassenbestand");
$sum_start = $ct4rel->{$id}->{int02} if($ct4rel->{$id}->{state} eq "Kassenbestand");
if(eval($sum_pos . $max_op . $max_sum_pos) || $table ne "contenttrans"){
if(1==1){
if(1==1){
$nr++;
$nx=$nr;

View file

@ -524,7 +524,7 @@ EOF
#if(!$ctt->{close_time} && $varenv{Zahlungsweise} && $users_dms->{u_id} == $dbt->{copri_conf}->{superu_id}){
if($users_dms->{int03} == 2){
#only if user is also a primary DMS user with invoice rw
print $q->hidden(-name=>'printer_id', -value=>"PDF - Normalpapier", -override=>'1');
print $q->hidden(-name=>'printer_id', -value=>"PDF", -override=>'1');
my $dbh_primary = $dbt->dbconnect_extern("sharee_primary");
my $users_dms_primary = { u_id => 0 };
$users_dms_primary = $dbt->select_users($dbh_primary,$users_dms->{u_id},"and int03=2");

View file

@ -0,0 +1 @@
../../../../../sharee.bike/copri-bike/main/src/scripts/coupongen_check.pl

View file

@ -137,6 +137,6 @@ if($todo eq "fraud_rental" && $pos_id){
my $booking = { c_id => 0 };
$booking = $dbt->fetch_tablerecord($dbh,$booking_pos);
$smstrans->sms_message($todo,"",$sms_to,$booking->{ct_name});
#$smstrans->sms_message($todo,"",$sms_to,$booking->{ct_name});
}#end