mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-07-17 18:27:27 +02:00
copri Faktura ticket email integration. Table depended sort. Cleanup users table
This commit is contained in:
parent
1672564775
commit
e3d3713994
16 changed files with 219 additions and 238 deletions
|
@ -7,6 +7,7 @@
|
|||
#
|
||||
#Example
|
||||
#./src/scripts/mailTransportcms.pl 'shareedms-operator' 'send_alarm2hotline' '[user.c_id]' '[contenttxxxx.c_id]'
|
||||
#./src/scripts/mailTransportcms.pl 'shareedms-operator' 'send_invoice_cms' '[user.c_id]' '[contenttxxxx.c_id]' '' '[cmstext_select]' '[with_pdf]'
|
||||
#
|
||||
#
|
||||
#
|
||||
|
@ -42,6 +43,8 @@ my $todo = $ARGV[1] || "";
|
|||
my $adr_id = $ARGV[2] || "";
|
||||
my $ct_id = $ARGV[3] || "";
|
||||
my $temppw = $ARGV[4] || "";
|
||||
my $cmstext_select = $ARGV[5] || "";
|
||||
my $with_pdf = $ARGV[6] || "";
|
||||
|
||||
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, temppw:$temppw\n";
|
||||
|
@ -80,13 +83,13 @@ if(looks_like_number($adr_id)){
|
|||
#send_invoice
|
||||
if($todo eq "send_invoice" && looks_like_number($ct_id)){
|
||||
$sendref->{mailxcfg} = "mailx_invoice";
|
||||
$sendmail = send_invoice($todo,$sendref,$ctadr,$ct_id);
|
||||
$sendmail = send_invoice($todo,$sendref,$ctadr,$ct_id,"email-invoice",$with_pdf);
|
||||
}
|
||||
|
||||
#send_warninginvoice
|
||||
if($todo eq "send_warninginvoice" && looks_like_number($ct_id)){
|
||||
$sendref->{mailxcfg} = "mailx_invoice_bcc";
|
||||
$sendmail = send_warninginvoice($todo,$sendref,$ctadr,$ct_id);
|
||||
#send_invoice_cms
|
||||
if($todo eq "send_invoice_cms" && looks_like_number($ct_id) && $cmstext_select){
|
||||
$sendref->{mailxcfg} = "mailx_invoice_bcc";#with BCC
|
||||
$sendmail = send_invoice($todo,$sendref,$ctadr,$ct_id,$cmstext_select,$with_pdf);
|
||||
}
|
||||
|
||||
#send_emailack
|
||||
|
@ -115,7 +118,7 @@ if($todo eq "send_occupied2hotline"){
|
|||
$sendmail = send_occupied2hotline($sendref);
|
||||
}
|
||||
|
||||
#send_invoice_onwork once a week as reminder
|
||||
#send_invoice_onwork once a week as reminder [in Arbeit|eMail gesendet]
|
||||
if($todo eq "send_invoice_onwork"){
|
||||
#loop operators DB
|
||||
while (my ($key, $op_name) = each %{ $dbt->{operator} }) {
|
||||
|
@ -144,18 +147,21 @@ if($sendmail->{c_id}){
|
|||
|
||||
#send_invoice
|
||||
sub send_invoice {
|
||||
my $todo = shift;
|
||||
my $sendref = shift;
|
||||
my $ctadr = shift;
|
||||
my $ct_id = shift;
|
||||
|
||||
my $project = $dbt->{operator}->{$varenv{dbname}}->{project} || "";
|
||||
my $dbh_primary = $dbt->dbconnect_extern($dbt->{primary}->{sharee_primary}->{database}->{dbname},"iso-8859-1");
|
||||
$varenv{cms} = $dbt->fetch_cms($dbh_primary,{ lang => $ctadr->{txt10} });
|
||||
my $cms_message_key = "email-invoice";
|
||||
my $todo = shift || "";
|
||||
my $sendref = shift || {};
|
||||
my $ctadr = shift || "";
|
||||
my $ct_id = shift || "";
|
||||
my $cms_message_key = shift || "email-invoice";
|
||||
my $with_pdf = shift || "";
|
||||
|
||||
my $dbh = $dbt->dbconnect_extern($dbt->{operator}->{$varenv{dbname}}->{database}->{dbname},"iso-8859-1");
|
||||
#ex. primary hotline c_id=1# changed to Kunden-Fakture c_is=100002, check tablefields
|
||||
my $project = $dbt->{operator}->{$varenv{dbname}}->{project} || "";
|
||||
$varenv{cms} = $dbt->fetch_cms($dbh,{ lang => $ctadr->{txt10} });
|
||||
|
||||
if(!$varenv{cms}->{$cms_message_key}->{txt}){
|
||||
exit 1;
|
||||
}
|
||||
|
||||
my $pref_ctu = {
|
||||
table => "contentuser",
|
||||
fetch => "one",
|
||||
|
@ -178,52 +184,13 @@ sub send_invoice {
|
|||
table => "contenttrans",
|
||||
c_id => "$ct_id",
|
||||
};
|
||||
$dbt->update_one($dbh,$updatectt,"txt30='$now_dt, $ctt->{txt00} per eMail versandt'");
|
||||
my $log_stamp = strftime "%d.%m.%Y %H:%M:%S", localtime;
|
||||
my $mailing_log = $ctt->{txt30} . "\n- $log_stamp mailing: $cms_message_key";
|
||||
$dbt->update_one($dbh,$updatectt,"txt30='$mailing_log'");
|
||||
|
||||
return $sendref;
|
||||
}#end send_invoice
|
||||
|
||||
#TODO with CMS-Text selection
|
||||
#send_warninginvoice
|
||||
sub send_warninginvoice {
|
||||
my $todo = shift;
|
||||
my $sendref = shift;
|
||||
my $ctadr = shift;
|
||||
my $ct_id = shift;
|
||||
|
||||
my $project = $dbt->{operator}->{$varenv{dbname}}->{project} || "";
|
||||
my $dbh_primary = $dbt->dbconnect_extern($dbt->{primary}->{sharee_primary}->{database}->{dbname},"iso-8859-1");
|
||||
$varenv{cms} = $dbt->fetch_cms($dbh_primary,{ lang => $ctadr->{txt10} });
|
||||
my $cms_message_key = "email-invoice";
|
||||
|
||||
my $dbh = $dbt->dbconnect_extern($dbt->{operator}->{$varenv{dbname}}->{database}->{dbname},"iso-8859-1");
|
||||
my $pref_ctu = {
|
||||
table => "contentuser",
|
||||
fetch => "one",
|
||||
c_id => "100002",
|
||||
};
|
||||
my $uadr = { c_id => 0 };
|
||||
$uadr = $dbt->fetch_tablerecord($dbh,$pref_ctu);
|
||||
|
||||
my $fetchctt = {
|
||||
table => "contenttrans",
|
||||
fetch => "one",
|
||||
c_id => "=::$ct_id",
|
||||
};
|
||||
my $ctt = { c_id => 0 };
|
||||
$ctt = $dbt->fetch_tablerecord($dbh,$fetchctt);
|
||||
|
||||
$sendref = prepare_content($sendref,$ctadr,$uadr,$ctt,$varenv{cms}->{$cms_message_key}->{txt});
|
||||
|
||||
my $updatectt = {
|
||||
table => "contenttrans",
|
||||
c_id => "$ct_id",
|
||||
};
|
||||
#$dbt->update_one($dbh,$updatectt,"txt30='$now_dt, $ctt->{txt00} per eMail versandt'");
|
||||
|
||||
return $sendref;
|
||||
}#end send_warninginvoice
|
||||
|
||||
|
||||
#send_emailack
|
||||
sub send_emailack {
|
||||
|
@ -496,28 +463,22 @@ sub prepare_content {
|
|||
my $ctt = shift || {};
|
||||
my $cms_prim = shift;
|
||||
|
||||
my $globalconf_file = "/var/www/copri4/shareeconf/global.cfg";
|
||||
my $conf = Config::General->new($globalconf_file);
|
||||
my %globalconf = $conf->getall;
|
||||
|
||||
my $app_name = "Mietrad App";
|
||||
#while (my ($key, $merchant) = each %{ $globalconf{merchant_ids} }) {
|
||||
# $app_name =~ s/$app_name/$merchant->{app_name}/ if($merchant->{app_name} && $ctadr->{int15} && $ctadr->{int15} == $merchant->{id});
|
||||
#}
|
||||
$app_name = $dbt->{operator}->{$varenv{dbname}}->{app_name};
|
||||
my $invoice_name = "";
|
||||
my $invoice_nr = "";
|
||||
my $sharee_ticket = "";
|
||||
if(ref($ctt) eq "HASH" && $ctt->{ct_name}){
|
||||
$invoice_name = "$ctt->{txt00}-$varenv{dbname}-$ctt->{ct_name}.pdf";
|
||||
$sendref->{attachment} = "$invoice_name";
|
||||
$sharee_ticket = "[$varenv{dbname}-$ctt->{ct_name}]";
|
||||
$invoice_nr = "$varenv{dbname}-$ctt->{ct_name}";
|
||||
$sharee_ticket = "[$invoice_nr]";
|
||||
}
|
||||
|
||||
my $subject = "TeilRad Mietradsystem";#default
|
||||
$subject = $1 if($cms_prim =~ /--subject--(.*)--subject--/);
|
||||
$subject .= " $sharee_ticket" if($sharee_ticket);
|
||||
$cms_prim =~ s/--subject--$subject--subject--//;
|
||||
$cms_prim =~ s/\n//;
|
||||
$subject .= " $sharee_ticket" if($sharee_ticket);
|
||||
$cms_prim =~ s/\n//;
|
||||
|
||||
my $signature = <<EOF
|
||||
|
@ -540,9 +501,10 @@ EOF
|
|||
$sendref->{subject} =~ s/Mein // if($sendref->{subject} =~ /^Mein/);
|
||||
|
||||
$sendref->{message} = $cms_prim;
|
||||
$sendref->{message} =~ s/::user_name::/$ctadr->{txt01}/;
|
||||
$sendref->{message} =~ s/::user_name::/$ctadr->{txt01}/g;
|
||||
$sendref->{message} =~ s/::app_name::/$app_name/g;
|
||||
$sendref->{message} =~ s/::invoice_name::/$invoice_name/ if($invoice_name);
|
||||
$sendref->{message} =~ s/::invoice_nr::/\<b\>$invoice_nr\<\/b\>/g if($invoice_nr);
|
||||
$sendref->{message} =~ s/::invoice_name::/$invoice_name/g if($invoice_name);
|
||||
$sendref->{message} =~ s/::txid::/$ctt->{txt16}/;
|
||||
$sendref->{message} =~ s/::email_temppassword::/\<b\>$ctadr->{txt04}\<\/b\>/g;
|
||||
$sendref->{message} =~ s/::email_ack_digest::/\<b\>$ctadr->{txt34}\<\/b\>/g;#send_emailack
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue