]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/squid-accounting/accounting.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2014 IPFire Team <alexander.marx@ipfire.org> #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
32 # enable only the following on debugging purpose
34 #use CGI::Carp 'fatalsToBrowser';
36 require '/var/ipfire/general-functions.pl' ;
37 require "${General::swroot}/lang.pl" ;
38 require "${General::swroot}/header.pl" ;
39 require "${General::swroot}/accounting/acct-lib.pl" ;
41 unless (- e
"${General::swroot}/accounting/settings.conf" ) { system ( "touch ${General::swroot}/accounting/settings.conf" ); }
43 my $settingsfile = "${General::swroot}/accounting/settings.conf" ;
44 my $proxyenabled = "${General::swroot}/proxy/enable" ;
45 my $logopath = "/srv/web/ipfire/html/accounting/logo" ;
50 my ( $sec , $min , $hour , $mday , $mon , $year , $wday , $ydat , $isdst )= localtime ();
57 my $proxlog = $Lang :: tr
{ 'stopped' };
58 my $proxsrv = $Lang :: tr
{ 'stopped' };
60 & Header
:: getcgihash
( \
%cgiparams );
61 & General
:: readhash
( "${General::swroot}/main/settings" , \
%mainsettings );
62 & General
:: readhash
( "/srv/web/ipfire/html/themes/" . $mainsettings { 'THEME' }. "/include/colors.txt" , \
%color );
63 & General
:: readhash
( " $settingsfile " , \
%settings ) if (- f
$settingsfile );
65 #Find out which lang is set (used later to set decimal separator correctly)
66 my $uplang = uc ( $mainsettings { 'LANGUAGE' });
67 setlocale LC_NUMERIC
, " $mainsettings {'LANGUAGE'}_ $uplang " ;
69 if ( $cgiparams { 'BILLVIEW' } eq "show" ){
70 my $file = $cgiparams { 'file' };
71 my $name = $cgiparams { 'name' };
72 open ( DLFILE
, "< $file " ) or die "Unable to open $file : $!" ;
73 my @fileholder = < DLFILE
>;
74 print "Content-Type:application/pdf \n " ;
75 my @fileinfo = stat ( " $file " );
76 print "Content-Length: $fileinfo [7] \n " ;
77 print "Content-Disposition:attachment;filename=' $name '; \n\n " ;
81 if ( $cgiparams { 'BILLACTION' } eq "open_preview" ){
82 #Generate preview Bill
83 my $rggrp = $cgiparams { 'txt_billgroup' };
84 my $address_cust = & ACCT
:: getTaAddress
( $rggrp , 'CUST' );
85 my $address_host = & ACCT
:: getTaAddress
( $rggrp , 'HOST' );
86 my $billpos = & ACCT
:: getextrabillpos
( $rggrp );
87 my $mwst = $settings { 'MWST' };
88 my $cur = $settings { 'CURRENCY' };
89 my @now = localtime ( time );
90 $now [ 5 ] = $now [ 5 ] + 1900 ;
91 my $actmonth = $now [ 4 ]+ 1 ;
92 my $actyear = $now [ 5 ];
93 my ( $from , $till )=& ACCT
:: getmonth
( $actmonth , $actyear );
94 my @billar = & ACCT
:: GetTaValues
( $from , $till , $rggrp );
95 my $tempfile =& ACCT
:: pdf2
( \
@billar , $actmonth , $actyear , $mwst , $address_cust , $address_host , $billpos , $rggrp , $cur , "on" );
97 open ( DLFILE
, "< $tempfile " ) or die "Unable to open tmp.pdf: $!" ;
98 my @fileholder = < DLFILE
>;
99 print "Content-Type:application/pdf \n " ;
100 my @fileinfo = stat ( $tempfile );
101 print "Content-Length: $fileinfo [7] \n " ;
102 print "Content-Disposition:attachment;filename='tmp.pdf'; \n\n " ;
108 & Header
:: showhttpheaders
();
110 if ( $cgiparams { 'ACTION' } eq " $Lang ::tr{'acct config'}" ){ #ConfigButton from Menu
113 if ( $cgiparams { 'ACTION' } eq " $Lang ::tr{'acct addresses'}" ){ #AddressmgmntButton from Menu
116 if ( $cgiparams { 'ACTION' } eq " $Lang ::tr{'acct billgroup'}" ){ #BillgroupButton from Menu
119 if ( $cgiparams { 'ACTION' } eq " $Lang ::tr{'acct maintenance'}" ){ #MaintenanceButton from Menu
122 if ( $cgiparams { 'ACTION' } eq " $Lang ::tr{'save'}" ){ #SaveButton on configsite
123 my @val = split ( ' \r\n ' , $cgiparams { 'txt_skipurls' });
125 foreach my $line ( @val ){
126 $skipurls .= "|" . $line ;
128 $skipurls = $skipurls . "|" ;
129 $skipurls =~ s/\|\|/\|/g ;
130 my @txt = split ( ' \r\n ' , $cgiparams { 'txt_mailtxt' });
132 foreach my $txt ( @txt ){
136 if ( $cgiparams { 'USEMAIL' } eq 'on' ){
137 $errormessage =& checkmailsettings
;
138 } elsif ( $cgiparams { 'USEMAIL' } ne 'on' ){
139 $cgiparams { 'txt_mailserver' }= '' ;
140 $cgiparams { 'txt_mailport' }= '' ;
141 $cgiparams { 'txt_mailuser' }= '' ;
142 $cgiparams { 'txt_mailpass' }= '' ;
143 $cgiparams { 'mail_tls' }= '' ;
144 $cgiparams { 'txt_mailsender' }= '' ;
145 $cgiparams { 'txt_mailsubject' }= '' ;
149 open ( TXT
, "> $settingsfile " ) or die ( "Die Datei konnte nicht geƶffnet werden: $! \n " );
151 $settings { 'LOG' } = $cgiparams { 'logging' };
152 $settings { 'EXPERT' } = $cgiparams { 'expert' };
153 $settings { 'MULTIUSER' } = $cgiparams { 'multiuser' };
154 $settings { 'MWST' } = $cgiparams { 'txt_mwst' };
155 $settings { 'CURRENCY' } = $cgiparams { 'txt_currency' };
156 $settings { 'SKIPURLS' } = $skipurls ;
157 $settings { 'USEMAIL' } = $cgiparams { 'USEMAIL' };
158 $settings { 'MAILSRV' } = $cgiparams { 'txt_mailserver' };
159 $settings { 'MAILPORT' } = $cgiparams { 'txt_mailport' };
160 $settings { 'MAILUSER' } = $cgiparams { 'txt_mailuser' };
161 $settings { 'MAILPASS' } = $cgiparams { 'txt_mailpass' };
162 $settings { 'TLS' } = $cgiparams { 'mail_tls' };
163 $settings { 'MAILSENDER' } = $cgiparams { 'txt_mailsender' };
164 $settings { 'MAILSUB' } = $cgiparams { 'txt_mailsubject' };
165 $settings { 'MAILTXT' } = $mailtxt ;
166 & General
:: writehash
( " $settingsfile " , \
%settings );
168 $cgiparams { 'update' }= 'on' ;
172 if ( $cgiparams { 'ACTION' } eq " $Lang ::tr{'acct view'}" ){ #If special month and year is given on mainsite
173 & mainsite
( $cgiparams { 'month' }, $cgiparams { 'year' });
176 if ( $cgiparams { 'ACTION' } eq " $Lang ::tr{'acct commit'}" ){ #Maintenance function
177 & ACCT
:: logger
( $settings { 'LOG' }, "Clear DB (all data) committed). \n " );
181 if ( $cgiparams { 'ACTION2' } eq " $Lang ::tr{'acct commit'}" ){ #Maintenance function
182 & ACCT
:: logger
( $settings { 'LOG' }, "Clear DB (only traffic data) committed). \n " );
186 if ( $cgiparams { 'ACTION1' } eq " $Lang ::tr{'acct commit'}" ){ #Maintenance Function
188 my ( $a , $b )=& ACCT
:: getmonth
( $cgiparams { 'expmonth' }, $cgiparams { 'expyear' });
189 & ACCT
:: delbefore
(( $a - 1 ));
192 if ( $cgiparams { 'ACTION' } eq "viewgraph" ){ #Graph icon on hosttable (viewhosttable)
193 & graphsite
( $cgiparams { 'month' }, $cgiparams { 'year' }, $cgiparams { 'host' });
195 if ( $cgiparams { 'ACTION1' } eq " $Lang ::tr{'save'}" ){ #SaveButton when adding Address
196 $errormessage =& checkaddress
;
199 & addressmgmnt
( $errormessage );
202 $cgiparams { 'txt_company' },
203 $cgiparams { 'rdo_companytype' },
204 $cgiparams { 'txt_name1' },
205 $cgiparams { 'txt_str' },
206 $cgiparams { 'txt_str_nr' },
207 $cgiparams { 'txt_plz' },
208 $cgiparams { 'txt_city' },
209 $cgiparams { 'txt_bank' },
210 $cgiparams { 'txt_iban' },
211 $cgiparams { 'txt_bic' },
212 $cgiparams { 'txt_blz' },
213 $cgiparams { 'txt_kto' },
214 $cgiparams { 'txt_email' },
215 $cgiparams { 'txt_inet' },
216 $cgiparams { 'txt_hrb' },
217 $cgiparams { 'txt_ustid' },
218 $cgiparams { 'txt_tel' },
219 $cgiparams { 'txt_fax' },
221 & ACCT
:: logger
( $settings { 'LOG' }, "Created new address $cgiparams {'txt_company'} as $cgiparams {'rdo_companytype'}. \n " );
226 if ( $cgiparams { 'ACTION' } eq "edit_addr" ){ #Pencil icon in Address overwiev on Addressmgmnt site
227 $cgiparams { 'update' } = 'on' ;
228 $cgiparams { 'oldcompname' }= $cgiparams { 'txt_company' };
231 if ( $cgiparams { 'ACTION' } eq " $Lang ::tr{'update'}" ){ #UpdateButton when editing Address
232 $cgiparams { 'update' } = 'on' ;
233 $errormessage =& checkaddress
;
235 & addressmgmnt
( $errormessage );
238 $cgiparams { 'rdo_companytype' },
239 $cgiparams { 'txt_company' },
240 $cgiparams { 'txt_name1' },
241 $cgiparams { 'txt_str' },
242 $cgiparams { 'txt_str_nr' },
243 $cgiparams { 'txt_plz' },
244 $cgiparams { 'txt_city' },
245 $cgiparams { 'txt_bank' },
246 $cgiparams { 'txt_iban' },
247 $cgiparams { 'txt_bic' },
248 $cgiparams { 'txt_blz' },
249 $cgiparams { 'txt_kto' },
250 $cgiparams { 'txt_email' },
251 $cgiparams { 'txt_inet' },
252 $cgiparams { 'txt_hrb' },
253 $cgiparams { 'txt_ustid' },
254 $cgiparams { 'txt_tel' },
255 $cgiparams { 'txt_fax' },
256 $cgiparams { 'oldcompname' }
258 my $res =& ACCT
:: getbillgroups
;
259 foreach my $line ( @
$res ){
260 my ( $name , $host , $cust )= @
$line ;
261 if ( $host eq $cgiparams { 'oldcompname' }){
262 & ACCT
:: updatebillgrouphost
( $cgiparams { 'oldcompname' }, $cgiparams { 'txt_company' });
263 } elsif ( $cust eq $cgiparams { 'oldcompname' }){
264 & ACCT
:: updatebillgroupcust
( $cgiparams { 'oldcompname' }, $cgiparams { 'txt_company' });
268 & ACCT
:: logger
( $settings { 'LOG' }, "Edited address $cgiparams {'oldcompname'}. \n " );
273 if ( $cgiparams { 'ACTION' } eq "del_addr" ){ #Trash icon in Address overview on Addressmgmnt site
274 my $res =& ACCT
:: checkbillgrp
;
275 foreach my $line ( @
$res ){
276 my ( $grp , $host , $cust ) = @
$line ;
277 if ( $cgiparams { 'txt_company' } eq $host ){
278 $errormessage = " $Lang ::tr{'acct err hostdel'} $grp " ;
280 if ( $cgiparams { 'txt_company' } eq $cust ){
281 $errormessage = " $Lang ::tr{'acct err custdel'} $grp " ;
284 if (! $errormessage ){
285 & ACCT
:: deladdr
( $cgiparams { 'txt_company' });
286 & ACCT
:: logger
( $settings { 'LOG' }, "Deleted address $cgiparams {'txt_company'}. \n " );
288 $cgiparams { 'txt_company' }= '' ;
291 if ( $cgiparams { 'BILLACTION' } eq " $Lang ::tr{'save'}" ){ #SaveButton when adding BillingGroups
292 #check if a group with the same name already exists in DB
293 my $res =& ACCT
:: getbillgroups
;
294 foreach my $row ( @
$res ) {
296 if ( $group eq $cgiparams { 'txt_billgroup' }){
297 $errormessage .= $Lang :: tr
{ 'acct billgroupexists' };
300 #Check if a selected user is in another group already
301 if ( $settings { 'MULTIUSER' } ne 'on' ){
302 #split hosts into array
303 my @user = split ( /\|/ , $cgiparams { 'sel_hosts' });
304 my $res =& ACCT
:: checkusergrp
;
305 foreach my $val ( @
$res ){
306 my ( $grp , $usr )= @
$val ;
307 foreach my $wanted ( @user ){
309 $errormessage .= " $usr $Lang ::tr{'acct usermulti'} $grp <br>" ;
315 if (!& validtextfield
( $cgiparams { 'txt_billgroup' })){
316 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'name'}<br>" ;
318 #FIXME: Validate CENT amount (num with .)
319 #if used colon, replace with .
320 $cgiparams { 'txt_cent' } =~ tr/,/./ ;
321 if (!& validnumfield
( $cgiparams { 'txt_cent' })){
322 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct cent'}<br>" ;
325 my @ips = split ( /\|/ , $cgiparams { 'sel_hosts' });
327 #Check if we use extra bill positions
328 if ( $cgiparams { 'txt_amount' } || $cgiparams { 'txt_name' }|| $cgiparams { 'txt_price' }){
329 if (! $cgiparams { 'txt_amount' } || ! $cgiparams { 'txt_name' } || ! $cgiparams { 'txt_price' }){
330 $errormessage .= " $Lang ::tr{'acct invalid billpos'}<br>" ;
334 if (! & validnumfield
( $cgiparams { 'txt_amount' })){
335 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct amount'}<br>" ;
336 } elsif (! & validtextfield
( $cgiparams { 'txt_name' })){
337 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct name'}<br>" ;
338 } elsif (! & validnumfield
( $cgiparams { 'txt_price' })){
339 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct price pp'}<br>" ;
345 & billgroupsite
( $errormessage );
347 #check if we use extra positions
348 if ( $cgiparams { 'txt_amount' }){
350 $cgiparams { 'txt_posbillgroup' },
351 $cgiparams { 'txt_amount' },
352 $cgiparams { 'txt_name' },
353 $cgiparams { 'txt_price' });
354 & ACCT
:: logger
( $settings { 'LOG' }, "Saved new fixed billposition $cgiparams {'txt_name'} into billgroup $cgiparams {'txt_posbillgroup'} . \n " );
358 & ACCT
:: savebillgroup
(
359 $cgiparams { 'txt_billgroup' },
360 $cgiparams { 'txt_billtext1' },
361 $cgiparams { 'dd_host' },
362 $cgiparams { 'dd_cust' },
363 $cgiparams { 'txt_cent' },
365 & ACCT
:: logger
( $settings { 'LOG' }, "Saved new billgroup $cgiparams {'txt_billgroup'}. \n " );
370 if ( $cgiparams { 'BILLACTION' } eq " $Lang ::tr{'update'}" ){ #UpdateButton when editing BillingGroups
373 my $filename = $cgiparams { 'uploaded_file' };
375 #First check if logo dir exists
376 if (! - d
" $logopath / $cgiparams {'logo_grp'}" ){
377 mkpath
( " $logopath / $cgiparams {'logo_grp'}" , 0 , 01777 );
380 my ( $filehandle ) = CGI
:: upload
( 'uploaded_file' );
381 open ( UPLOADFILE
, "> $logopath / $cgiparams {'logo_grp'}/logo.png" );
383 while ( < $filehandle > ) {
388 #Check dimensions of uploaded file
389 open ( PNG
, "< $logopath / $cgiparams {'logo_grp'}/logo.png" ) ;
393 my ( $width , $height )=& ACCT
:: pngsize
( $PNG1 ) ;
395 if (! & validnumfield
( $width )){
396 $errormessage .= " $Lang ::tr{'acct invalid png'}<br>" ;
397 unlink ( " $logopath / $cgiparams {'logo_grp'}/logo.png" );
398 } elsif ( $width > 400 || $height > 150 ){
399 $errormessage .= " $Lang ::tr{'acct invalid pngsize'} width: $width height: $height <br>" ;
400 unlink ( " $logopath / $cgiparams {'logo_grp'}/logo.png" );
404 #Check if a group with the same name already exists in DB
405 my $res =& ACCT
:: getbillgroups
;
406 foreach my $row ( @
$res ) {
408 if (( $group eq $cgiparams { 'txt_billgroup' }) && ( $cgiparams { 'oldname' } ne $cgiparams { 'txt_billgroup' })){
409 $errormessage .= $Lang :: tr
{ 'acct billgroupexists' };
412 #Check if a selected user is in another group already
413 if ( $settings { 'MULTIUSER' } ne 'on' ){
414 #split hosts into array
415 my @user = split ( /\|/ , $cgiparams { 'sel_hosts' });
416 my $res =& ACCT
:: checkusergrp
;
417 foreach my $val ( @
$res ){
418 my ( $grp , $usr )= @
$val ;
419 foreach my $wanted ( @user ){
420 if ( $usr eq $wanted && $grp ne $cgiparams { 'txt_billgroup' }){
421 $errormessage .= " $usr $Lang ::tr{'acct usermulti'} $grp <br>" ;
427 if (!& validtextfield
( $cgiparams { 'txt_billgroup' })){
428 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'name'}" ;
430 #Validate CENT amount (num with .)
431 #if used colon, replace with .
432 $cgiparams { 'txt_cent' } =~ tr/,/./ ;
433 if (!& validnumfield
( $cgiparams { 'txt_cent' })){
434 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct cent'}<br>" ;
438 my @ips = split ( /\|/ , $cgiparams { 'sel_hosts' });
440 #Check if we use extra bill positions
441 if ( $cgiparams { 'txt_amount' } || $cgiparams { 'txt_name' }|| $cgiparams { 'txt_price' }){
442 if (! $cgiparams { 'txt_amount' } || ! $cgiparams { 'txt_name' } || ! $cgiparams { 'txt_price' }){
443 $errormessage .= " $Lang ::tr{'acct invalid billpos'}<br>" ;
447 if (! & validnumfield
( $cgiparams { 'txt_amount' })){
448 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct amount'}<br>" ;
449 } elsif (! & validtextfield
( $cgiparams { 'txt_name' })){
450 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct name'}<br>" ;
451 } elsif (! & validnumfield
( $cgiparams { 'txt_price' })){
452 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct price pp'}<br>" ;
456 #Check if we added some CC mail recipients
457 if ( $cgiparams { 'txt_ccmail' }){
458 $cgiparams { 'txt_ccmail' }=~ s/ //g ;
459 #Split line into single addresses and check each one
460 my @ccaddr = split ( "," , $cgiparams { 'txt_ccmail' });
461 foreach my $cc ( @ccaddr ){
462 if (! & General
:: validemail
( $cc )){
463 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct ccmail'} $cc <br>" ;
468 $cgiparams { 'update' } = 'on' ;
471 #update fixedbillpositions if defined
472 if ( $cgiparams { 'oldname' } ne $cgiparams { 'txt_billgroup' }){
473 & ACCT
:: updatebillpos
( $cgiparams { 'oldname' }, $cgiparams { 'txt_billgroup' });
475 #Check if we use extra positions
476 if ( $cgiparams { 'txt_amount' }){
478 $cgiparams { 'txt_billgroup' },
479 $cgiparams { 'txt_amount' },
480 $cgiparams { 'txt_name' },
481 $cgiparams { 'txt_price' });
483 #Check if we have NEW cc Mails
484 if ( $cgiparams { 'txt_ccmail' } ne $cgiparams { 'oldccmail' }){
485 & ACCT
:: updateccaddr
( $cgiparams { 'txt_ccmail' }, $cgiparams { 'dd_cust' });
487 & ACCT
:: deletebillgroup
( $cgiparams { 'oldname' });
488 & ACCT
:: savebillgroup
(
489 $cgiparams { 'txt_billgroup' },
490 $cgiparams { 'txt_billtext1' },
491 $cgiparams { 'dd_host' },
492 $cgiparams { 'dd_cust' },
493 $cgiparams { 'txt_cent' },
499 if ( $cgiparams { 'BILLACTION' } eq "edit_billgroup" ){ #Pencil icon in Billgroup table
500 $cgiparams { 'update' } = 'on' ;
503 if ( $cgiparams { 'BILLACTION' } eq "delete_billgroup" ){ #Trash icon in Billgroup table
504 & deletefiles
( $cgiparams { 'txt_billgroup' });
505 & ACCT
:: delbillpos
( $cgiparams { 'txt_billgroup' });
506 & ACCT
:: deletebillgroup
( $cgiparams { 'txt_billgroup' });
507 & ACCT
:: logger
( $settings { 'LOG' }, "Deleted billgroup $cgiparams {'txt_billgroup'}. \n " );
510 if ( $cgiparams { 'BILLACTION' } eq "open_billgroup" ){ #Folder icon on billgrouptable (viewtablebillgroup)
511 & billoverview
( $cgiparams { 'txt_billgroup' });
513 if ( $cgiparams { 'BILLPOS' } eq "delpos" ){ #Trash icon in Billpos table
514 $cgiparams { 'update' } = 'on' ;
515 & ACCT
:: delbillpos_single
( $cgiparams { 'txt_billpos' }, $cgiparams { 'txt_billgroup' });
516 & ACCT
:: logger
( $settings { 'LOG' }, "Deleted fixed billposition $cgiparams {'txt_billpos'} from billgroup $cgiparams {'txt_billgroup'}. \n " );
519 if ( $cgiparams { 'BILLPOS' } eq " $Lang ::tr{'save'}" ){ #Savebutton in Billpos table
520 $cgiparams { 'update' }= 'on' ;
521 #Check if we use extra bill positions
522 if ( $cgiparams { 'txt_amount' } || $cgiparams { 'txt_name' }|| $cgiparams { 'txt_price' }){
523 if (! $cgiparams { 'txt_amount' } || ! $cgiparams { 'txt_name' } || ! $cgiparams { 'txt_price' }){
524 $errormessage .= " $Lang ::tr{'acct invalid billpos'}<br>" ;
528 #if used colon, replace with .
529 $cgiparams { 'txt_price' } =~ tr/,/./ ;
530 if (! & validnumfield
( $cgiparams { 'txt_amount' })){
531 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct amount'}<br>" ;
532 } elsif (! & validtextfield
( $cgiparams { 'txt_name' })){
533 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct name'}<br>" ;
534 } elsif (! & validnumfield
( $cgiparams { 'txt_price' })){
535 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct price pp'}<br>" ;
540 & billgroupsite
( $errormessage );
542 #check if we use extra positions
543 if ( $cgiparams { 'txt_amount' }){
545 $cgiparams { 'txt_billgroup' },
546 $cgiparams { 'txt_amount' },
547 $cgiparams { 'txt_name' },
548 $cgiparams { 'txt_price' });
550 & ACCT
:: logger
( $settings { 'LOG' }, "Added fixed billposition $cgiparams {'txt_amount'} $cgiparams {'txt_name'} with price $cgiparams {'txt_price'} to billgroup $cgiparams {'txt_billgroup'}. \n " );
557 #Check if we already have settings
558 if ( - z
$settingsfile ){
561 & mainsite
(( $mon + 1 ),( $year + 1900 ));
567 my $blockactivation = '' ;
568 #If update set fieldvalues new
569 if ( $cgiparams { 'update' } eq 'on' ){
570 $settings { 'USEMAIL' } = 'on' ;
571 $settings { 'MAILSRV' } = $cgiparams { 'txt_mailserver' };
572 $settings { 'MAILPORT' } = $cgiparams { 'txt_mailport' };
573 $settings { 'MAILUSER' } = $cgiparams { 'txt_mailuser' };
574 $settings { 'MAILPASS' } = $cgiparams { 'txt_mailpass' };
575 $settings { 'MAILSUB' } = $cgiparams { 'txt_mailsubject' };
576 $settings { 'MAILTXT' } = $cgiparams { 'txt_mailtxt' };
579 $checked { 'expert' }{ $settings { 'EXPERT' }} = 'CHECKED' ;
580 $checked { 'logging' }{ $settings { 'LOG' }} = 'CHECKED' ;
581 $checked { 'multiuser' }{ $settings { 'MULTIUSER' }} = 'CHECKED' ;
582 $checked { 'usemail' }{ $settings { 'USEMAIL' }} = 'CHECKED' ;
583 $checked { 'mail_tls' }{ $settings { 'TLS' }} = 'CHECKED' ;
586 & Header
:: openpage
( $Lang :: tr
{ 'acct settings' }, 1 , '' );
587 & Header
:: openbigbox
( '100%' , 'center' );
589 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'acct config' });
591 #### JAVA SCRIPT ####
594 \$(document).ready(function() {
595 // Show/Hide elements when NAT checkbox is checked.
596 if (\$("#MAIL").attr("checked")) {
599 \$(".MAILSRV").hide();
602 // Show NAT area when "use nat" checkbox is clicked
603 \$("#MAIL").change(function() {
604 \$(".MAILSRV").toggle();
610 #######################
611 $settings { 'SKIPURLS' } =~ tr/|/\r\n/ ;
612 $settings { 'MAILTXT' } =~ tr/|/\r\n/ ;
613 my $col = "style='background-color: $color {'color22'}'" ;
615 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
616 <table style='width:100%'>
618 <th colspan='3'></th>
621 <td style='width:24em'> $Lang ::tr{'acct logging'}</td>
622 <td><input type='checkbox' name='logging' $checked {'logging'}{'on'}></td>
626 <td> $Lang ::tr{'acct expert'}</td>
627 <td><input type='checkbox' name='expert' $checked {'expert'}{'on'}></td>
631 <td> $Lang ::tr{'acct multiuser'}</td>
632 <td><input type='checkbox' name='multiuser' $checked {'multiuser'}{'on'}></td>
636 <td> $Lang ::tr{'acct mwst'}</td>
637 <td><input type='text' name='txt_mwst' value=' $settings {'MWST'}' style='width:22em;'></td>
640 <td> $Lang ::tr{'acct currency'}</td>
641 <td><input type='text' name='txt_currency' value=' $settings {'CURRENCY'}' style='width:22em;'></td>
645 <td valign='top'> $Lang ::tr{'acct skipurl'}</td>
646 <td style='padding-left:0.2em;'><textarea name="txt_skipurls" cols="20" rows="6" style='width:22em;'> $settings {'SKIPURLS'}</textarea></td>
650 <td> $Lang ::tr{'acct usemail'}</td>
651 <td><label><input type='checkbox' name='USEMAIL' id='MAIL' $checked {'usemail'}{'on'}></label></td>
656 <div class="MAILSRV">
657 <table style='width:100%;'>
659 <td style='width:24em'> $Lang ::tr{'acct mailaddr'}</td>
660 <td><input type='text' name='txt_mailserver' value=' $settings {'MAILSRV'}' style='width:22em;'></td>
663 <td> $Lang ::tr{'acct mailport'}</td>
664 <td><input type='text' name='txt_mailport' value=' $settings {'MAILPORT'}' size='3'></td>
667 <td> $Lang ::tr{'acct mailuser'}<img src='/blob.gif' alt='*' /></td>
668 <td><input type='text' name='txt_mailuser' value=' $settings {'MAILUSER'}' style='width:22em;'></td>
671 <td> $Lang ::tr{'acct mailpass'}<img src='/blob.gif' alt='*' /></td>
672 <td><input type='password' name='txt_mailpass' value=' $settings {'MAILPASS'}' style='width:22em;' ></td>
675 <td> $Lang ::tr{'acct tls'}</td>
676 <td><input type='checkbox' name='mail_tls' $checked {'mail_tls'}{'on'}></td>
679 <td> $Lang ::tr{'acct mailsender'}</td>
680 <td><input type='text' name='txt_mailsender' value=' $settings {'MAILSENDER'}' style='width:22em;'></td>
683 <td colspan='2'> </td>
686 <td> $Lang ::tr{'acct subject'}</td>
687 <td><input type='text' name='txt_mailsubject' value=' $settings {'MAILSUB'}' style='width:22em;'></td>
690 <td valign='top' > $Lang ::tr{'acct mailtxt'}</td>
691 <td style='padding-left:0.2em;'><textarea name="txt_mailtxt" cols="34" rows="6" style='width: 22em;'> $settings {'MAILTXT'}</textarea></td>
697 <table style='width:100%;'>
699 <td colspan='3' display:inline align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}'></td>
708 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
709 <table style='width:100%;'>
712 <td align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'back'}'></td>
717 & Header
:: closebigbox
();
718 & Header
:: closepage
();
724 rmtree
( " $logopath / $grp " );
725 rmtree
( "${General::swroot}/accounting/bill/ $grp " );
731 if ( $_ [ 0 ]){ $mon = $_ [ 0 ];}
732 & Header
:: openpage
( $Lang :: tr
{ 'acct title' }, 1 , '' );
733 & Header
:: openbigbox
( '100%' , 'center' );
737 & viewtablehosts
(( $mon ), $year );
738 & Header
:: closebigbox
();
739 & Header
:: closepage
();
743 & Header
:: openpage
( $Lang :: tr
{ 'acct maintenance' }, 1 , '' );
744 & Header
:: openbigbox
( '100%' , 'center' );
746 #Get size of Databasefile
747 my $sizedb = - s
"/var/ipfire/accounting/acct.db" ;
748 $sizedb = sprintf "%.2f" , $sizedb /( 1024 * 1024 );
749 #Get size of Directory, where all bills are stored
751 find
( sub { $sizerrd += - s
if - f
$_ }, "${General::swroot}/accounting/bill" );
752 $sizerrd = sprintf "%.2f" , $sizerrd /( 1024 * 1024 );
755 #Get latest and earliest entry of DB
756 my ( $min , $max ) = & ACCT
:: getminmax
;
760 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'acct status' });
762 <table style='width:100%;' cellspacong='0' class='tbl'>
764 <th align='left' width='30%'> $Lang ::tr{'name'}</th>
765 <th align='left'> $Lang ::tr{'acct value'}</th>
768 <td> $Lang ::tr{'acct dbsize'}</td>
772 <td> $Lang ::tr{'acct rrdsize'}</td>
776 <td> $Lang ::tr{'acct oldestdb'}</td>
780 <td> $Lang ::tr{'acct latestdb'}</td>
787 #print Database maintenance table
788 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'acct dbmaintenance' });
791 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
792 <table style='width:100%;' cellspacing='0' class='tbl'>
794 <th> $Lang ::tr{'acct task'}</th>
795 <th> $Lang ::tr{'acct parameter'}</th>
796 <th> $Lang ::tr{'acct action'}</th>
799 <td> $Lang ::tr{'acct emptydb'}</td>
801 <td><input type='submit' name='ACTION2' value=' $Lang ::tr{'acct commit'}' style='width:10em'></td>
804 <td> $Lang ::tr{'acct emptydbtraf'}</td>
806 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'acct commit'}' style='width:10em'></td>
809 <td> $Lang ::tr{'acct delbefore'} (ACCT,ACCT_HIST)</td>
810 <td><select name='expmonth'>
812 for ( my $i = 1 ; $i < 13 ; $i ++){
813 print "<option> $i </option>" ;
815 print "</select><select name='expyear'>" ;
816 for ( my $i = 2014 ; $i <=( $year + 1900 ); $i ++){
817 print "<option> $i </option>" ;
821 <td><input type='submit' name='ACTION1' value=' $Lang ::tr{'acct commit'}' style='width:10em'></td>
829 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
830 <table style='width:100%;'>
833 <td align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'back'}'></td>
840 & Header
:: closebigbox
();
841 & Header
:: closepage
();
847 #GET : Timestamp in seconds since 1.1.1970
848 #GIVES: Date in Format dd.mm.yyyy HH:MM:SS
850 my $y = sprintf ( " %02d " ,( localtime ( $val ))[ 5 ]- 100 );
851 my $Y = sprintf ( " %04d " ,( localtime ( $val ))[ 5 ]+ 1900 );
852 my $m = sprintf ( " %02d " ,( localtime ( $val ))[ 4 ]+ 1 );
853 my $d = sprintf ( " %02d " ,( localtime ( $val ))[ 3 ]);
854 my $H = sprintf ( " %02d " ,( localtime ( $val ))[ 2 ]);
855 my $M = sprintf ( " %02d " ,( localtime ( $val ))[ 1 ]);
856 my $S = sprintf ( " %02d " ,( localtime ( $val ))[ 0 ]);
858 return " $d . $m . $Y $H : $M : $S " ;
862 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'menu' });
864 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
865 <table style='width: 100%;'>
867 <td style='display:inline;'>
868 <input type='submit' name='ACTION' value=' $Lang ::tr{'acct config'}'>
869 <input type='submit' name='ACTION' value=' $Lang ::tr{'acct addresses'}'>
870 <input type='submit' name='ACTION' value=' $Lang ::tr{'acct billgroup'}'>
872 if ( $settings { 'EXPERT' } eq 'on' ){
873 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'acct maintenance'}'>" ;
889 & Header
:: openpage
( " $Lang ::tr{'acct host detail'} $grhost " , 1 , '' );
890 & Header
:: openbigbox
( '100%' , 'center' );
891 & Header
:: openbox
( '100%' , 'left' , );
893 & generatemonthgraph
( $grmon , $gryear , $grhost );
896 & Header
:: closebigbox
();
897 & Header
:: closepage
();
901 sub generatemonthgraph
{
905 my ( $from , $till ) = & ACCT
:: getmonth
( $grmon , $gryear );
909 #If we want to show Data from within last 2 months, get DATA from ACCT
910 if ( ! $grmon < ( $mon + 1 ) && $gryear == ( $year + 1900 )){
911 $sth =& ACCT
:: getmonthgraphdata
( "ACCT" , $from , $till , $grhost );
913 #If we want to show data from a date older than last two months, use ACCT_HIST
914 $sth =& ACCT
:: getmonthgraphdata
( "ACCT_HIST" , $from , $till , $grhost );
918 foreach my $i ( 0 ..$ #$_) {
919 push ( @
{ $values [ $i ]},( $_ ->[ $i ]));
923 for my $graph ( GD
:: Graph
:: area
-> new ( 600 , 200 ))
925 my $name = $cgiparams { 'host' };
930 accentclr
=> 'dblue' ,
931 valuesclr
=> '#ffff77' ,
933 axislabelcl
=> 'black' ,
937 dclrs
=> [ qw(lgreen lred) ],
938 x_label
=> $Lang :: tr
{ 'date' },
939 y_label
=> $Lang :: tr
{ 'acct mb' },
942 #x_label_skip => 3, #skip every 3 x-axis title
943 x_label_position
=> 0 ,
947 $graph -> set_legend ( " $Lang ::tr{'acct traffic'}" );
948 $graph -> set ( x_labels_vertical
=> 1 , values_vertical
=> 1 );
949 my $gd = $graph -> plot ( \
@values );
950 open ( IMG
, '>/srv/web/ipfire/html/accounting/tmpgraph.png' ) or die $!;
954 #Show Box with monthly graph for this host
955 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'acct traffic monthly' });
956 print "<center><img src='/accounting/tmpgraph.png' alt=' $grhost '></center>" ;
957 print "<b> $cgiparams {'traffic'}</b>" ;
960 <table style='width:100%;'>
962 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
963 <td align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'back'}'></td>
970 sub generatehourgraph
{
974 my ( $from , $till ) = & ACCT
:: getmonth
( $grmon , $gryear );
978 #If we want to show Data from within last 2 months, get DATA from ACCT
979 if ( ! $grmon < ( $mon + 1 ) && $gryear == ( $year + 1900 )){
980 $sth =& ACCT
:: getgraphdata
( "ACCT" , $from , $till , $grhost );
982 #If we want to show data from a date older than last two months, use ACCT_HIST
983 $sth =& ACCT
:: getgraphdata
( "ACCT_HIST" , $from , $till , $grhost );
987 foreach my $i ( 0 ..$ #$_) {
990 push ( @
{ $values [ $i ]},( $_ ->[ $i ] /1024/ 1024 ));
992 push ( @
{ $values [ $i ]}, $_ ->[ $i ]);
999 for my $graph ( GD
:: Graph
:: area
-> new ( 600 , 200 ))
1001 my $name = $cgiparams { 'host' };
1002 print STDERR
"Processing $name mit sosse \n " ;
1005 x_label
=> 'X Label' ,
1006 y_label
=> 'Y label' ,
1007 title
=> 'An Area Graph' ,
1009 #y_tick_number => 8,
1011 #accent_treshold => 41,
1015 $graph -> set_legend ( 'one' , 'two' );
1016 my $gd = $graph -> plot ( \
@values );
1017 open ( IMG
, '>/srv/web/ipfire/html/test/file.png' ) or die $!;
1022 print "<img src='/test/file.png' alt='Tanzmaus'>" ;
1029 if ( $proxsrv eq $Lang :: tr
{ 'stopped' }){
1030 $bgcolor1 = "bgcolor='${Header::colourred}' align='center'" ;
1031 $message = "<br> $Lang ::tr{'acct proxy_enable'}" ;
1033 $bgcolor1 = "bgcolor='${Header::colourgreen}' align='center'" ;
1035 if ( $proxlog eq $Lang :: tr
{ 'stopped' }){
1036 $bgcolor2 = "bgcolor='${Header::colourred}' align='center'" ;
1037 $message = $message . "<br> $Lang ::tr{'acct proxylog_enable'}" ;
1039 $bgcolor2 = "bgcolor='${Header::colourgreen}' align='center'" ;
1041 & Header
:: openbox
( '100%' , 'left' , );
1043 <center><table width='50%' class='tbl'>
1045 <th> $Lang ::tr{'service'}</th>
1046 <th> $Lang ::tr{'status'}</th>
1049 <td bgcolor=' $color {'color22'}'> $Lang ::tr{'proxy'}</td>
1050 <td $bgcolor1 ><font color='white'> $proxsrv </td>
1053 <td bgcolor=' $color {'color20'}'> $Lang ::tr{'logging'}</td>
1054 <td $bgcolor2 ><font color='white'> $proxlog </td>
1058 print "<tr><td colspan='2'><font color='red'> $message <br> $Lang ::tr{'acct nodata'}</td></tr>" ;
1061 & Header
:: closebox
();
1066 #GIVES: Value (in MB,GB,TB) With Type ("MB","GB","TB")
1069 if (( $val / 1024 ) < 1024 ){
1071 $val = sprintf "%.2f" , $val / 1024 ;
1072 $type = $Lang :: tr
{ 'acct kb' };
1073 } elsif (( $val /( 1024 * 1024 )) < 1024 ){
1075 $val = sprintf "%.2f" , $val /( 1024 * 1024 );
1076 $type = $Lang :: tr
{ 'acct mb' };
1077 } elsif (( $val /( 1024 * 1024 * 1024 )) < 1024 ){
1079 $val = sprintf "%.2f" , $val /( 1024 * 1024 * 1024 );
1080 $type = $Lang :: tr
{ 'acct gb' };
1081 } elsif (( $val /( 1024 * 1024 * 1024 * 1024 )) < 1024 ){
1083 $val = sprintf "%.2f" , $val /( 1024 * 1024 * 1024 * 1024 );
1084 $type = $Lang :: tr
{ 'acct tb' };
1086 return ( $val , $type );
1090 #This function shows the site "address management"
1091 & Header
:: openpage
( " $Lang ::tr{'acct addresses'}" , 1 , '' );
1092 & Header
:: openbigbox
( '100%' , 'center' );
1097 #Get all Addresses from DB
1098 my $res = & ACCT
:: getaddresses
;
1100 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'acct edit_addr' } );
1102 #When no address preselected, set COMPANYTYPE to "CUST"
1103 if ( $cgiparams { 'rdo_companytype' } eq '' ){
1104 $cgiparams { 'rdo_companytype' } = 'CUST' ;
1106 $checked { 'rdo_companytype' }{ $cgiparams { 'rdo_companytype' }} = 'CHECKED' ;
1110 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1111 <table style=width:100%;'>
1113 <td style='width:8em;'></td>
1115 <td colspan='2'><font size="1"> $Lang ::tr{'acct hint_hoster'}:</font></td>
1118 <td> $Lang ::tr{'acct companytype'}</td>
1120 <input type='radio' name='rdo_companytype' value='CUST' $checked {'rdo_companytype'}{'CUST'}> $Lang ::tr{'acct customer'}
1121 <input type='radio' name='rdo_companytype' value='HOST' $checked {'rdo_companytype'}{'HOST'}> $Lang ::tr{'acct hoster'}</td>
1122 <td style='width:8em;'> $Lang ::tr{'acct bank'}</td>
1124 <input type='text' name='txt_bank' value=' $cgiparams {'txt_bank'}' style='width:25em;'></td>
1127 <td> $Lang ::tr{'acct company'}</td>
1129 <input type='text' name='txt_company' value=' $cgiparams {'txt_company'}' style='width:25em;'></td>
1130 <td> $Lang ::tr{'acct iban'}<img src='/blob.gif' alt='*' /></td>
1132 <input type='text' name='txt_iban' value=' $cgiparams {'txt_iban'}' style='width:25em;'></td>
1135 <td> $Lang ::tr{'acct name1'}<img src='/blob.gif' alt='*' /></td>
1137 <input type='text' name='txt_name1' value=' $cgiparams {'txt_name1'}' style='width:25em;'></td>
1138 <td> $Lang ::tr{'acct bic'}<img src='/blob.gif' alt='*' /></td>
1140 <input type='text' name='txt_bic' maxlength='8' value=' $cgiparams {'txt_bic'}' style='width:25em;'></td>
1143 <td> $Lang ::tr{'acct str'}</td>
1145 <input type='text' name='txt_str' value=' $cgiparams {'txt_str'}' style='width:25em;'></td>
1146 <td> $Lang ::tr{'acct blz'}</td>
1148 <input type='text' name='txt_blz' maxlength='8' value=' $cgiparams {'txt_blz'}' style='width:25em;'></td>
1151 <td> $Lang ::tr{'acct str_nr'}</td>
1152 <td><input type='text' name='txt_str_nr' value=' $cgiparams {'txt_str_nr'}' style='width:25em;'></td>
1153 <td> $Lang ::tr{'acct kto'}</td>
1155 <input type='text' name='txt_kto' value=' $cgiparams {'txt_kto'}' style='width:25em;'></td>
1160 <td> $Lang ::tr{'acct plz'}</td>
1162 <input type='text' name='txt_plz' value=' $cgiparams {'txt_plz'}' style='width:25em;'></td>
1163 <td> $Lang ::tr{'acct email'}</td>
1164 <td><input type='text' name='txt_email' value=' $cgiparams {'txt_email'}' style='width:25em;'></td>
1167 <td> $Lang ::tr{'acct city'}</td>
1168 <td><input type='text' name='txt_city' value=' $cgiparams {'txt_city'}' style='width:25em;'></td>
1169 <td> $Lang ::tr{'acct inet'}<img src='/blob.gif' alt='*' /></td>
1171 <input type='text' name='txt_inet' value=' $cgiparams {'txt_inet'}' style='width:25em;'></td>
1176 <td> $Lang ::tr{'acct hrb'}<img src='/blob.gif' alt='*' /></td>
1178 <input type='text' name='txt_hrb' value=' $cgiparams {'txt_hrb'}' style='width:25em;'></td>
1183 <td> $Lang ::tr{'acct ustid'}</td>
1184 <td><input type='text' name='txt_ustid' value=' $cgiparams {'txt_ustid'}' style='width:25em;'></td>
1189 <td> $Lang ::tr{'acct tel'}<img src='/blob.gif' alt='*' /></td>
1191 <input type='text' name='txt_tel' value=' $cgiparams {'txt_tel'}' style='width:25em;'></td>
1196 <td> $Lang ::tr{'acct fax'}<img src='/blob.gif' alt='*' /></td>
1198 <input type='text' name='txt_fax' value=' $cgiparams {'txt_fax'}' style='width:25em;'></td>
1201 <td colspan='6'><img src='/blob.gif' alt='*' /><font size="1"> $Lang ::tr{'acct optional'}</font></td>
1205 if ( $cgiparams { 'update' } eq 'on' ){
1206 print "<input type='hidden' name='oldcompname' value=' $cgiparams {'oldcompname'}'>" ;
1207 print "<td colspan='6' align='right' display:inline><input type='submit' name='ACTION' value=' $Lang ::tr{'update'}'></td>" ;
1209 print "<td colspan='6' align='right' display:inline><input type='submit' name='ACTION1' value=' $Lang ::tr{'save'}'></td>" ;
1211 print "</tr></table></form>" ;
1212 & Header
:: closebox
();
1215 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1216 <table style='width:100%;'>
1218 <td align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'back'}'></td>
1223 #Check if we need to show HOSTBOX and/or CUSTBOX
1224 foreach my $row ( @
$res ) {
1225 my ( $gr , $comp , $type , $name1 , $str , $nr , $plz , $city , $bank , $iban , $bic , $blz , $kto , $email , $inet , $hrb , $ustid , $tel , $fax ) = @
$row ;
1226 if ( $type eq 'HOST' ){
1229 if ( $type eq 'CUST' ){
1233 #Show HOSTER Addresses if any
1237 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'acct exst_host_addr' } );
1239 print "<table style='width:100%'>" ;
1240 foreach my $row ( @
$res ) {
1241 #SET colors for tablerows
1242 $col = "style='background-color: $color {'color22'}'" ;
1243 $col1 = "style='background-color:#e2d8d8'" ;
1244 my ( $gr , $comp , $type , $name1 , $str , $nr , $plz , $city , $bank , $iban , $bic , $blz , $kto , $email , $inet , $hrb , $ustid , $tel , $fax ) = @
$row ;
1245 if ( $cgiparams { 'oldcompname' } eq $comp ){
1246 $col = "style='background-color:yellow'" ;
1247 $col1 = "style='background-color:yellow'" ;
1249 if ( $type eq 'HOST' ){
1252 print "<tr><td width='50%' valign='top' align='center'>" ;
1254 print "</td><td width='50%' valign='top' align='center'>" ;
1257 <table style='width:90%;' cellspacing='0' class='tbl'>
1259 <th align='left' width='50%'> $Lang ::tr{'acct company'}</th>
1260 <th align='left' width='10%' > $Lang ::tr{'acct bank'}</th>
1261 <th width='38%' ></th>
1262 <th align='right' width='1%' style="PADDING: 0px">
1263 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1264 <input type='image' src='/images/edit.gif' alt= $Lang ::tr{'acct edit'} title=' $Lang ::tr{'acct edit'}' />
1265 <input type='hidden' name='ACTION' value='edit_addr'>
1266 <input type='hidden' name='rdo_companytype' value=' $type '>
1267 <input type='hidden' name='txt_company' value=' $comp '>
1268 <input type='hidden' name='txt_name1' value=' $name1 '>
1269 <input type='hidden' name='txt_str' value=' $str '>
1270 <input type='hidden' name='txt_str_nr' value=' $nr '>
1271 <input type='hidden' name='txt_plz' value=' $plz '>
1272 <input type='hidden' name='txt_city' value=' $city '>
1273 <input type='hidden' name='txt_bank' value=' $bank '>
1274 <input type='hidden' name='txt_iban' value=' $iban '>
1275 <input type='hidden' name='txt_bic' value=' $bic '>
1276 <input type='hidden' name='txt_blz' value=' $blz '>
1277 <input type='hidden' name='txt_kto' value=' $kto '>
1278 <input type='hidden' name='txt_email' value=' $email '>
1279 <input type='hidden' name='txt_inet' value=' $inet '>
1280 <input type='hidden' name='txt_hrb' value=' $hrb '>
1281 <input type='hidden' name='txt_ustid' value=' $ustid '>
1282 <input type='hidden' name='txt_tel' value=' $tel '>
1283 <input type='hidden' name='txt_fax' value=' $fax '>
1285 <th width='1%' style="PADDING: 0px">
1286 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1287 <input type='image' src='/images/delete.gif' alt= $Lang ::tr{'acct deladr'} title= $Lang ::tr{'acct deladr'} />
1288 <input type='hidden' name='txt_company' value=' $comp '>
1289 <input type='hidden' name='ACTION' value='del_addr'>
1294 <td $col ><b> $comp </b></td>
1296 <td colspan='3' $col1 ></td>
1299 <td $col > $name1 </td>
1300 <td $col1 width='35%'> $Lang ::tr{'acct bank'}</td>
1301 <td colspan='3' $col1 > $bank </td>
1305 <td $col1 > $Lang ::tr{'acct iban'}</td>
1306 <td colspan='3' $col1 > $iban </td>
1309 <td $col > $str $nr </td>
1310 <td $col1 > $Lang ::tr{'acct bic'}</td>
1311 <td colspan='3' $col1 > $bic </td>
1314 <td $col > $plz $city </td>
1315 <td $col1 > $Lang ::tr{'acct blz'}</td>
1316 <td colspan='3' $col1 > $blz </td>
1320 <td $col1 > $Lang ::tr{'acct kto'}</td>
1321 <td colspan='3' $col1 > $kto </td>
1333 print "<td width='50%' valign='top' align='center'></td></tr>" ;
1336 & Header
:: closebox
();
1338 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'acct exst_host_addr' } );
1339 print $Lang :: tr
{ 'acct host empty' };
1340 & Header
:: closebox
();
1342 #Show CUSTOMER Addresses if any
1345 #EXISTING CUSTOMER BOX
1346 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'acct exst_cust_addr' } );
1347 print "<table style='width:100%;'><tr>" ;
1348 foreach my $row ( @
$res ) {
1349 #SET colors for tablerows
1350 $col = "style='background-color: $color {'color22'}'" ;
1351 my ( $gr , $comp , $type , $name1 , $str , $nr , $plz , $city , $bank , $iban , $bic , $blz , $kto , $email , $inet , $hrb , $ustid , $tel , $fax ) = @
$row ;
1352 if ( $cgiparams { 'oldcompname' } eq $comp ){
1353 $col = "style='background-color:yellow'" ;
1355 if ( $type eq 'CUST' ){
1357 print "<td width='15%' valign='top' align='center'>" ;
1360 <table style='width:90%;' cellspacing='0' class='tbl'>
1363 $Lang ::tr{'acct company'}
1365 <th width='1%' style="PADDING: 0px">
1366 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1367 <input type='image' src='/images/edit.gif' alt=' $Lang ::tr{'acct edit'}' title=' $Lang ::tr{'acct edit'}' />
1368 <input type='hidden' name='ACTION' value='edit_addr'>
1369 <input type='hidden' name='rdo_companytype' value=' $type '>
1370 <input type='hidden' name='txt_company' value=' $comp '>
1371 <input type='hidden' name='txt_name1' value=' $name1 '>
1372 <input type='hidden' name='txt_str' value=' $str '>
1373 <input type='hidden' name='txt_str_nr' value=' $nr '>
1374 <input type='hidden' name='txt_plz' value=' $plz '>
1375 <input type='hidden' name='txt_city' value=' $city '>
1376 <input type='hidden' name='txt_bank' value=' $bank '>
1377 <input type='hidden' name='txt_iban' value=' $iban '>
1378 <input type='hidden' name='txt_bic' value=' $bic '>
1379 <input type='hidden' name='txt_blz' value=' $blz '>
1380 <input type='hidden' name='txt_kto' value=' $kto '>
1381 <input type='hidden' name='txt_email' value=' $email '>
1382 <input type='hidden' name='txt_inet' value=' $inet '>
1383 <input type='hidden' name='txt_hrb' value=' $hrb '>
1384 <input type='hidden' name='txt_ustid' value=' $ustid '>
1385 <input type='hidden' name='txt_tel' value=' $tel '>
1386 <input type='hidden' name='txt_fax' value=' $fax '>
1389 <th width='1%' style="padding: 0px">
1390 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1391 <input type='image' src='/images/delete.gif' alt= $Lang ::tr{'acct deladr'} title= $Lang ::tr{'acct deladr'} />
1392 <input type='hidden' name='ACTION' value='del_addr' />
1393 <input type='hidden' name='txt_company' value=' $comp ' />
1398 <td colspan='3' $col ><b> $comp </b></td>
1401 <td colspan='3' $col > $name1 </td>
1404 <td colspan='3' $col > $str $nr </td>
1407 <td colspan='3' $col > $plz $city </td>
1413 if (! ( $count % 3 )) {
1420 print "<td width='15%' valign='top' align='center'></td></tr>" ;
1423 & Header
:: closebox
();
1425 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'acct exst_cust_addr' } );
1426 print $Lang :: tr
{ 'acct cust empty' };
1427 & Header
:: closebox
();
1429 & Header
:: closebigbox
();
1430 & Header
:: closepage
();
1436 my $fieldvalue = $_ [ 1 ];
1437 my $errormessage = $_ [ 2 ];
1439 if (!& validtextfield
( $fieldvalue )){
1441 $errormessage .= " $Lang ::tr{'acct empty field'} $field <br>" ;
1443 $errormessage .= " $Lang ::tr{'acct invalid'} $field <br>" ;
1446 return $errormessage ;
1450 #Check if an address with the same name alread exists
1451 if ( $cgiparams { 'update' } ne 'on' ){
1452 my $res =& ACCT
:: getaddresses
;
1453 foreach my $row ( @
$res ) {
1454 my ( $anz , $name )= @
$row ;
1455 if ( $name eq $cgiparams { 'txt_company' }){
1456 $errormessage .= $Lang :: tr
{ 'acct companyexists' };
1461 $errormessage =& checkfield
( $Lang :: tr
{ 'acct company' }, $cgiparams { 'txt_company' }, $errormessage );
1464 if ( $cgiparams { 'txt_name1' }){
1465 $errormessage =& checkfield
( $Lang :: tr
{ 'acct name1' }, $cgiparams { 'txt_name1' }, $errormessage );
1469 if ( $cgiparams { 'txt_name2' }){
1470 $errormessage =& checkfield
( $Lang :: tr
{ 'acct name2' }, $cgiparams { 'txt_name2' }, $errormessage );
1474 $errormessage =& checkfield
( $Lang :: tr
{ 'acct str' }, $cgiparams { 'txt_str' }, $errormessage );
1477 if (! $cgiparams { 'txt_str_nr' }){
1478 $errormessage .= " $Lang ::tr{'acct empty field'} $Lang ::tr{'acct str_nr'}<br>" ;
1480 if (! & validalphanumfield
( $cgiparams { 'txt_str_nr' })){
1481 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct str_nr'}<br>" ;
1486 if (! $cgiparams { 'txt_plz' }){
1487 $errormessage .= " $Lang ::tr{'acct empty field'} $Lang ::tr{'acct plz'}<br>" ;
1489 if (! & validnumfield
( $cgiparams { 'txt_plz' })){
1490 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct plz'}<br>" ;
1495 $errormessage =& checkfield
( $Lang :: tr
{ 'acct city' }, $cgiparams { 'txt_city' }, $errormessage );
1498 if (! $cgiparams { 'txt_email' }){
1499 $errormessage .= " $Lang ::tr{'acct empty field'} $Lang ::tr{'acct email'}<br>" ;
1501 if (! & General
:: validemail
( $cgiparams { 'txt_email' })){
1502 $errormessage .= "<br> $Lang ::tr{'acct invalid'} $Lang ::tr{'acct email'}" ;
1506 #Check all fields required for companytype "HOST"
1507 if ( $cgiparams { 'rdo_companytype' } eq 'HOST' ){
1509 $errormessage =& checkfield
( $Lang :: tr
{ 'acct bank' }, $cgiparams { 'txt_bank' }, $errormessage );
1511 #Check IBAN - optional
1512 if ( $cgiparams { 'txt_iban' }){
1513 if (!& validalphanumfield
( $cgiparams { 'txt_iban' })){
1514 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct iban'}<br>" ;
1517 if ( $cgiparams { 'txt_bic' }){
1518 if (!& validalphanumfield
( $cgiparams { 'txt_bic' })){
1519 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct bic'}<br>" ;
1522 if (( $cgiparams { 'txt_iban' } && $cgiparams { 'txt_blz' })||(! $cgiparams { 'txt_iban' } && $cgiparams { 'txt_blz' })){
1524 if (! & validnumfield
( $cgiparams { 'txt_blz' })){
1525 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct blz'}<br>" ;
1528 if ( $cgiparams { 'txt_kto' }){
1529 if (! & validnumfield
( $cgiparams { 'txt_kto' })){
1530 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct kto'}<br>" ;
1532 } elsif (! $cgiparams { 'txt_kto' }){
1533 $errormessage .= " $Lang ::tr{'acct empty field'} $Lang ::tr{'acct kto'}<br>" ;
1535 } elsif (! $cgiparams { 'txt_iban' } && ! $cgiparams { 'txt_blz' }){
1536 $errormessage .= " $Lang ::tr{'acct empty field'} $Lang ::tr{'acct blz'}<br>" ;
1538 if ( $cgiparams { 'txt_kto' }){
1539 if (! & validnumfield
( $cgiparams { 'txt_kto' })){
1540 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct kto'}<br>" ;
1542 } elsif (! $cgiparams { 'txt_kto' }){
1543 $errormessage .= " $Lang ::tr{'acct empty field'} $Lang ::tr{'acct kto'}<br>" ;
1548 if ( $cgiparams { 'txt_inet' }){
1549 if ( $cgiparams { 'txt_inet' } =~ m/([a-z]+:\/ \
/)??([a-z0-9\-]+\.){1}(([a-z0-9\-]+\.){0,})([a-z0-9\-]+){1}/o ) {
1550 $cgiparams { 'txt_inet' }= $2 . $3 . $5 ;
1552 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct inet'}<br>" ;
1556 if ( $cgiparams { 'txt_hrb' }){
1557 $errormessage =& checkfield
( $Lang :: tr
{ 'acct hrb' }, $cgiparams { 'txt_hrb' }, $errormessage );
1563 if ( $cgiparams { 'txt_tel' }){
1564 if (!& validphonefield
( $cgiparams { 'txt_tel' })){
1565 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct tel'}<br>" ;
1569 return $errormessage ;
1573 if (- f
"${General::swroot}/proxy/enable" ){
1574 $proxsrv = $Lang :: tr
{ 'running' };
1576 $proxsrv = $Lang :: tr
{ 'stopped' };
1578 my $srce = "${General::swroot}/proxy/squid.conf" ;
1579 my $string1 = 'access\.log' ;
1581 while ( my $line = < FH
>) {
1582 if ( $line =~ m/$string1/ ) {
1583 $proxlog = $Lang :: tr
{ 'running' };
1591 #GET: Input from a Textfield
1592 #GIVES: True if valid, false if not valid
1595 # Each part should be at least two characters in length
1596 # but no more than 63 characters
1597 if ( length ( $remark ) < 1 || length ( $remark ) > 255 ) {
1599 # Only valid characters are a-z, A-Z, 0-9 and -
1600 if ( $remark !~ /^[a-zĆ¤Ć¶Ć¼A-ZĆĆĆ0-9-.:;\&\|\Ć_()\/ \s
]*$/) {
1602 # First character can only be a letter or a digit
1603 if ( substr ( $remark , 0 , 1 ) !~ /^[a-zĆ¤Ć¶Ć¼A-ZĆĆĆ0-9(]*$/ ) {
1605 # Last character can only be a letter or a digit
1606 if ( substr ( $remark , - 1 , 1 ) !~ /^[a-zĆ¶Ć¤Ć¼A-ZĆĆĆ0-9.:;_)]*$/ ) {
1612 #GET: Input from a numeric field
1613 #GIVES: True if valid, false if not valid
1616 # Each part should be at least two characters in length
1617 # but no more than 63 characters
1618 if ( length ( $num ) < 1 || length ( $num ) > 255 ) {
1620 # Only valid characters are a-z, A-Z, 0-9 and -
1621 if ( $num !~ /^[0-9.]*$/ ) {
1623 # First character can only be a letter or a digit
1624 if ( substr ( $num , 0 , 1 ) !~ /^[0-9]*$/ ) {
1626 # Last character can only be a letter or a digit
1627 if ( substr ( $num , - 1 , 1 ) !~ /^[0-9]*$/ ) {
1632 sub validphonefield
{
1633 #GET: Input from a numeric field
1634 #GIVES: True if valid, false if not valid
1637 # Each part should be at least two characters in length
1638 # but no more than 63 characters
1639 if ( length ( $num ) < 1 || length ( $num ) > 255 ) {
1641 # Only valid characters are a-z, A-Z, 0-9 and -
1642 if ( $num !~ /^[0-9-()\+ ]*$/ ) {
1644 # First character can only be a letter or a digit
1645 if ( substr ( $num , 0 , 1 ) !~ /^[0-9(\+]*$/ ) {
1647 # Last character can only be a digit
1648 if ( substr ( $num , - 1 , 1 ) !~ /^[0-9]*$/ ) {
1653 sub validalphanumfield
{
1654 #GET: Input from a numeric field
1655 #GIVES: True if valid, false if not valid
1658 # Each part should be at least two characters in length
1659 # but no more than 63 characters
1660 if ( length ( $remark ) < 1 || length ( $remark ) > 255 ) {
1662 # Only valid characters are a-z, A-Z, 0-9 and -
1663 if ( $remark !~ /^[0-9a-zA-Z]*$/ ) {
1665 # First character can only be a letter or a digit
1666 if ( substr ( $remark , 0 , 1 ) !~ /^[0-9A-Za-z]*$/ ) {
1668 # Last character can only be a letter or a digit
1669 if ( substr ( $remark , - 1 , 1 ) !~ /^[0-9a-zA-Z]*$/ ) {
1675 if ( $errormessage ) {
1676 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
1677 print "<class name='base'> $errormessage \n " ;
1678 print " </class> \n " ;
1679 & Header
:: closebox
();
1684 & Header
:: openpage
( " $Lang ::tr{'acct billgroup'}" , 1 , '' );
1685 & Header
:: openbigbox
( '100%' , 'center' );
1693 #Get addresses from DB
1694 my $res = & ACCT
:: getaddresses
;
1695 #Check if we need to show NEW-BillGROUP-BOX or Hint
1696 foreach my $row ( @
$res ) {
1697 my ( $gr , $comp , $type , $name1 , $str , $nr , $plz , $city , $bank , $iban , $bic , $blz , $kto , $email , $inet , $hrb , $ust , $tel , $fax , $ccmail ) = @
$row ;
1700 $ccmailrcpt = $ccmail ;
1701 if ( $type eq 'HOST' ){
1704 if ( $type eq 'CUST' ){
1708 if ( $host && $cust ){
1710 if (! $cgiparams { 'txt_ccmail' }){
1711 $cgiparams { 'txt_ccmail' }= $ccmailrcpt ;
1713 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'acct edit_addr'}" );
1715 <form method='post' action=' $ENV {'SCRIPT_NAME'}' ENCTYPE='multipart/form-data'>
1716 <table style='width:100%;'>
1718 <td style='width: 22em;'> $Lang ::tr{'name'}</td>
1719 <td><input type='text' name='txt_billgroup' value=' $cgiparams {'txt_billgroup'}' style='width: 24em;'></td>
1725 <td valign='top'> $Lang ::tr{'acct billtext1'}<img src='/blob.gif' alt='*' /></td>
1726 <td><textarea name='txt_billtext1' cols='40' rows='5' style='width: 24em;' maxlength='300'> $cgiparams {'txt_billtext1'}</textarea></td>
1728 <tr><td><br></td></tr>
1730 #Print Dropdown Menu for HOSTER and CUSTOMER
1731 print "<tr><td> $Lang ::tr{'acct hoster'}</td><td><select name='dd_host' style='width: 24.3em;'>" ;
1732 foreach my $row ( @
$res ) {
1733 my ( $gr , $comp , $type ) = @
$row ;
1734 if ( $type eq 'HOST' ){
1735 if ( $cgiparams { 'dd_host' } eq $comp ){
1736 print "<option selected> $comp </option>" ;
1738 print "<option> $comp </option>" ;
1742 print "</select></td></tr><tr><td><br></td></tr>" ;
1743 print "<tr><td> $Lang ::tr{'acct customer'}</td><td><select name='dd_cust' style='width: 24.3em;'>" ;
1744 foreach my $row ( @
$res ) {
1745 my ( $gr , $comp , $type ) = @
$row ;
1746 if ( $type eq 'CUST' ){
1747 if ( $cgiparams { 'dd_cust' } eq $comp ){
1748 print "<option selected> $comp </option>" ;
1750 print "<option> $comp </option>" ;
1754 print "</select></td></tr>" ;
1755 print "<tr><td><br></td></tr>" ;
1756 #Print multiselectbox for hosts/users which should be part of this group
1757 my $hosts =& ACCT
:: gethosts
;
1758 print "<tr><td valign='top'> $Lang ::tr{'acct members'}</td><td><select name='sel_hosts' multiple size='8' style='width: 24em;' >" ;
1759 #If update, split $cgiparams{'sel_hosts'} and preselect values from selectbox
1760 if ( $cgiparams { 'update' } eq 'on' ){
1761 $cgiparams { 'oldname' }= $cgiparams { 'txt_billgroup' };
1762 @oldhosts = split ( /\|/ , $cgiparams { 'sel_hosts' });
1764 foreach my $row ( @
$hosts ) {
1767 foreach my $old ( @oldhosts ){
1773 print "<option selected> $val </option>" ;
1775 print "<option> $val </option>" ;
1778 print "</select></td></tr>" ;
1779 print "<tr><td><br></td></tr>" ;
1780 #set right decimal seperator for cent value
1781 setlocale
( LC_NUMERIC
, " $mainsettings {'LANGUAGE'}_ $uplang " );
1782 my $val = sprintf "%.3f" , $cgiparams { 'txt_cent' };
1783 print "<tr><td> $Lang ::tr{'acct cent'}</td><td><input type='text' name='txt_cent' value=' $val ' size='3'> $settings {'CURRENCY'} </td></tr>" ;
1785 print "<tr><td colspan='2' align='left'><img src='/blob.gif' alt='*' /><font size='1'> $Lang ::tr{'acct optional'}</font></td></tr>" ;
1786 print "<tr><td colspan='2' align='right'><br><br>" ;
1787 print "</td></tr></table>" ;
1789 #LOGO Upload if update eq 'on'
1790 if ( $cgiparams { 'update' } eq 'on' ){
1792 <table style='width:100%;'>
1794 <td style='width: 22em;'> $Lang ::tr{'acct logo upload'}</td>
1795 <td><INPUT TYPE="file" NAME="uploaded_file" SIZE=30 MAXLENGTH=80></td>
1796 <input type='hidden' name='logo_grp' value=' $cgiparams {'txt_billgroup'}' />
1799 <td><br> $Lang ::tr{'acct logo'}</td>
1801 #Show Logo in webinterface with 1/2 size if set
1802 if (- f
" $logopath / $cgiparams {'txt_billgroup'}/logo.png" ){
1803 print "<td><img src='/accounting/logo/ $cgiparams {'txt_billgroup'}/logo.png' alt=' $logopath / $cgiparams {'txt_billgroup'}/logo.png' width='25%' height='25%' /></td></tr>" ;
1805 print "<td><br> $Lang ::tr{'no'}</td></tr>" ;
1807 #Show optional CC Mailadresses
1810 <td><br> $Lang ::tr{'acct mailrcpt'}</td>
1811 <td><br> $mailrcpt </td>
1814 <td><br> $Lang ::tr{'acct ccmail'}</td>
1815 <td><br><input type='text' name='txt_ccmail' value=' $cgiparams {'txt_ccmail'}' style='width: 24.3em;'></td>
1823 print "<table style='width:100%;'><tr><td align='right'>" ;
1824 #Print SAVE or EDIT Button
1825 if ( $cgiparams { 'update' } eq 'on' ){
1826 print "<input type='submit' name='BILLACTION' value=' $Lang ::tr{'update'}'>" ;
1827 print "<input type='hidden' name='oldname' value=' $cgiparams {'oldname'}'>" ;
1828 print "<input type='hidden' name='oldccmail' value=' $ccmailrcpt '>" ;
1830 print "<input type='submit' name='BILLACTION' value=' $Lang ::tr{'save'}'>" ;
1832 print "</td></tr></table><br></form><br>" ;
1833 & Header
:: closebox
();
1836 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1837 <table style='width:100%;'>
1840 <input type='submit' name='ACTION' value=' $Lang ::tr{'back'}'>
1846 #Show Box for fixed positions if update
1847 if ( $cgiparams { 'update' } eq 'on' ){
1848 & viewtablebillpos
( $cgiparams { 'txt_billgroup' });
1851 & viewtablebillgroups
;
1855 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'hint'}" );
1856 print " $Lang ::tr{'acct hint billgrp'}" ;
1857 & Header
:: closebox
();
1860 <table style='width:100%;'>
1862 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1863 <td align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'back'}'></td>
1869 & Header
:: closebigbox
();
1870 & Header
:: closepage
();
1874 sub viewtablebillgroups
{
1876 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'acct billgroup'}" );
1877 #Get DATA from table BILLINGGRP
1878 my $res = & ACCT
:: getbillgroups
;
1880 #Print table billinggroup
1882 <table style='width:100%;' cellspacing='0' class='tbl'>
1884 <th align='left'> $Lang ::tr{'name'}</th>
1885 <th align='left'> $Lang ::tr{'acct hoster'}</th>
1886 <th align='left'> $Lang ::tr{'acct customer'}</th>
1887 <th align='left'> $Lang ::tr{'acct members'}</th>
1888 <th align='left' colspan='5'></th>
1891 foreach my $line ( @
$res ){
1894 $col = "style='background-color: $color {'color22'}'" ;
1896 $col = "style='background-color: $color {'color20'}'" ;
1898 my ( $name , $host , $cust , $txt , $amount , $cent ) = @
$line ;
1904 <td $col > $amount </td>
1905 <td width='1%' $col >
1907 my $members =& ACCT
:: listhosts
( $name );
1908 my @mem = split ( /\|/ , $members );
1910 foreach my $m ( @mem ){
1913 print "<img src='/images/computer.png' alt= $Lang ::tr{'acct members'} title='" . $msg . "' /></td>" ;
1916 <td width='1%' $col >
1917 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1918 <input type='image' src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' title=' $Lang ::tr{'edit'}' />
1919 <input type='hidden' name='BILLACTION' value='edit_billgroup'>
1920 <input type='hidden' name='txt_billgroup' value=' $name '>
1921 <input type='hidden' name='txt_billtext1' value=' $txt '>
1922 <input type='hidden' name='dd_host' value=' $host '>
1923 <input type='hidden' name='dd_cust' value=' $cust '>
1924 <input type='hidden' name='sel_hosts' value=' $members '>
1925 <input type='hidden' name='txt_cent' value=' $cent '>
1929 <td width='1%' $col >
1930 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1931 <input type='image' src='/images/folder-open.png' alt=' $Lang ::tr{'edit'}' title=' $Lang ::tr{'acct billarchive'}' />
1932 <input type='hidden' name='BILLACTION' value='open_billgroup'>
1933 <input type='hidden' name='txt_billgroup' value=' $name '>
1937 <td width='1%' $col >
1938 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1939 <input type='image' src='/images/document-new.png' alt=' $Lang ::tr{'acct preview'}' title=' $Lang ::tr{'acct preview'}' />
1940 <input type='hidden' name='BILLACTION' value='open_preview'>
1941 <input type='hidden' name='txt_billgroup' value=' $name '>
1944 <td width='1%' $col >
1945 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1946 <input type='image' src='/images/delete.gif' alt= $Lang ::tr{'delete'} title=" $Lang ::tr{'delete'}" />
1947 <input type='hidden' name='BILLACTION' value='delete_billgroup'>
1948 <input type='hidden' name='txt_billgroup' value=' $name '>
1956 & Header
:: closebox
();
1960 $dbh =& ACCT
:: connectdb
;
1961 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'acct hosts' });
1964 my ( $from , $till )=& ACCT
:: getmonth
( $mon , $year );
1966 #Menu to display another month
1968 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1969 <table style='width:100%;'>
1971 <td style='width:5%; text-align:center;'> $Lang ::tr{'acct month'}</td>
1972 <td style='width:10%; text-align: center;'> $Lang ::tr{'acct year'}</td>
1976 <td><select name='month'>
1978 for ( my $i = 1 ; $i < 13 ; $i ++){
1980 print "<option selected> $i </option>" ;
1982 print "<option> $i </option>" ;
1987 <td style='text-align: center;'><select name='year'>
1989 for ( my $j = 2014 ; $j <=( $year ); $j ++){
1991 print "<option selected> $j </option>" ;
1993 print "<option> $j </option>" ;
1998 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'acct view'}'></td>
2003 #View table with all hosts
2005 <table style='width:100%;' class='tbl'>
2007 <th> $Lang ::tr{'name'}</th>
2008 <th> $Lang ::tr{'acct traffic'}</th>
2009 <th> $Lang ::tr{'from'}</th>
2010 <th> $Lang ::tr{'to'}</th>
2014 my $res = $dbh -> selectall_arrayref ( "SELECT SUM(BYTES),min(TIME_RUN),max(TIME_RUN),NAME from ACCT where TIME_RUN between " . $from . " and " . $till . " group by NAME;" );
2019 foreach my $row ( @
$res ) {
2024 $col = "background-color: $color {'color22'};" ;
2026 $col = "background-color: $color {'color20'};" ;
2028 my ( $bytes , $mintime , $maxtime , $name ) = @
$row ;
2030 ( $lineval , $type ) = & calcbytes
( $bytes );
2032 print "<tr><td style=' $col '> $name </td><td style=' $col text-align: right;'> $lineval $type </td><td style=' $col text-align: center;'>" .& getdate
( $mintime ). "</td><td style=' $col text-align: center;'>" .& getdate
( $maxtime ). "</td>" ;
2035 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2036 <input type='image' src='/images/utilities-system-monitor.png' alt=" $Lang ::tr{'status'}" title=" $Lang ::tr{'status'}" />
2037 <input type='hidden' name='ACTION' value='viewgraph'>
2038 <input type='hidden' name='host' value=' $name '>
2039 <input type='hidden' name='month' value=' $mon '>
2040 <input type='hidden' name='year' value=' $year '>
2041 <input type='hidden' name='traffic' value=" $Lang ::tr{'acct sum'} $Lang ::tr{'acct traffic'} $lineval $type ">
2049 print "<tr><td colspan='5'><center> $Lang ::tr{'acct no data'}</td></tr>" ;
2052 & Header
:: closebox
();
2056 sub viewtablebillpos
{
2058 #BOX for extra billpositions
2059 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'acct fix billpos'} $grp " );
2060 #Table for optional billpositions
2062 <center><table style='width:65%' cellspacing='0' class='tbl' border='0'>
2064 <th align='left'> $Lang ::tr{'acct amount'}</th>
2065 <th align='left' style='padding-left:1.2em'> $Lang ::tr{'acct name'}</th>
2066 <th align='left'> $Lang ::tr{'acct price pp'}</th>
2070 #Fill Table for extra billpositions if any
2071 if ( $cgiparams { 'update' } eq 'on' ){
2072 my $res = & ACCT
:: getextrabillpos
( $cgiparams { 'txt_billgroup' });
2074 foreach my $line ( @
$res ){
2077 $col = "style='background-color: $color {'color22'}'" ;
2079 $col = "style='background-color: $color {'color20'}'" ;
2081 my ( $grp , $amnt , $pos , $price ) = @
$line ;
2082 setlocale
( LC_NUMERIC
, " $mainsettings {'LANGUAGE'}_ $uplang " );
2083 my $locale_price = sprintf "%.2f" , $price ;
2084 print "<tr><form method='post' action=' $ENV {'SCRIPT_NAME'}'><td $col style='padding-right:1.2em' align='right'> $amnt </td><td $col style='padding-left:1.2em'> $pos </td><td $col style='padding-right:1.2em' align='right'> $locale_price $settings {'CURRENCY'}</td>" ;
2085 print "<td $col ><input type='image' src='/images/delete.gif' alt= $Lang ::tr{'delete'} title= $Lang ::tr{'delete'} >" ;
2086 print "<input type='hidden' name='BILLPOS' value='delpos'>" ;
2087 print "<input type='hidden' name='txt_billgroup' value=' $grp '>" ;
2088 print "<input type='hidden' name='txt_billpos' value=' $pos '></form></tr>" ;
2094 <td ><form method='post' action=' $ENV {'SCRIPT_NAME'}'><input type='text' name='txt_amount' value=' $cgiparams {'txt_amount'}' size='3'></td>
2095 <td><input type='text' name='txt_name' value=' $cgiparams {'txt_name'}' size='40'></td>
2096 <td ><input type='text' name='txt_price' value=' $cgiparams {'txt_price'}' size='6'></td>
2100 <table style='width:100%'>
2102 <td align='right'><input type='submit' name='BILLPOS' value=' $Lang ::tr{'save'}'></td>
2103 <input type='hidden' name='txt_billgroup' value=' $grp '>
2109 & Header
:: closebox
();
2117 & Header
:: openpage
( $Lang :: tr
{ 'acct billoverview' }, 1 , '' );
2118 & Header
:: openbigbox
( '100%' , 'center' );
2119 & Header
:: openbox
( '100%' , 'left' , $grp );
2120 my $res =& ACCT
:: getbills
( $grp );
2124 <table style='width:100%' cellspacing='0' class='tbl' border='0'>
2126 <th> $Lang ::tr{'acct nr'}</th>
2127 <th> $Lang ::tr{'acct path'}</th>
2128 <th> $Lang ::tr{'name'}</th>
2129 <th> $Lang ::tr{'acct generated'}</th>
2134 foreach my $row ( @
$res ){
2137 $col = "style='background-color: $color {'color22'}'" ;
2139 $col = "style='background-color: $color {'color20'}'" ;
2141 my ( $no , $path , $name , $date , $dbgrp ) = @
$row ;
2143 print "<tr><td $col > $no </td><td $col > $path </td><td $col > $name </td><td $col > $date </td><td $col >" ;
2144 print "<form method='post' action=' $ENV {'SCRIPT_NAME'}'><input type='image' src='/images/updbooster/updxl-src-adobe.gif' alt=' $Lang ::tr{'edit'}' title=' $Lang ::tr{'edit'}' />" ;
2145 print "<input type='hidden' name='BILLVIEW' value='show'>" ;
2146 my $file = " $path / $name " ;
2147 print "<input type='hidden' name='file' value=' $file '>" ;
2148 print "<input type='hidden' name='name' value=' $name '>" ;
2149 print "</form></td></tr>" ;
2151 print "</table><br>" ;
2153 print "<center> $Lang ::tr{'acct no data'}" ;
2155 & Header
:: closebox
();
2159 <table style='width:100%'>
2161 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2162 <td align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'back'}'></td>
2167 & Header
:: closebigbox
();
2168 & Header
:: closepage
();
2172 sub checkmailsettings
{
2173 #Check if mailserver is an ip address or a domain
2174 if ( $cgiparams { 'txt_mailserver' } =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/ ){
2175 if (! & General
:: validip
( $cgiparams { 'txt_mailserver' })){
2176 $errormessage .= " $Lang ::tr{'acct invalid mailip'} $cgiparams {'txt_mailserver'}<br>" ;
2178 } elsif (! & General
:: validfqdn
( $cgiparams { 'txt_mailserver' })){
2179 $errormessage .= " $Lang ::tr{'acct invalid mailfqdn'} $cgiparams {'txt_mailserver'}<br>" ;
2181 #Check valid mailserverport
2182 if ( $cgiparams { 'txt_mailport' } < 1 || $cgiparams { 'txt_mailport' } > 65535 ){
2183 $errormessage .= " $Lang ::tr{'acct invalid mailport'} $cgiparams {'txt_mailport'}<br>" ;
2186 if (! $cgiparams { 'txt_mailsender' }){
2187 $errormessage .= " $Lang ::tr{'acct empty field'} $Lang ::tr{'acct mailsender'}<br>" ;
2189 if (! & General
:: validemail
( $cgiparams { 'txt_mailsender' })){
2190 $errormessage .= "<br> $Lang ::tr{'acct invalid'} $Lang ::tr{'acct mailsender'}<br>" ;
2193 return $errormessage ;