";
- $col="bgcolor='$color{'color22'}'";
- }
-
- #if a field is empty, replace it with a '---' to see colorized info!
- $temp[1] = '---' if (!$temp[1]);
- $temp[2] = '---' if (!$temp[2]);
-
- print <$temp[0]
-
+
+END
+#Check if we need to show HOSTBOX and/or CUSTBOX
+foreach my $row (@$res) {
+ my ($gr,$comp,$type,$name1,$str,$nr,$plz,$city,$bank,$iban,$bic,$blz,$kto,$email,$inet,$hrb,$ustid,$tel,$fax) = @$row;
+ if ($type eq 'HOST'){
+ $host=1;
+ }
+ if ($type eq 'CUST'){
+ $cust=1;
+ }
+}
+#Show HOSTER Addresses if any
+ if ($host){
+ $count=0;
+ #EXISTING HOST BOX
+ &Header::openbox('100%', 'left',$Lang::tr{'acct exst_host_addr'} );
+ my $float;
+ print "
";
+ foreach my $row (@$res) {
+ #SET colors for tablerows
+ $col="style='background-color:$color{'color22'}'";
+ $col1="style='background-color:#e2d8d8'";
+ my ($gr,$comp,$type,$name1,$str,$nr,$plz,$city,$bank,$iban,$bic,$blz,$kto,$email,$inet,$hrb,$ustid,$tel,$fax) = @$row;
+ if ($cgiparams{'oldcompname'} eq $comp){
+ $col="style='background-color:yellow'";
+ $col1="style='background-color:yellow'";
+ }
+ if ($type eq 'HOST'){
+ $count++;
+ if($count % 2){
+ print"
";
+ foreach my $row (@$res) {
+ #SET colors for tablerows
+ $col="style='background-color:$color{'color22'}'";
+ my ($gr,$comp,$type,$name1,$str,$nr,$plz,$city,$bank,$iban,$bic,$blz,$kto,$email,$inet,$hrb,$ustid,$tel,$fax) = @$row;
+ if ($cgiparams{'oldcompname'} eq $comp){
+ $col="style='background-color:yellow'";
+ }
+ if ($type eq 'CUST'){
+ $count++;
+ print"
";
+
+ print<
+
+
+ $Lang::tr{'acct company'}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
$comp
+
+
+
$name1
+
+
+
$str $nr
+
+
+
$plz $city
+
+
+
+
+END
+ if(! ($count % 3)) {
+ print"
";
+ }
+ }
+
+ }
+ if ($count %2){
+ print"
";
+ }
+ print"";
+ &Header::closebox();
+ }else{
+ &Header::openbox('100%', 'left',$Lang::tr{'acct exst_cust_addr'} );
+ print $Lang::tr{'acct cust empty'};
+ &Header::closebox();
+ }
+ &Header::closebigbox();
+ &Header::closepage();
+ exit 0;
+}
+
+sub checkfield{
+ my $field=$_[0];
+ my $fieldvalue=$_[1];
+ my $errormessage=$_[2];
+
+ if (!&validtextfield($fieldvalue)){
+ if(!$fieldvalue){
+ $errormessage.="$Lang::tr{'acct empty field'} $field ";
+ }else{
+ $errormessage.="$Lang::tr{'acct invalid'} $field ";
+ }
+ }
+ return $errormessage;
+}
+
+sub checkaddress{
+ #Check if an address with the same name alread exists
+ if ($cgiparams{'update'} ne 'on'){
+ my $res=&ACCT::getaddresses;
+ foreach my $row (@$res) {
+ my ($anz,$name)=@$row;
+ if ($name eq $cgiparams{'txt_company'}){
+ $errormessage.=$Lang::tr{'acct companyexists'};
+ }
+ }
+ }
+ #Check Companyfield
+ $errormessage=&checkfield($Lang::tr{'acct company'},$cgiparams{'txt_company'},$errormessage);
+
+ #Check Name1
+ if($cgiparams{'txt_name1'}){
+ $errormessage=&checkfield($Lang::tr{'acct name1'},$cgiparams{'txt_name1'},$errormessage);
+ }
+
+ #Check Name2
+ if($cgiparams{'txt_name2'}){
+ $errormessage=&checkfield($Lang::tr{'acct name2'},$cgiparams{'txt_name2'},$errormessage);
+ }
+
+ #Check STREET
+ $errormessage=&checkfield($Lang::tr{'acct str'},$cgiparams{'txt_str'},$errormessage);
+
+ #Check STREET-NR
+ if (! $cgiparams{'txt_str_nr'}){
+ $errormessage.="$Lang::tr{'acct empty field'} $Lang::tr{'acct str_nr'} ";
+ }else{
+ if(! &validalphanumfield($cgiparams{'txt_str_nr'})){
+ $errormessage.="$Lang::tr{'acct invalid'} $Lang::tr{'acct str_nr'} ";
+ }
+ }
+
+ #Check POSTAL-CODE
+ if (! $cgiparams{'txt_plz'}){
+ $errormessage.="$Lang::tr{'acct empty field'} $Lang::tr{'acct plz'} ";
+ }else{
+ if(! &validnumfield($cgiparams{'txt_plz'})){
+ $errormessage.="$Lang::tr{'acct invalid'} $Lang::tr{'acct plz'} ";
+ }
+ }
+
+ #Check CITY
+ $errormessage=&checkfield($Lang::tr{'acct city'},$cgiparams{'txt_city'},$errormessage);
+
+ #Check E-MAIL
+ if(! $cgiparams{'txt_email'}){
+ $errormessage.="$Lang::tr{'acct empty field'} $Lang::tr{'acct email'} ";
+ }else{
+ if (! &General::validemail($cgiparams{'txt_email'})){
+ $errormessage.=" $Lang::tr{'acct invalid'} $Lang::tr{'acct email'}";
+ }
+ }
+
+ #Check all fields required for companytype "HOST"
+ if ($cgiparams{'rdo_companytype'} eq 'HOST'){
+ #Check BANK
+ $errormessage=&checkfield($Lang::tr{'acct bank'},$cgiparams{'txt_bank'},$errormessage);
+
+ #Check IBAN - optional
+ if($cgiparams{'txt_iban'}){
+ if(!&validalphanumfield($cgiparams{'txt_iban'})){
+ $errormessage.="$Lang::tr{'acct invalid'} $Lang::tr{'acct iban'} ";
+ }
+ }
+ if($cgiparams{'txt_bic'}){
+ if(!&validalphanumfield($cgiparams{'txt_bic'})){
+ $errormessage.="$Lang::tr{'acct invalid'} $Lang::tr{'acct bic'} ";
+ }
+ }
+ if(($cgiparams{'txt_iban'} && $cgiparams{'txt_blz'})||(!$cgiparams{'txt_iban'} && $cgiparams{'txt_blz'})){
+ #Check BLZ
+ if(! &validnumfield($cgiparams{'txt_blz'})){
+ $errormessage.="$Lang::tr{'acct invalid'} $Lang::tr{'acct blz'} ";
+ }
+ #Check BANKACCOUNT
+ if($cgiparams{'txt_kto'}){
+ if(! &validnumfield($cgiparams{'txt_kto'})){
+ $errormessage.="$Lang::tr{'acct invalid'} $Lang::tr{'acct kto'} ";
+ }
+ }elsif(!$cgiparams{'txt_kto'}){
+ $errormessage.="$Lang::tr{'acct empty field'} $Lang::tr{'acct kto'} ";
+ }
+ }elsif(!$cgiparams{'txt_iban'} && !$cgiparams{'txt_blz'}){
+ $errormessage.="$Lang::tr{'acct empty field'} $Lang::tr{'acct blz'} ";
+ #Check BANKACCOUNT
+ if($cgiparams{'txt_kto'}){
+ if(! &validnumfield($cgiparams{'txt_kto'})){
+ $errormessage.="$Lang::tr{'acct invalid'} $Lang::tr{'acct kto'} ";
+ }
+ }elsif(!$cgiparams{'txt_kto'}){
+ $errormessage.="$Lang::tr{'acct empty field'} $Lang::tr{'acct kto'} ";
+ }
+ }
+
+ #Check Internet
+ if($cgiparams{'txt_inet'}){
+ if ($cgiparams{'txt_inet'} =~ m/([a-z]+:\/\/)??([a-z0-9\-]+\.){1}(([a-z0-9\-]+\.){0,})([a-z0-9\-]+){1}/o) {
+ $cgiparams{'txt_inet'}=$2.$3.$5;
+ } else {
+ $errormessage.="$Lang::tr{'acct invalid'} $Lang::tr{'acct inet'} ";
+ }
+ }
+ #Check Hrb
+ if($cgiparams{'txt_hrb'}){
+ $errormessage=&checkfield($Lang::tr{'acct hrb'},$cgiparams{'txt_hrb'},$errormessage);
+ }
+
+ }
+
+ #Check Phone
+ if($cgiparams{'txt_tel'}){
+ if (!&validphonefield($cgiparams{'txt_tel'})){
+ $errormessage.="$Lang::tr{'acct invalid'} $Lang::tr{'acct tel'} ";
+ }
+ }
+
+ return $errormessage;
+}
+
+sub checkproxy{
+ if(-f "${General::swroot}/proxy/enable"){
+ $proxsrv=$Lang::tr{'running'};
+ }else{
+ $proxsrv=$Lang::tr{'stopped'};
+ }
+ my $srce = "${General::swroot}/proxy/squid.conf";
+ my $string1 = 'access\.log';
+ open(FH, $srce);
+ while(my $line = ) {
+ if($line =~ m/$string1/) {
+ $proxlog=$Lang::tr{'running'};
+ }
+ }
+ close FH;
+ return;
+}
+
+sub validtextfield{
+ #GET: Input from a Textfield
+ #GIVES: True if valid, false if not valid
+ my $remark = $_[0];
+
+ # Each part should be at least two characters in length
+ # but no more than 63 characters
+ if (length ($remark) < 1 || length ($remark) > 255) {
+ return 0;}
+ # Only valid characters are a-z, A-Z, 0-9 and -
+ if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\&\|\ß_()\/\s]*$/) {
+ return 0;}
+ # First character can only be a letter or a digit
+ if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9(]*$/) {
+ return 0;}
+ # Last character can only be a letter or a digit
+ if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
+ return 0;}
+ return 1;
+}
+
+sub validnumfield{
+ #GET: Input from a numeric field
+ #GIVES: True if valid, false if not valid
+ my $num = $_[0];
+
+ # Each part should be at least two characters in length
+ # but no more than 63 characters
+ if (length ($num) < 1 || length ($num) > 255) {
+ return 0;}
+ # Only valid characters are a-z, A-Z, 0-9 and -
+ if ($num !~ /^[0-9.]*$/) {
+ return 0;}
+ # First character can only be a letter or a digit
+ if (substr ($num, 0, 1) !~ /^[0-9]*$/) {
+ return 0;}
+ # Last character can only be a letter or a digit
+ if (substr ($num, -1, 1) !~ /^[0-9]*$/) {
+ return 0;}
+ return 1;
+}
+
+sub validphonefield{
+ #GET: Input from a numeric field
+ #GIVES: True if valid, false if not valid
+ my $num = $_[0];
+
+ # Each part should be at least two characters in length
+ # but no more than 63 characters
+ if (length ($num) < 1 || length ($num) > 255) {
+ return 0;}
+ # Only valid characters are a-z, A-Z, 0-9 and -
+ if ($num !~ /^[0-9-()\+ ]*$/) {
+ return 0;}
+ # First character can only be a letter or a digit
+ if (substr ($num, 0, 1) !~ /^[0-9(\+]*$/) {
+ return 0;}
+ # Last character can only be a digit
+ if (substr ($num, -1, 1) !~ /^[0-9]*$/) {
+ return 0;}
+ return 1;
+}
+
+sub validalphanumfield{
+ #GET: Input from a numeric field
+ #GIVES: True if valid, false if not valid
+ my $remark = $_[0];
+
+ # Each part should be at least two characters in length
+ # but no more than 63 characters
+ if (length ($remark) < 1 || length ($remark) > 255) {
+ return 0;}
+ # Only valid characters are a-z, A-Z, 0-9 and -
+ if ($remark !~ /^[0-9a-zA-Z]*$/) {
+ return 0;}
+ # First character can only be a letter or a digit
+ if (substr ($remark, 0, 1) !~ /^[0-9A-Za-z]*$/) {
+ return 0;}
+ # Last character can only be a letter or a digit
+ if (substr ($remark, -1, 1) !~ /^[0-9a-zA-Z]*$/) {
+ return 0;}
+ return 1;
+}
+
+sub error{
+ if ($errormessage) {
+ &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
+ print "$errormessage\n";
+ print " \n";
+ &Header::closebox();
+ }
+}
+
+sub billgroupsite{
+ &Header::openpage("$Lang::tr{'acct billgroup'}", 1, '');
+ &Header::openbigbox('100%', 'center');
+ &error;
+ my $host;
+ my $cust;
+ my @oldhosts;
+ my $grp;
+ my $mailrcpt;
+ my $ccmailrcpt;
+ #Get addresses from DB
+ my $res = &ACCT::getaddresses;
+ #Check if we need to show NEW-BillGROUP-BOX or Hint
+ foreach my $row (@$res) {
+ my ($gr,$comp,$type,$name1,$str,$nr,$plz,$city,$bank,$iban,$bic,$blz,$kto,$email,$inet,$hrb,$ust,$tel,$fax,$ccmail) = @$row;
+ $grp=$gr;
+ $mailrcpt=$email;
+ $ccmailrcpt=$ccmail;
+ if ($type eq 'HOST'){
+ $host=1;
+ }
+ if ($type eq 'CUST'){
+ $cust=1;
+ }
+ }
+if ($host && $cust){
+ #Fill CCMAIL
+ if (!$cgiparams{'txt_ccmail'}){
+ $cgiparams{'txt_ccmail'}=$ccmailrcpt;
+ }
+ &Header::openbox('100%', 'left',"$Lang::tr{'acct edit_addr'}" );
+ print<
+
+
+
$Lang::tr{'name'}
+
+
+
+
+
+
+
$Lang::tr{'acct billtext1'}
+
+
+
+END
+ #Print Dropdown Menu for HOSTER and CUSTOMER
+ print "
$Lang::tr{'acct hoster'}
";
+ print "
$Lang::tr{'acct customer'}
";
+ print "
";
+ #Print multiselectbox for hosts/users which should be part of this group
+ my $hosts=&ACCT::gethosts;
+ print"
$Lang::tr{'acct members'}
";
+ print "
";
+ #set right decimal seperator for cent value
+ setlocale(LC_NUMERIC,"$mainsettings{'LANGUAGE'}_$uplang");
+ my $val=sprintf"%.3f",$cgiparams{'txt_cent'};
+ print"
$Lang::tr{'acct cent'}
$settings{'CURRENCY'}
";
+ #Optional note
+ print"
$Lang::tr{'acct optional'}
";
+ print"
";
+ print"
";
+
+ #LOGO Upload if update eq 'on'
+ if ($cgiparams{'update'} eq 'on'){
+ print<
+
+
$Lang::tr{'acct logo upload'}
+
+
+
+
+
$Lang::tr{'acct logo'}
+END
+ #Show Logo in webinterface with 1/2 size if set
+ if (-f "$logopath/$cgiparams{'txt_billgroup'}/logo.png"){
+ print"