]>
git.ipfire.org Git - 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 & ACCT
:: pdf2
( \
@billar , $actmonth , $actyear , $mwst , $address_cust , $address_host , $billpos , $rggrp , $cur , "on" );
97 open ( DLFILE
, "</var/ipfire/accounting/bill/tmp.pdf" ) or die "Unable to open tmp.pdf: $!" ;
98 my @fileholder = < DLFILE
>;
99 print "Content-Type:application/pdf \n " ;
100 my @fileinfo = stat ( "/var/ipfire/accounting/bill/tmp.pdf" );
101 print "Content-Length: $fileinfo [7] \n " ;
102 print "Content-Disposition:attachment;filename='tmp.pdf'; \n\n " ;
107 & Header
:: showhttpheaders
();
109 if ( $cgiparams { 'ACTION' } eq " $Lang ::tr{'acct config'}" ){ #ConfigButton from Menu
112 if ( $cgiparams { 'ACTION' } eq " $Lang ::tr{'acct addresses'}" ){ #AddressmgmntButton from Menu
115 if ( $cgiparams { 'ACTION' } eq " $Lang ::tr{'acct billgroup'}" ){ #BillgroupButton from Menu
118 if ( $cgiparams { 'ACTION' } eq " $Lang ::tr{'acct maintenance'}" ){ #MaintenanceButton from Menu
121 if ( $cgiparams { 'ACTION' } eq " $Lang ::tr{'save'}" ){ #SaveButton on configsite
122 my @val = split ( ' \r\n ' , $cgiparams { 'txt_skipurls' });
124 foreach my $line ( @val ){
125 $skipurls .= "|" . $line ;
127 $skipurls = $skipurls . "|" ;
128 $skipurls =~ s/\|\|/\|/g ;
129 my @txt = split ( ' \r\n ' , $cgiparams { 'txt_mailtxt' });
131 foreach my $txt ( @txt ){
135 if ( $cgiparams { 'USEMAIL' } eq 'on' ){
136 $errormessage =& checkmailsettings
;
137 } elsif ( $cgiparams { 'USEMAIL' } ne 'on' ){
138 $cgiparams { 'txt_mailserver' }= '' ;
139 $cgiparams { 'txt_mailport' }= '' ;
140 $cgiparams { 'txt_mailuser' }= '' ;
141 $cgiparams { 'txt_mailpass' }= '' ;
142 $cgiparams { 'mail_tls' }= '' ;
143 $cgiparams { 'txt_mailsender' }= '' ;
144 $cgiparams { 'txt_mailsubject' }= '' ;
148 open ( TXT
, "> $settingsfile " ) or die ( "Die Datei konnte nicht geƶffnet werden: $! \n " );
150 $settings { 'LOG' } = $cgiparams { 'logging' };
151 $settings { 'EXPERT' } = $cgiparams { 'expert' };
152 $settings { 'MULTIUSER' } = $cgiparams { 'multiuser' };
153 $settings { 'MWST' } = $cgiparams { 'txt_mwst' };
154 $settings { 'CURRENCY' } = $cgiparams { 'txt_currency' };
155 $settings { 'SKIPURLS' } = $skipurls ;
156 $settings { 'USEMAIL' } = $cgiparams { 'USEMAIL' };
157 $settings { 'MAILSRV' } = $cgiparams { 'txt_mailserver' };
158 $settings { 'MAILPORT' } = $cgiparams { 'txt_mailport' };
159 $settings { 'MAILUSER' } = $cgiparams { 'txt_mailuser' };
160 $settings { 'MAILPASS' } = $cgiparams { 'txt_mailpass' };
161 $settings { 'TLS' } = $cgiparams { 'mail_tls' };
162 $settings { 'MAILSENDER' } = $cgiparams { 'txt_mailsender' };
163 $settings { 'MAILSUB' } = $cgiparams { 'txt_mailsubject' };
164 $settings { 'MAILTXT' } = $mailtxt ;
165 & General
:: writehash
( " $settingsfile " , \
%settings );
167 $cgiparams { 'update' }= 'on' ;
171 if ( $cgiparams { 'ACTION' } eq " $Lang ::tr{'acct view'}" ){ #If special month and year is given on mainsite
172 & mainsite
( $cgiparams { 'month' }, $cgiparams { 'year' });
175 if ( $cgiparams { 'ACTION' } eq " $Lang ::tr{'acct commit'}" ){ #Maintenance function
176 & ACCT
:: logger
( $settings { 'LOG' }, "Clear DB (all data) committed). \n " );
180 if ( $cgiparams { 'ACTION2' } eq " $Lang ::tr{'acct commit'}" ){ #Maintenance function
181 & ACCT
:: logger
( $settings { 'LOG' }, "Clear DB (only traffic data) committed). \n " );
185 if ( $cgiparams { 'ACTION1' } eq " $Lang ::tr{'acct commit'}" ){ #Maintenance Function
187 my ( $a , $b )=& ACCT
:: getmonth
( $cgiparams { 'expmonth' }, $cgiparams { 'expyear' });
188 & ACCT
:: delbefore
(( $a - 1 ));
191 if ( $cgiparams { 'ACTION' } eq "viewgraph" ){ #Graph icon on hosttable (viewhosttable)
192 & graphsite
( $cgiparams { 'month' }, $cgiparams { 'year' }, $cgiparams { 'host' });
194 if ( $cgiparams { 'ACTION1' } eq " $Lang ::tr{'save'}" ){ #SaveButton when adding Address
195 $errormessage =& checkaddress
;
198 & addressmgmnt
( $errormessage );
201 $cgiparams { 'txt_company' },
202 $cgiparams { 'rdo_companytype' },
203 $cgiparams { 'txt_name1' },
204 $cgiparams { 'txt_str' },
205 $cgiparams { 'txt_str_nr' },
206 $cgiparams { 'txt_plz' },
207 $cgiparams { 'txt_city' },
208 $cgiparams { 'txt_bank' },
209 $cgiparams { 'txt_iban' },
210 $cgiparams { 'txt_bic' },
211 $cgiparams { 'txt_blz' },
212 $cgiparams { 'txt_kto' },
213 $cgiparams { 'txt_email' },
214 $cgiparams { 'txt_inet' },
215 $cgiparams { 'txt_hrb' },
216 $cgiparams { 'txt_ustid' },
217 $cgiparams { 'txt_tel' },
218 $cgiparams { 'txt_fax' },
220 & ACCT
:: logger
( $settings { 'LOG' }, "Created new address $cgiparams {'txt_company'} as $cgiparams {'rdo_companytype'}. \n " );
225 if ( $cgiparams { 'ACTION' } eq "edit_addr" ){ #Pencil icon in Address overwiev on Addressmgmnt site
226 $cgiparams { 'update' } = 'on' ;
227 $cgiparams { 'oldcompname' }= $cgiparams { 'txt_company' };
230 if ( $cgiparams { 'ACTION' } eq " $Lang ::tr{'update'}" ){ #UpdateButton when editing Address
231 $cgiparams { 'update' } = 'on' ;
232 $errormessage =& checkaddress
;
234 & addressmgmnt
( $errormessage );
237 $cgiparams { 'rdo_companytype' },
238 $cgiparams { 'txt_company' },
239 $cgiparams { 'txt_name1' },
240 $cgiparams { 'txt_str' },
241 $cgiparams { 'txt_str_nr' },
242 $cgiparams { 'txt_plz' },
243 $cgiparams { 'txt_city' },
244 $cgiparams { 'txt_bank' },
245 $cgiparams { 'txt_iban' },
246 $cgiparams { 'txt_bic' },
247 $cgiparams { 'txt_blz' },
248 $cgiparams { 'txt_kto' },
249 $cgiparams { 'txt_email' },
250 $cgiparams { 'txt_inet' },
251 $cgiparams { 'txt_hrb' },
252 $cgiparams { 'txt_ustid' },
253 $cgiparams { 'txt_tel' },
254 $cgiparams { 'txt_fax' },
255 $cgiparams { 'oldcompname' }
257 my $res =& ACCT
:: getbillgroups
;
258 foreach my $line ( @
$res ){
259 my ( $name , $host , $cust )= @
$line ;
260 if ( $host eq $cgiparams { 'oldcompname' }){
261 & ACCT
:: updatebillgrouphost
( $cgiparams { 'oldcompname' }, $cgiparams { 'txt_company' });
262 } elsif ( $cust eq $cgiparams { 'oldcompname' }){
263 & ACCT
:: updatebillgroupcust
( $cgiparams { 'oldcompname' }, $cgiparams { 'txt_company' });
267 & ACCT
:: logger
( $settings { 'LOG' }, "Edited address $cgiparams {'oldcompname'}. \n " );
272 if ( $cgiparams { 'ACTION' } eq "del_addr" ){ #Trash icon in Address overview on Addressmgmnt site
273 my $res =& ACCT
:: checkbillgrp
;
274 foreach my $line ( @
$res ){
275 my ( $grp , $host , $cust ) = @
$line ;
276 if ( $cgiparams { 'txt_company' } eq $host ){
277 $errormessage = " $Lang ::tr{'acct err hostdel'} $grp " ;
279 if ( $cgiparams { 'txt_company' } eq $cust ){
280 $errormessage = " $Lang ::tr{'acct err custdel'} $grp " ;
283 if (! $errormessage ){
284 & ACCT
:: deladdr
( $cgiparams { 'txt_company' });
285 & ACCT
:: logger
( $settings { 'LOG' }, "Deleted address $cgiparams {'txt_company'}. \n " );
287 $cgiparams { 'txt_company' }= '' ;
290 if ( $cgiparams { 'BILLACTION' } eq " $Lang ::tr{'save'}" ){ #SaveButton when adding BillingGroups
291 #check if a group with the same name already exists in DB
292 my $res =& ACCT
:: getbillgroups
;
293 foreach my $row ( @
$res ) {
295 if ( $group eq $cgiparams { 'txt_billgroup' }){
296 $errormessage .= $Lang :: tr
{ 'acct billgroupexists' };
299 #Check if a selected user is in another group already
300 if ( $settings { 'MULTIUSER' } ne 'on' ){
301 #split hosts into array
302 my @user = split ( /\|/ , $cgiparams { 'sel_hosts' });
303 my $res =& ACCT
:: checkusergrp
;
304 foreach my $val ( @
$res ){
305 my ( $grp , $usr )= @
$val ;
306 foreach my $wanted ( @user ){
308 $errormessage .= " $usr $Lang ::tr{'acct usermulti'} $grp <br>" ;
314 if (!& validtextfield
( $cgiparams { 'txt_billgroup' })){
315 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'name'}<br>" ;
317 #FIXME: Validate CENT amount (num with .)
318 #if used colon, replace with .
319 $cgiparams { 'txt_cent' } =~ tr/,/./ ;
320 if (!& validnumfield
( $cgiparams { 'txt_cent' })){
321 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct cent'}<br>" ;
324 my @ips = split ( /\|/ , $cgiparams { 'sel_hosts' });
326 #Check if we use extra bill positions
327 if ( $cgiparams { 'txt_amount' } || $cgiparams { 'txt_name' }|| $cgiparams { 'txt_price' }){
328 if (! $cgiparams { 'txt_amount' } || ! $cgiparams { 'txt_name' } || ! $cgiparams { 'txt_price' }){
329 $errormessage .= " $Lang ::tr{'acct invalid billpos'}<br>" ;
333 if (! & validnumfield
( $cgiparams { 'txt_amount' })){
334 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct amount'}<br>" ;
335 } elsif (! & validtextfield
( $cgiparams { 'txt_name' })){
336 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct name'}<br>" ;
337 } elsif (! & validnumfield
( $cgiparams { 'txt_price' })){
338 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct price pp'}<br>" ;
344 & billgroupsite
( $errormessage );
346 #check if we use extra positions
347 if ( $cgiparams { 'txt_amount' }){
349 $cgiparams { 'txt_posbillgroup' },
350 $cgiparams { 'txt_amount' },
351 $cgiparams { 'txt_name' },
352 $cgiparams { 'txt_price' });
353 & ACCT
:: logger
( $settings { 'LOG' }, "Saved new fixed billposition $cgiparams {'txt_name'} into billgroup $cgiparams {'txt_posbillgroup'} . \n " );
357 & ACCT
:: savebillgroup
(
358 $cgiparams { 'txt_billgroup' },
359 $cgiparams { 'txt_billtext1' },
360 $cgiparams { 'dd_host' },
361 $cgiparams { 'dd_cust' },
362 $cgiparams { 'txt_cent' },
364 & ACCT
:: logger
( $settings { 'LOG' }, "Saved new billgroup $cgiparams {'txt_billgroup'}. \n " );
369 if ( $cgiparams { 'BILLACTION' } eq " $Lang ::tr{'update'}" ){ #UpdateButton when editing BillingGroups
372 my $filename = $cgiparams { 'uploaded_file' };
374 #First check if logo dir exists
375 if (! - d
" $logopath / $cgiparams {'logo_grp'}" ){
376 mkpath
( " $logopath / $cgiparams {'logo_grp'}" , 0 , 01777 );
379 my ( $filehandle ) = CGI
:: upload
( 'uploaded_file' );
380 open ( UPLOADFILE
, "> $logopath / $cgiparams {'logo_grp'}/logo.png" );
382 while ( < $filehandle > ) {
387 #Check dimensions of uploaded file
388 open ( PNG
, "< $logopath / $cgiparams {'logo_grp'}/logo.png" ) ;
392 my ( $width , $height )=& ACCT
:: pngsize
( $PNG1 ) ;
394 if (! & validnumfield
( $width )){
395 $errormessage .= " $Lang ::tr{'acct invalid png'}<br>" ;
396 unlink ( " $logopath / $cgiparams {'logo_grp'}/logo.png" );
397 } elsif ( $width > 400 || $height > 150 ){
398 $errormessage .= " $Lang ::tr{'acct invalid pngsize'} width: $width height: $height <br>" ;
399 unlink ( " $logopath / $cgiparams {'logo_grp'}/logo.png" );
403 #Check if a group with the same name already exists in DB
404 my $res =& ACCT
:: getbillgroups
;
405 foreach my $row ( @
$res ) {
407 if (( $group eq $cgiparams { 'txt_billgroup' }) && ( $cgiparams { 'oldname' } ne $cgiparams { 'txt_billgroup' })){
408 $errormessage .= $Lang :: tr
{ 'acct billgroupexists' };
411 #Check if a selected user is in another group already
412 if ( $settings { 'MULTIUSER' } ne 'on' ){
413 #split hosts into array
414 my @user = split ( /\|/ , $cgiparams { 'sel_hosts' });
415 my $res =& ACCT
:: checkusergrp
;
416 foreach my $val ( @
$res ){
417 my ( $grp , $usr )= @
$val ;
418 foreach my $wanted ( @user ){
419 if ( $usr eq $wanted && $grp ne $cgiparams { 'txt_billgroup' }){
420 $errormessage .= " $usr $Lang ::tr{'acct usermulti'} $grp <br>" ;
426 if (!& validtextfield
( $cgiparams { 'txt_billgroup' })){
427 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'name'}" ;
429 #Validate CENT amount (num with .)
430 #if used colon, replace with .
431 $cgiparams { 'txt_cent' } =~ tr/,/./ ;
432 if (!& validnumfield
( $cgiparams { 'txt_cent' })){
433 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct cent'}<br>" ;
437 my @ips = split ( /\|/ , $cgiparams { 'sel_hosts' });
439 #Check if we use extra bill positions
440 if ( $cgiparams { 'txt_amount' } || $cgiparams { 'txt_name' }|| $cgiparams { 'txt_price' }){
441 if (! $cgiparams { 'txt_amount' } || ! $cgiparams { 'txt_name' } || ! $cgiparams { 'txt_price' }){
442 $errormessage .= " $Lang ::tr{'acct invalid billpos'}<br>" ;
446 if (! & validnumfield
( $cgiparams { 'txt_amount' })){
447 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct amount'}<br>" ;
448 } elsif (! & validtextfield
( $cgiparams { 'txt_name' })){
449 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct name'}<br>" ;
450 } elsif (! & validnumfield
( $cgiparams { 'txt_price' })){
451 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct price pp'}<br>" ;
455 #Check if we added some CC mail recipients
456 if ( $cgiparams { 'txt_ccmail' }){
457 $cgiparams { 'txt_ccmail' }=~ s/ //g ;
458 #Split line into single addresses and check each one
459 my @ccaddr = split ( "," , $cgiparams { 'txt_ccmail' });
460 foreach my $cc ( @ccaddr ){
461 if (! & General
:: validemail
( $cc )){
462 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct ccmail'} $cc <br>" ;
467 $cgiparams { 'update' } = 'on' ;
470 #update fixedbillpositions if defined
471 if ( $cgiparams { 'oldname' } ne $cgiparams { 'txt_billgroup' }){
472 & ACCT
:: updatebillpos
( $cgiparams { 'oldname' }, $cgiparams { 'txt_billgroup' });
474 #Check if we use extra positions
475 if ( $cgiparams { 'txt_amount' }){
477 $cgiparams { 'txt_billgroup' },
478 $cgiparams { 'txt_amount' },
479 $cgiparams { 'txt_name' },
480 $cgiparams { 'txt_price' });
482 #Check if we have NEW cc Mails
483 if ( $cgiparams { 'txt_ccmail' } ne $cgiparams { 'oldccmail' }){
484 & ACCT
:: updateccaddr
( $cgiparams { 'txt_ccmail' }, $cgiparams { 'dd_cust' });
486 & ACCT
:: deletebillgroup
( $cgiparams { 'oldname' });
487 & ACCT
:: savebillgroup
(
488 $cgiparams { 'txt_billgroup' },
489 $cgiparams { 'txt_billtext1' },
490 $cgiparams { 'dd_host' },
491 $cgiparams { 'dd_cust' },
492 $cgiparams { 'txt_cent' },
498 if ( $cgiparams { 'BILLACTION' } eq "edit_billgroup" ){ #Pencil icon in Billgroup table
499 $cgiparams { 'update' } = 'on' ;
502 if ( $cgiparams { 'BILLACTION' } eq "delete_billgroup" ){ #Trash icon in Billgroup table
503 & deletefiles
( $cgiparams { 'txt_billgroup' });
504 & ACCT
:: delbillpos
( $cgiparams { 'txt_billgroup' });
505 & ACCT
:: deletebillgroup
( $cgiparams { 'txt_billgroup' });
506 & ACCT
:: logger
( $settings { 'LOG' }, "Deleted billgroup $cgiparams {'txt_billgroup'}. \n " );
509 if ( $cgiparams { 'BILLACTION' } eq "open_billgroup" ){ #Folder icon on billgrouptable (viewtablebillgroup)
510 & billoverview
( $cgiparams { 'txt_billgroup' });
512 if ( $cgiparams { 'BILLPOS' } eq "delpos" ){ #Trash icon in Billpos table
513 $cgiparams { 'update' } = 'on' ;
514 & ACCT
:: delbillpos_single
( $cgiparams { 'txt_billpos' }, $cgiparams { 'txt_billgroup' });
515 & ACCT
:: logger
( $settings { 'LOG' }, "Deleted fixed billposition $cgiparams {'txt_billpos'} from billgroup $cgiparams {'txt_billgroup'}. \n " );
518 if ( $cgiparams { 'BILLPOS' } eq " $Lang ::tr{'save'}" ){ #Savebutton in Billpos table
519 $cgiparams { 'update' }= 'on' ;
520 #Check if we use extra bill positions
521 if ( $cgiparams { 'txt_amount' } || $cgiparams { 'txt_name' }|| $cgiparams { 'txt_price' }){
522 if (! $cgiparams { 'txt_amount' } || ! $cgiparams { 'txt_name' } || ! $cgiparams { 'txt_price' }){
523 $errormessage .= " $Lang ::tr{'acct invalid billpos'}<br>" ;
527 #if used colon, replace with .
528 $cgiparams { 'txt_price' } =~ tr/,/./ ;
529 if (! & validnumfield
( $cgiparams { 'txt_amount' })){
530 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct amount'}<br>" ;
531 } elsif (! & validtextfield
( $cgiparams { 'txt_name' })){
532 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct name'}<br>" ;
533 } elsif (! & validnumfield
( $cgiparams { 'txt_price' })){
534 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct price pp'}<br>" ;
539 & billgroupsite
( $errormessage );
541 #check if we use extra positions
542 if ( $cgiparams { 'txt_amount' }){
544 $cgiparams { 'txt_billgroup' },
545 $cgiparams { 'txt_amount' },
546 $cgiparams { 'txt_name' },
547 $cgiparams { 'txt_price' });
549 & ACCT
:: logger
( $settings { 'LOG' }, "Added fixed billposition $cgiparams {'txt_amount'} $cgiparams {'txt_name'} with price $cgiparams {'txt_price'} to billgroup $cgiparams {'txt_billgroup'}. \n " );
556 #Check if we already have settings
557 if ( - z
$settingsfile ){
560 & mainsite
(( $mon + 1 ),( $year + 1900 ));
566 my $blockactivation = '' ;
567 #If update set fieldvalues new
568 if ( $cgiparams { 'update' } eq 'on' ){
569 $settings { 'USEMAIL' } = 'on' ;
570 $settings { 'MAILSRV' } = $cgiparams { 'txt_mailserver' };
571 $settings { 'MAILPORT' } = $cgiparams { 'txt_mailport' };
572 $settings { 'MAILUSER' } = $cgiparams { 'txt_mailuser' };
573 $settings { 'MAILPASS' } = $cgiparams { 'txt_mailpass' };
574 $settings { 'MAILSUB' } = $cgiparams { 'txt_mailsubject' };
575 $settings { 'MAILTXT' } = $cgiparams { 'txt_mailtxt' };
578 $checked { 'expert' }{ $settings { 'EXPERT' }} = 'CHECKED' ;
579 $checked { 'logging' }{ $settings { 'LOG' }} = 'CHECKED' ;
580 $checked { 'multiuser' }{ $settings { 'MULTIUSER' }} = 'CHECKED' ;
581 $checked { 'usemail' }{ $settings { 'USEMAIL' }} = 'CHECKED' ;
582 $checked { 'mail_tls' }{ $settings { 'TLS' }} = 'CHECKED' ;
585 & Header
:: openpage
( $Lang :: tr
{ 'acct settings' }, 1 , '' );
586 & Header
:: openbigbox
( '100%' , 'center' );
588 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'acct config' });
590 #### JAVA SCRIPT ####
593 \$(document).ready(function() {
594 // Show/Hide elements when NAT checkbox is checked.
595 if (\$("#MAIL").attr("checked")) {
598 \$(".MAILSRV").hide();
601 // Show NAT area when "use nat" checkbox is clicked
602 \$("#MAIL").change(function() {
603 \$(".MAILSRV").toggle();
609 #######################
610 $settings { 'SKIPURLS' } =~ tr/|/\r\n/ ;
611 $settings { 'MAILTXT' } =~ tr/|/\r\n/ ;
612 my $col = "style='background-color: $color {'color22'}'" ;
614 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
615 <table style='width:100%'>
617 <th colspan='3'></th>
620 <td style='width:24em'> $Lang ::tr{'acct logging'}</td>
621 <td><input type='checkbox' name='logging' $checked {'logging'}{'on'}></td>
625 <td> $Lang ::tr{'acct expert'}</td>
626 <td><input type='checkbox' name='expert' $checked {'expert'}{'on'}></td>
630 <td> $Lang ::tr{'acct multiuser'}</td>
631 <td><input type='checkbox' name='multiuser' $checked {'multiuser'}{'on'}></td>
635 <td> $Lang ::tr{'acct mwst'}</td>
636 <td><input type='text' name='txt_mwst' value=' $settings {'MWST'}' style='width:22em;'></td>
639 <td> $Lang ::tr{'acct currency'}</td>
640 <td><input type='text' name='txt_currency' value=' $settings {'CURRENCY'}' style='width:22em;'></td>
644 <td valign='top'> $Lang ::tr{'acct skipurl'}</td>
645 <td style='padding-left:0.2em;'><textarea name="txt_skipurls" cols="20" rows="6" style='width:22em;'> $settings {'SKIPURLS'}</textarea></td>
649 <td> $Lang ::tr{'acct usemail'}</td>
650 <td><label><input type='checkbox' name='USEMAIL' id='MAIL' $checked {'usemail'}{'on'}></label></td>
655 <div class="MAILSRV">
656 <table style='width:100%;'>
658 <td style='width:24em'> $Lang ::tr{'acct mailaddr'}</td>
659 <td><input type='text' name='txt_mailserver' value=' $settings {'MAILSRV'}' style='width:22em;'></td>
662 <td> $Lang ::tr{'acct mailport'}</td>
663 <td><input type='text' name='txt_mailport' value=' $settings {'MAILPORT'}' size='3'></td>
666 <td> $Lang ::tr{'acct mailuser'}<img src='/blob.gif' alt='*' /></td>
667 <td><input type='text' name='txt_mailuser' value=' $settings {'MAILUSER'}' style='width:22em;'></td>
670 <td> $Lang ::tr{'acct mailpass'}<img src='/blob.gif' alt='*' /></td>
671 <td><input type='password' name='txt_mailpass' value=' $settings {'MAILPASS'}' style='width:22em;' ></td>
674 <td> $Lang ::tr{'acct tls'}</td>
675 <td><input type='checkbox' name='mail_tls' $checked {'mail_tls'}{'on'}></td>
678 <td> $Lang ::tr{'acct mailsender'}</td>
679 <td><input type='text' name='txt_mailsender' value=' $settings {'MAILSENDER'}' style='width:22em;'></td>
682 <td colspan='2'> </td>
685 <td> $Lang ::tr{'acct subject'}</td>
686 <td><input type='text' name='txt_mailsubject' value=' $settings {'MAILSUB'}' style='width:22em;'></td>
689 <td valign='top' > $Lang ::tr{'acct mailtxt'}</td>
690 <td style='padding-left:0.2em;'><textarea name="txt_mailtxt" cols="34" rows="6" style='width: 22em;'> $settings {'MAILTXT'}</textarea></td>
696 <table style='width:100%;'>
698 <td colspan='3' display:inline align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}'></td>
707 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
708 <table style='width:100%;'>
711 <td align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'back'}'></td>
716 & Header
:: closebigbox
();
717 & Header
:: closepage
();
723 rmtree
( " $logopath / $grp " );
724 rmtree
( "${General::swroot}/accounting/bill/ $grp " );
730 if ( $_ [ 0 ]){ $mon = $_ [ 0 ];}
731 & Header
:: openpage
( $Lang :: tr
{ 'acct title' }, 1 , '' );
732 & Header
:: openbigbox
( '100%' , 'center' );
736 & viewtablehosts
(( $mon ), $year );
737 & Header
:: closebigbox
();
738 & Header
:: closepage
();
742 & Header
:: openpage
( $Lang :: tr
{ 'acct maintenance' }, 1 , '' );
743 & Header
:: openbigbox
( '100%' , 'center' );
745 #Get size of Databasefile
746 my $sizedb = - s
"/var/ipfire/accounting/acct.db" ;
747 $sizedb = sprintf "%.2f" , $sizedb /( 1024 * 1024 );
748 #Get size of Directory, where all bills are stored
750 find
( sub { $sizerrd += - s
if - f
$_ }, "${General::swroot}/accounting/bill" );
751 $sizerrd = sprintf "%.2f" , $sizerrd /( 1024 * 1024 );
754 #Get latest and earliest entry of DB
755 my ( $min , $max ) = & ACCT
:: getminmax
;
759 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'acct status' });
761 <table style='width:100%;' cellspacong='0' class='tbl'>
763 <th align='left' width='30%'> $Lang ::tr{'name'}</th>
764 <th align='left'> $Lang ::tr{'acct value'}</th>
767 <td> $Lang ::tr{'acct dbsize'}</td>
771 <td> $Lang ::tr{'acct rrdsize'}</td>
775 <td> $Lang ::tr{'acct oldestdb'}</td>
779 <td> $Lang ::tr{'acct latestdb'}</td>
786 #print Database maintenance table
787 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'acct dbmaintenance' });
790 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
791 <table style='width:100%;' cellspacing='0' class='tbl'>
793 <th> $Lang ::tr{'acct task'}</th>
794 <th> $Lang ::tr{'acct parameter'}</th>
795 <th> $Lang ::tr{'acct action'}</th>
798 <td> $Lang ::tr{'acct emptydb'}</td>
800 <td><input type='submit' name='ACTION2' value=' $Lang ::tr{'acct commit'}' style='width:10em'></td>
803 <td> $Lang ::tr{'acct emptydbtraf'}</td>
805 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'acct commit'}' style='width:10em'></td>
808 <td> $Lang ::tr{'acct delbefore'} (ACCT,ACCT_HIST)</td>
809 <td><select name='expmonth'>
811 for ( my $i = 1 ; $i < 13 ; $i ++){
812 print "<option> $i </option>" ;
814 print "</select><select name='expyear'>" ;
815 for ( my $i = 2014 ; $i <=( $year + 1900 ); $i ++){
816 print "<option> $i </option>" ;
820 <td><input type='submit' name='ACTION1' value=' $Lang ::tr{'acct commit'}' style='width:10em'></td>
828 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
829 <table style='width:100%;'>
832 <td align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'back'}'></td>
839 & Header
:: closebigbox
();
840 & Header
:: closepage
();
846 #GET : Timestamp in seconds since 1.1.1970
847 #GIVES: Date in Format dd.mm.yyyy HH:MM:SS
849 my $y = sprintf ( " %02d " ,( localtime ( $val ))[ 5 ]- 100 );
850 my $Y = sprintf ( " %04d " ,( localtime ( $val ))[ 5 ]+ 1900 );
851 my $m = sprintf ( " %02d " ,( localtime ( $val ))[ 4 ]+ 1 );
852 my $d = sprintf ( " %02d " ,( localtime ( $val ))[ 3 ]);
853 my $H = sprintf ( " %02d " ,( localtime ( $val ))[ 2 ]);
854 my $M = sprintf ( " %02d " ,( localtime ( $val ))[ 1 ]);
855 my $S = sprintf ( " %02d " ,( localtime ( $val ))[ 0 ]);
857 return " $d . $m . $Y $H : $M : $S " ;
861 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'menu' });
863 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
864 <table style='width: 100%;'>
866 <td style='display:inline;'>
867 <input type='submit' name='ACTION' value=' $Lang ::tr{'acct config'}'>
868 <input type='submit' name='ACTION' value=' $Lang ::tr{'acct addresses'}'>
869 <input type='submit' name='ACTION' value=' $Lang ::tr{'acct billgroup'}'>
871 if ( $settings { 'EXPERT' } eq 'on' ){
872 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'acct maintenance'}'>" ;
888 & Header
:: openpage
( " $Lang ::tr{'acct host detail'} $grhost " , 1 , '' );
889 & Header
:: openbigbox
( '100%' , 'center' );
890 & Header
:: openbox
( '100%' , 'left' , );
892 & generatemonthgraph
( $grmon , $gryear , $grhost );
895 & Header
:: closebigbox
();
896 & Header
:: closepage
();
900 sub generatemonthgraph
{
904 my ( $from , $till ) = & ACCT
:: getmonth
( $grmon , $gryear );
908 #If we want to show Data from within last 2 months, get DATA from ACCT
909 if ( ! $grmon < ( $mon + 1 ) && $gryear == ( $year + 1900 )){
910 $sth =& ACCT
:: getmonthgraphdata
( "ACCT" , $from , $till , $grhost );
912 #If we want to show data from a date older than last two months, use ACCT_HIST
913 $sth =& ACCT
:: getmonthgraphdata
( "ACCT_HIST" , $from , $till , $grhost );
917 foreach my $i ( 0 ..$ #$_) {
918 push ( @
{ $values [ $i ]},( $_ ->[ $i ]));
922 for my $graph ( GD
:: Graph
:: area
-> new ( 600 , 200 ))
924 my $name = $cgiparams { 'host' };
929 accentclr
=> 'dblue' ,
930 valuesclr
=> '#ffff77' ,
932 axislabelcl
=> 'black' ,
936 dclrs
=> [ qw(lgreen lred) ],
937 x_label
=> $Lang :: tr
{ 'date' },
938 y_label
=> $Lang :: tr
{ 'acct mb' },
941 #x_label_skip => 3, #skip every 3 x-axis title
942 x_label_position
=> 0 ,
946 $graph -> set_legend ( " $Lang ::tr{'acct traffic'}" );
947 $graph -> set ( x_labels_vertical
=> 1 , values_vertical
=> 1 );
948 my $gd = $graph -> plot ( \
@values );
949 open ( IMG
, '>/srv/web/ipfire/html/accounting/tmpgraph.png' ) or die $!;
953 #Show Box with monthly graph for this host
954 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'acct traffic monthly' });
955 print "<center><img src='/accounting/tmpgraph.png' alt=' $grhost '></center>" ;
956 print "<b> $cgiparams {'traffic'}</b>" ;
959 <table style='width:100%;'>
961 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
962 <td align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'back'}'></td>
969 sub generatehourgraph
{
973 my ( $from , $till ) = & ACCT
:: getmonth
( $grmon , $gryear );
977 #If we want to show Data from within last 2 months, get DATA from ACCT
978 if ( ! $grmon < ( $mon + 1 ) && $gryear == ( $year + 1900 )){
979 $sth =& ACCT
:: getgraphdata
( "ACCT" , $from , $till , $grhost );
981 #If we want to show data from a date older than last two months, use ACCT_HIST
982 $sth =& ACCT
:: getgraphdata
( "ACCT_HIST" , $from , $till , $grhost );
986 foreach my $i ( 0 ..$ #$_) {
989 push ( @
{ $values [ $i ]},( $_ ->[ $i ] /1024/ 1024 ));
991 push ( @
{ $values [ $i ]}, $_ ->[ $i ]);
998 for my $graph ( GD
:: Graph
:: area
-> new ( 600 , 200 ))
1000 my $name = $cgiparams { 'host' };
1001 print STDERR
"Processing $name mit sosse \n " ;
1004 x_label
=> 'X Label' ,
1005 y_label
=> 'Y label' ,
1006 title
=> 'An Area Graph' ,
1008 #y_tick_number => 8,
1010 #accent_treshold => 41,
1014 $graph -> set_legend ( 'one' , 'two' );
1015 my $gd = $graph -> plot ( \
@values );
1016 open ( IMG
, '>/srv/web/ipfire/html/test/file.png' ) or die $!;
1021 print "<img src='/test/file.png' alt='Tanzmaus'>" ;
1028 if ( $proxsrv eq $Lang :: tr
{ 'stopped' }){
1029 $bgcolor1 = "bgcolor='${Header::colourred}' align='center'" ;
1030 $message = "<br> $Lang ::tr{'acct proxy_enable'}" ;
1032 $bgcolor1 = "bgcolor='${Header::colourgreen}' align='center'" ;
1034 if ( $proxlog eq $Lang :: tr
{ 'stopped' }){
1035 $bgcolor2 = "bgcolor='${Header::colourred}' align='center'" ;
1036 $message = $message . "<br> $Lang ::tr{'acct proxylog_enable'}" ;
1038 $bgcolor2 = "bgcolor='${Header::colourgreen}' align='center'" ;
1040 & Header
:: openbox
( '100%' , 'left' , );
1042 <center><table width='50%' class='tbl'>
1044 <th> $Lang ::tr{'service'}</th>
1045 <th> $Lang ::tr{'status'}</th>
1048 <td bgcolor=' $color {'color22'}'> $Lang ::tr{'proxy'}</td>
1049 <td $bgcolor1 ><font color='white'> $proxsrv </td>
1052 <td bgcolor=' $color {'color20'}'> $Lang ::tr{'logging'}</td>
1053 <td $bgcolor2 ><font color='white'> $proxlog </td>
1057 print "<tr><td colspan='2'><font color='red'> $message <br> $Lang ::tr{'acct nodata'}</td></tr>" ;
1060 & Header
:: closebox
();
1065 #GIVES: Value (in MB,GB,TB) With Type ("MB","GB","TB")
1068 if (( $val / 1024 ) < 1024 ){
1070 $val = sprintf "%.2f" , $val / 1024 ;
1071 $type = $Lang :: tr
{ 'acct kb' };
1072 } elsif (( $val /( 1024 * 1024 )) < 1024 ){
1074 $val = sprintf "%.2f" , $val /( 1024 * 1024 );
1075 $type = $Lang :: tr
{ 'acct mb' };
1076 } elsif (( $val /( 1024 * 1024 * 1024 )) < 1024 ){
1078 $val = sprintf "%.2f" , $val /( 1024 * 1024 * 1024 );
1079 $type = $Lang :: tr
{ 'acct gb' };
1080 } elsif (( $val /( 1024 * 1024 * 1024 * 1024 )) < 1024 ){
1082 $val = sprintf "%.2f" , $val /( 1024 * 1024 * 1024 * 1024 );
1083 $type = $Lang :: tr
{ 'acct tb' };
1085 return ( $val , $type );
1089 #This function shows the site "address management"
1090 & Header
:: openpage
( " $Lang ::tr{'acct addresses'}" , 1 , '' );
1091 & Header
:: openbigbox
( '100%' , 'center' );
1096 #Get all Addresses from DB
1097 my $res = & ACCT
:: getaddresses
;
1099 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'acct edit_addr' } );
1101 #When no address preselected, set COMPANYTYPE to "CUST"
1102 if ( $cgiparams { 'rdo_companytype' } eq '' ){
1103 $cgiparams { 'rdo_companytype' } = 'CUST' ;
1105 $checked { 'rdo_companytype' }{ $cgiparams { 'rdo_companytype' }} = 'CHECKED' ;
1109 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1110 <table style=width:100%;'>
1112 <td style='width:8em;'></td>
1114 <td colspan='2'><font size="1"> $Lang ::tr{'acct hint_hoster'}:</font></td>
1117 <td> $Lang ::tr{'acct companytype'}</td>
1119 <input type='radio' name='rdo_companytype' value='CUST' $checked {'rdo_companytype'}{'CUST'}> $Lang ::tr{'acct customer'}
1120 <input type='radio' name='rdo_companytype' value='HOST' $checked {'rdo_companytype'}{'HOST'}> $Lang ::tr{'acct hoster'}</td>
1121 <td style='width:8em;'> $Lang ::tr{'acct bank'}</td>
1123 <input type='text' name='txt_bank' value=' $cgiparams {'txt_bank'}' style='width:25em;'></td>
1126 <td> $Lang ::tr{'acct company'}</td>
1128 <input type='text' name='txt_company' value=' $cgiparams {'txt_company'}' style='width:25em;'></td>
1129 <td> $Lang ::tr{'acct iban'}<img src='/blob.gif' alt='*' /></td>
1131 <input type='text' name='txt_iban' value=' $cgiparams {'txt_iban'}' style='width:25em;'></td>
1134 <td> $Lang ::tr{'acct name1'}<img src='/blob.gif' alt='*' /></td>
1136 <input type='text' name='txt_name1' value=' $cgiparams {'txt_name1'}' style='width:25em;'></td>
1137 <td> $Lang ::tr{'acct bic'}<img src='/blob.gif' alt='*' /></td>
1139 <input type='text' name='txt_bic' maxlength='8' value=' $cgiparams {'txt_bic'}' style='width:25em;'></td>
1142 <td> $Lang ::tr{'acct str'}</td>
1144 <input type='text' name='txt_str' value=' $cgiparams {'txt_str'}' style='width:25em;'></td>
1145 <td> $Lang ::tr{'acct blz'}</td>
1147 <input type='text' name='txt_blz' maxlength='8' value=' $cgiparams {'txt_blz'}' style='width:25em;'></td>
1150 <td> $Lang ::tr{'acct str_nr'}</td>
1151 <td><input type='text' name='txt_str_nr' value=' $cgiparams {'txt_str_nr'}' style='width:25em;'></td>
1152 <td> $Lang ::tr{'acct kto'}</td>
1154 <input type='text' name='txt_kto' value=' $cgiparams {'txt_kto'}' style='width:25em;'></td>
1159 <td> $Lang ::tr{'acct plz'}</td>
1161 <input type='text' name='txt_plz' value=' $cgiparams {'txt_plz'}' style='width:25em;'></td>
1162 <td> $Lang ::tr{'acct email'}</td>
1163 <td><input type='text' name='txt_email' value=' $cgiparams {'txt_email'}' style='width:25em;'></td>
1166 <td> $Lang ::tr{'acct city'}</td>
1167 <td><input type='text' name='txt_city' value=' $cgiparams {'txt_city'}' style='width:25em;'></td>
1168 <td> $Lang ::tr{'acct inet'}<img src='/blob.gif' alt='*' /></td>
1170 <input type='text' name='txt_inet' value=' $cgiparams {'txt_inet'}' style='width:25em;'></td>
1175 <td> $Lang ::tr{'acct hrb'}<img src='/blob.gif' alt='*' /></td>
1177 <input type='text' name='txt_hrb' value=' $cgiparams {'txt_hrb'}' style='width:25em;'></td>
1182 <td> $Lang ::tr{'acct ustid'}</td>
1183 <td><input type='text' name='txt_ustid' value=' $cgiparams {'txt_ustid'}' style='width:25em;'></td>
1188 <td> $Lang ::tr{'acct tel'}<img src='/blob.gif' alt='*' /></td>
1190 <input type='text' name='txt_tel' value=' $cgiparams {'txt_tel'}' style='width:25em;'></td>
1195 <td> $Lang ::tr{'acct fax'}<img src='/blob.gif' alt='*' /></td>
1197 <input type='text' name='txt_fax' value=' $cgiparams {'txt_fax'}' style='width:25em;'></td>
1200 <td colspan='6'><img src='/blob.gif' alt='*' /><font size="1"> $Lang ::tr{'acct optional'}</font></td>
1204 if ( $cgiparams { 'update' } eq 'on' ){
1205 print "<input type='hidden' name='oldcompname' value=' $cgiparams {'oldcompname'}'>" ;
1206 print "<td colspan='6' align='right' display:inline><input type='submit' name='ACTION' value=' $Lang ::tr{'update'}'></td>" ;
1208 print "<td colspan='6' align='right' display:inline><input type='submit' name='ACTION1' value=' $Lang ::tr{'save'}'></td>" ;
1210 print "</tr></table></form>" ;
1211 & Header
:: closebox
();
1214 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1215 <table style='width:100%;'>
1217 <td align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'back'}'></td>
1222 #Check if we need to show HOSTBOX and/or CUSTBOX
1223 foreach my $row ( @
$res ) {
1224 my ( $gr , $comp , $type , $name1 , $str , $nr , $plz , $city , $bank , $iban , $bic , $blz , $kto , $email , $inet , $hrb , $ustid , $tel , $fax ) = @
$row ;
1225 if ( $type eq 'HOST' ){
1228 if ( $type eq 'CUST' ){
1232 #Show HOSTER Addresses if any
1236 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'acct exst_host_addr' } );
1238 print "<table style='width:100%'>" ;
1239 foreach my $row ( @
$res ) {
1240 #SET colors for tablerows
1241 $col = "style='background-color: $color {'color22'}'" ;
1242 $col1 = "style='background-color:#e2d8d8'" ;
1243 my ( $gr , $comp , $type , $name1 , $str , $nr , $plz , $city , $bank , $iban , $bic , $blz , $kto , $email , $inet , $hrb , $ustid , $tel , $fax ) = @
$row ;
1244 if ( $cgiparams { 'oldcompname' } eq $comp ){
1245 $col = "style='background-color:yellow'" ;
1246 $col1 = "style='background-color:yellow'" ;
1248 if ( $type eq 'HOST' ){
1251 print "<tr><td width='50%' valign='top' align='center'>" ;
1253 print "</td><td width='50%' valign='top' align='center'>" ;
1256 <table style='width:90%;' cellspacing='0' class='tbl'>
1258 <th align='left' width='50%'> $Lang ::tr{'acct company'}</th>
1259 <th align='left' width='10%' > $Lang ::tr{'acct bank'}</th>
1260 <th width='38%' ></th>
1261 <th align='right' width='1%' style="PADDING: 0px">
1262 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1263 <input type='image' src='/images/edit.gif' alt= $Lang ::tr{'acct edit'} title=' $Lang ::tr{'acct edit'}' />
1264 <input type='hidden' name='ACTION' value='edit_addr'>
1265 <input type='hidden' name='rdo_companytype' value=' $type '>
1266 <input type='hidden' name='txt_company' value=' $comp '>
1267 <input type='hidden' name='txt_name1' value=' $name1 '>
1268 <input type='hidden' name='txt_str' value=' $str '>
1269 <input type='hidden' name='txt_str_nr' value=' $nr '>
1270 <input type='hidden' name='txt_plz' value=' $plz '>
1271 <input type='hidden' name='txt_city' value=' $city '>
1272 <input type='hidden' name='txt_bank' value=' $bank '>
1273 <input type='hidden' name='txt_iban' value=' $iban '>
1274 <input type='hidden' name='txt_bic' value=' $bic '>
1275 <input type='hidden' name='txt_blz' value=' $blz '>
1276 <input type='hidden' name='txt_kto' value=' $kto '>
1277 <input type='hidden' name='txt_email' value=' $email '>
1278 <input type='hidden' name='txt_inet' value=' $inet '>
1279 <input type='hidden' name='txt_hrb' value=' $hrb '>
1280 <input type='hidden' name='txt_ustid' value=' $ustid '>
1281 <input type='hidden' name='txt_tel' value=' $tel '>
1282 <input type='hidden' name='txt_fax' value=' $fax '>
1284 <th width='1%' style="PADDING: 0px">
1285 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1286 <input type='image' src='/images/delete.gif' alt= $Lang ::tr{'acct deladr'} title= $Lang ::tr{'acct deladr'} />
1287 <input type='hidden' name='txt_company' value=' $comp '>
1288 <input type='hidden' name='ACTION' value='del_addr'>
1293 <td $col ><b> $comp </b></td>
1295 <td colspan='3' $col1 ></td>
1298 <td $col > $name1 </td>
1299 <td $col1 width='35%'> $Lang ::tr{'acct bank'}</td>
1300 <td colspan='3' $col1 > $bank </td>
1304 <td $col1 > $Lang ::tr{'acct iban'}</td>
1305 <td colspan='3' $col1 > $iban </td>
1308 <td $col > $str $nr </td>
1309 <td $col1 > $Lang ::tr{'acct bic'}</td>
1310 <td colspan='3' $col1 > $bic </td>
1313 <td $col > $plz $city </td>
1314 <td $col1 > $Lang ::tr{'acct blz'}</td>
1315 <td colspan='3' $col1 > $blz </td>
1319 <td $col1 > $Lang ::tr{'acct kto'}</td>
1320 <td colspan='3' $col1 > $kto </td>
1332 print "<td width='50%' valign='top' align='center'></td></tr>" ;
1335 & Header
:: closebox
();
1337 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'acct exst_host_addr' } );
1338 print $Lang :: tr
{ 'acct host empty' };
1339 & Header
:: closebox
();
1341 #Show CUSTOMER Addresses if any
1344 #EXISTING CUSTOMER BOX
1345 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'acct exst_cust_addr' } );
1346 print "<table style='width:100%;'><tr>" ;
1347 foreach my $row ( @
$res ) {
1348 #SET colors for tablerows
1349 $col = "style='background-color: $color {'color22'}'" ;
1350 my ( $gr , $comp , $type , $name1 , $str , $nr , $plz , $city , $bank , $iban , $bic , $blz , $kto , $email , $inet , $hrb , $ustid , $tel , $fax ) = @
$row ;
1351 if ( $cgiparams { 'oldcompname' } eq $comp ){
1352 $col = "style='background-color:yellow'" ;
1354 if ( $type eq 'CUST' ){
1356 print "<td width='15%' valign='top' align='center'>" ;
1359 <table style='width:90%;' cellspacing='0' class='tbl'>
1362 $Lang ::tr{'acct company'}
1364 <th width='1%' style="PADDING: 0px">
1365 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1366 <input type='image' src='/images/edit.gif' alt=' $Lang ::tr{'acct edit'}' title=' $Lang ::tr{'acct edit'}' />
1367 <input type='hidden' name='ACTION' value='edit_addr'>
1368 <input type='hidden' name='rdo_companytype' value=' $type '>
1369 <input type='hidden' name='txt_company' value=' $comp '>
1370 <input type='hidden' name='txt_name1' value=' $name1 '>
1371 <input type='hidden' name='txt_str' value=' $str '>
1372 <input type='hidden' name='txt_str_nr' value=' $nr '>
1373 <input type='hidden' name='txt_plz' value=' $plz '>
1374 <input type='hidden' name='txt_city' value=' $city '>
1375 <input type='hidden' name='txt_bank' value=' $bank '>
1376 <input type='hidden' name='txt_iban' value=' $iban '>
1377 <input type='hidden' name='txt_bic' value=' $bic '>
1378 <input type='hidden' name='txt_blz' value=' $blz '>
1379 <input type='hidden' name='txt_kto' value=' $kto '>
1380 <input type='hidden' name='txt_email' value=' $email '>
1381 <input type='hidden' name='txt_inet' value=' $inet '>
1382 <input type='hidden' name='txt_hrb' value=' $hrb '>
1383 <input type='hidden' name='txt_ustid' value=' $ustid '>
1384 <input type='hidden' name='txt_tel' value=' $tel '>
1385 <input type='hidden' name='txt_fax' value=' $fax '>
1388 <th width='1%' style="padding: 0px">
1389 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1390 <input type='image' src='/images/delete.gif' alt= $Lang ::tr{'acct deladr'} title= $Lang ::tr{'acct deladr'} />
1391 <input type='hidden' name='ACTION' value='del_addr' />
1392 <input type='hidden' name='txt_company' value=' $comp ' />
1397 <td colspan='3' $col ><b> $comp </b></td>
1400 <td colspan='3' $col > $name1 </td>
1403 <td colspan='3' $col > $str $nr </td>
1406 <td colspan='3' $col > $plz $city </td>
1412 if (! ( $count % 3 )) {
1419 print "<td width='15%' valign='top' align='center'></td></tr>" ;
1422 & Header
:: closebox
();
1424 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'acct exst_cust_addr' } );
1425 print $Lang :: tr
{ 'acct cust empty' };
1426 & Header
:: closebox
();
1428 & Header
:: closebigbox
();
1429 & Header
:: closepage
();
1435 my $fieldvalue = $_ [ 1 ];
1436 my $errormessage = $_ [ 2 ];
1438 if (!& validtextfield
( $fieldvalue )){
1440 $errormessage .= " $Lang ::tr{'acct empty field'} $field <br>" ;
1442 $errormessage .= " $Lang ::tr{'acct invalid'} $field <br>" ;
1445 return $errormessage ;
1449 #Check if an address with the same name alread exists
1450 if ( $cgiparams { 'update' } ne 'on' ){
1451 my $res =& ACCT
:: getaddresses
;
1452 foreach my $row ( @
$res ) {
1453 my ( $anz , $name )= @
$row ;
1454 if ( $name eq $cgiparams { 'txt_company' }){
1455 $errormessage .= $Lang :: tr
{ 'acct companyexists' };
1460 $errormessage =& checkfield
( $Lang :: tr
{ 'acct company' }, $cgiparams { 'txt_company' }, $errormessage );
1463 if ( $cgiparams { 'txt_name1' }){
1464 $errormessage =& checkfield
( $Lang :: tr
{ 'acct name1' }, $cgiparams { 'txt_name1' }, $errormessage );
1468 if ( $cgiparams { 'txt_name2' }){
1469 $errormessage =& checkfield
( $Lang :: tr
{ 'acct name2' }, $cgiparams { 'txt_name2' }, $errormessage );
1473 $errormessage =& checkfield
( $Lang :: tr
{ 'acct str' }, $cgiparams { 'txt_str' }, $errormessage );
1476 if (! $cgiparams { 'txt_str_nr' }){
1477 $errormessage .= " $Lang ::tr{'acct empty field'} $Lang ::tr{'acct str_nr'}<br>" ;
1479 if (! & validalphanumfield
( $cgiparams { 'txt_str_nr' })){
1480 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct str_nr'}<br>" ;
1485 if (! $cgiparams { 'txt_plz' }){
1486 $errormessage .= " $Lang ::tr{'acct empty field'} $Lang ::tr{'acct plz'}<br>" ;
1488 if (! & validnumfield
( $cgiparams { 'txt_plz' })){
1489 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct plz'}<br>" ;
1494 $errormessage =& checkfield
( $Lang :: tr
{ 'acct city' }, $cgiparams { 'txt_city' }, $errormessage );
1497 if (! $cgiparams { 'txt_email' }){
1498 $errormessage .= " $Lang ::tr{'acct empty field'} $Lang ::tr{'acct email'}<br>" ;
1500 if (! & General
:: validemail
( $cgiparams { 'txt_email' })){
1501 $errormessage .= "<br> $Lang ::tr{'acct invalid'} $Lang ::tr{'acct email'}" ;
1505 #Check all fields required for companytype "HOST"
1506 if ( $cgiparams { 'rdo_companytype' } eq 'HOST' ){
1508 $errormessage =& checkfield
( $Lang :: tr
{ 'acct bank' }, $cgiparams { 'txt_bank' }, $errormessage );
1510 #Check IBAN - optional
1511 if ( $cgiparams { 'txt_iban' }){
1512 if (!& validalphanumfield
( $cgiparams { 'txt_iban' })){
1513 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct iban'}<br>" ;
1516 if ( $cgiparams { 'txt_bic' }){
1517 if (!& validalphanumfield
( $cgiparams { 'txt_bic' })){
1518 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct bic'}<br>" ;
1521 if (( $cgiparams { 'txt_iban' } && $cgiparams { 'txt_blz' })||(! $cgiparams { 'txt_iban' } && $cgiparams { 'txt_blz' })){
1523 if (! & validnumfield
( $cgiparams { 'txt_blz' })){
1524 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct blz'}<br>" ;
1527 if ( $cgiparams { 'txt_kto' }){
1528 if (! & validnumfield
( $cgiparams { 'txt_kto' })){
1529 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct kto'}<br>" ;
1531 } elsif (! $cgiparams { 'txt_kto' }){
1532 $errormessage .= " $Lang ::tr{'acct empty field'} $Lang ::tr{'acct kto'}<br>" ;
1534 } elsif (! $cgiparams { 'txt_iban' } && ! $cgiparams { 'txt_blz' }){
1535 $errormessage .= " $Lang ::tr{'acct empty field'} $Lang ::tr{'acct blz'}<br>" ;
1537 if ( $cgiparams { 'txt_kto' }){
1538 if (! & validnumfield
( $cgiparams { 'txt_kto' })){
1539 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct kto'}<br>" ;
1541 } elsif (! $cgiparams { 'txt_kto' }){
1542 $errormessage .= " $Lang ::tr{'acct empty field'} $Lang ::tr{'acct kto'}<br>" ;
1547 if ( $cgiparams { 'txt_inet' }){
1548 if ( $cgiparams { 'txt_inet' } =~ m/([a-z]+:\/ \
/)??([a-z0-9\-]+\.){1}(([a-z0-9\-]+\.){0,})([a-z0-9\-]+){1}/o ) {
1549 $cgiparams { 'txt_inet' }= $2 . $3 . $5 ;
1551 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct inet'}<br>" ;
1555 if ( $cgiparams { 'txt_hrb' }){
1556 $errormessage =& checkfield
( $Lang :: tr
{ 'acct hrb' }, $cgiparams { 'txt_hrb' }, $errormessage );
1562 if ( $cgiparams { 'txt_tel' }){
1563 if (!& validphonefield
( $cgiparams { 'txt_tel' })){
1564 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct tel'}<br>" ;
1568 return $errormessage ;
1572 if (- f
"${General::swroot}/proxy/enable" ){
1573 $proxsrv = $Lang :: tr
{ 'running' };
1575 $proxsrv = $Lang :: tr
{ 'stopped' };
1577 my $srce = "${General::swroot}/proxy/squid.conf" ;
1578 my $string1 = 'access\.log' ;
1580 while ( my $line = < FH
>) {
1581 if ( $line =~ m/$string1/ ) {
1582 $proxlog = $Lang :: tr
{ 'running' };
1590 #GET: Input from a Textfield
1591 #GIVES: True if valid, false if not valid
1594 # Each part should be at least two characters in length
1595 # but no more than 63 characters
1596 if ( length ( $remark ) < 1 || length ( $remark ) > 255 ) {
1598 # Only valid characters are a-z, A-Z, 0-9 and -
1599 if ( $remark !~ /^[a-zĆ¤Ć¶Ć¼A-ZĆĆĆ0-9-.:;\&\|\Ć_()\/ \s
]*$/) {
1601 # First character can only be a letter or a digit
1602 if ( substr ( $remark , 0 , 1 ) !~ /^[a-zĆ¤Ć¶Ć¼A-ZĆĆĆ0-9(]*$/ ) {
1604 # Last character can only be a letter or a digit
1605 if ( substr ( $remark , - 1 , 1 ) !~ /^[a-zĆ¶Ć¤Ć¼A-ZĆĆĆ0-9.:;_)]*$/ ) {
1611 #GET: Input from a numeric field
1612 #GIVES: True if valid, false if not valid
1615 # Each part should be at least two characters in length
1616 # but no more than 63 characters
1617 if ( length ( $num ) < 1 || length ( $num ) > 255 ) {
1619 # Only valid characters are a-z, A-Z, 0-9 and -
1620 if ( $num !~ /^[0-9.]*$/ ) {
1622 # First character can only be a letter or a digit
1623 if ( substr ( $num , 0 , 1 ) !~ /^[0-9]*$/ ) {
1625 # Last character can only be a letter or a digit
1626 if ( substr ( $num , - 1 , 1 ) !~ /^[0-9]*$/ ) {
1631 sub validphonefield
{
1632 #GET: Input from a numeric field
1633 #GIVES: True if valid, false if not valid
1636 # Each part should be at least two characters in length
1637 # but no more than 63 characters
1638 if ( length ( $num ) < 1 || length ( $num ) > 255 ) {
1640 # Only valid characters are a-z, A-Z, 0-9 and -
1641 if ( $num !~ /^[0-9-()\+ ]*$/ ) {
1643 # First character can only be a letter or a digit
1644 if ( substr ( $num , 0 , 1 ) !~ /^[0-9(\+]*$/ ) {
1646 # Last character can only be a digit
1647 if ( substr ( $num , - 1 , 1 ) !~ /^[0-9]*$/ ) {
1652 sub validalphanumfield
{
1653 #GET: Input from a numeric field
1654 #GIVES: True if valid, false if not valid
1657 # Each part should be at least two characters in length
1658 # but no more than 63 characters
1659 if ( length ( $remark ) < 1 || length ( $remark ) > 255 ) {
1661 # Only valid characters are a-z, A-Z, 0-9 and -
1662 if ( $remark !~ /^[0-9a-zA-Z]*$/ ) {
1664 # First character can only be a letter or a digit
1665 if ( substr ( $remark , 0 , 1 ) !~ /^[0-9A-Za-z]*$/ ) {
1667 # Last character can only be a letter or a digit
1668 if ( substr ( $remark , - 1 , 1 ) !~ /^[0-9a-zA-Z]*$/ ) {
1674 if ( $errormessage ) {
1675 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
1676 print "<class name='base'> $errormessage \n " ;
1677 print " </class> \n " ;
1678 & Header
:: closebox
();
1683 & Header
:: openpage
( " $Lang ::tr{'acct billgroup'}" , 1 , '' );
1684 & Header
:: openbigbox
( '100%' , 'center' );
1692 #Get addresses from DB
1693 my $res = & ACCT
:: getaddresses
;
1694 #Check if we need to show NEW-BillGROUP-BOX or Hint
1695 foreach my $row ( @
$res ) {
1696 my ( $gr , $comp , $type , $name1 , $str , $nr , $plz , $city , $bank , $iban , $bic , $blz , $kto , $email , $inet , $hrb , $ust , $tel , $fax , $ccmail ) = @
$row ;
1699 $ccmailrcpt = $ccmail ;
1700 if ( $type eq 'HOST' ){
1703 if ( $type eq 'CUST' ){
1707 if ( $host && $cust ){
1709 if (! $cgiparams { 'txt_ccmail' }){
1710 $cgiparams { 'txt_ccmail' }= $ccmailrcpt ;
1712 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'acct edit_addr'}" );
1714 <form method='post' action=' $ENV {'SCRIPT_NAME'}' ENCTYPE='multipart/form-data'>
1715 <table style='width:100%;'>
1717 <td style='width: 22em;'> $Lang ::tr{'name'}</td>
1718 <td><input type='text' name='txt_billgroup' value=' $cgiparams {'txt_billgroup'}' style='width: 24em;'></td>
1724 <td valign='top'> $Lang ::tr{'acct billtext1'}<img src='/blob.gif' alt='*' /></td>
1725 <td><textarea name='txt_billtext1' cols='40' rows='5' style='width: 24em;' maxlength='300'> $cgiparams {'txt_billtext1'}</textarea></td>
1727 <tr><td><br></td></tr>
1729 #Print Dropdown Menu for HOSTER and CUSTOMER
1730 print "<tr><td> $Lang ::tr{'acct hoster'}</td><td><select name='dd_host' style='width: 24.3em;'>" ;
1731 foreach my $row ( @
$res ) {
1732 my ( $gr , $comp , $type ) = @
$row ;
1733 if ( $type eq 'HOST' ){
1734 if ( $cgiparams { 'dd_host' } eq $comp ){
1735 print "<option selected> $comp </option>" ;
1737 print "<option> $comp </option>" ;
1741 print "</select></td></tr><tr><td><br></td></tr>" ;
1742 print "<tr><td> $Lang ::tr{'acct customer'}</td><td><select name='dd_cust' style='width: 24.3em;'>" ;
1743 foreach my $row ( @
$res ) {
1744 my ( $gr , $comp , $type ) = @
$row ;
1745 if ( $type eq 'CUST' ){
1746 if ( $cgiparams { 'dd_cust' } eq $comp ){
1747 print "<option selected> $comp </option>" ;
1749 print "<option> $comp </option>" ;
1753 print "</select></td></tr>" ;
1754 print "<tr><td><br></td></tr>" ;
1755 #Print multiselectbox for hosts/users which should be part of this group
1756 my $hosts =& ACCT
:: gethosts
;
1757 print "<tr><td valign='top'> $Lang ::tr{'acct members'}</td><td><select name='sel_hosts' multiple size='8' style='width: 24em;' >" ;
1758 #If update, split $cgiparams{'sel_hosts'} and preselect values from selectbox
1759 if ( $cgiparams { 'update' } eq 'on' ){
1760 $cgiparams { 'oldname' }= $cgiparams { 'txt_billgroup' };
1761 @oldhosts = split ( /\|/ , $cgiparams { 'sel_hosts' });
1763 foreach my $row ( @
$hosts ) {
1766 foreach my $old ( @oldhosts ){
1772 print "<option selected> $val </option>" ;
1774 print "<option> $val </option>" ;
1777 print "</select></td></tr>" ;
1778 print "<tr><td><br></td></tr>" ;
1779 #set right decimal seperator for cent value
1780 setlocale
( LC_NUMERIC
, " $mainsettings {'LANGUAGE'}_ $uplang " );
1781 my $val = sprintf "%.3f" , $cgiparams { 'txt_cent' };
1782 print "<tr><td> $Lang ::tr{'acct cent'}</td><td><input type='text' name='txt_cent' value=' $val ' size='3'> $settings {'CURRENCY'} </td></tr>" ;
1784 print "<tr><td colspan='2' align='left'><img src='/blob.gif' alt='*' /><font size='1'> $Lang ::tr{'acct optional'}</font></td></tr>" ;
1785 print "<tr><td colspan='2' align='right'><br><br>" ;
1786 print "</td></tr></table>" ;
1788 #LOGO Upload if update eq 'on'
1789 if ( $cgiparams { 'update' } eq 'on' ){
1791 <table style='width:100%;'>
1793 <td style='width: 22em;'> $Lang ::tr{'acct logo upload'}</td>
1794 <td><INPUT TYPE="file" NAME="uploaded_file" SIZE=30 MAXLENGTH=80></td>
1795 <input type='hidden' name='logo_grp' value=' $cgiparams {'txt_billgroup'}' />
1798 <td><br> $Lang ::tr{'acct logo'}</td>
1800 #Show Logo in webinterface with 1/2 size if set
1801 if (- f
" $logopath / $cgiparams {'txt_billgroup'}/logo.png" ){
1802 print "<td><img src='/accounting/logo/ $cgiparams {'txt_billgroup'}/logo.png' alt=' $logopath / $cgiparams {'txt_billgroup'}/logo.png' width='25%' height='25%' /></td></tr>" ;
1804 print "<td><br> $Lang ::tr{'no'}</td></tr>" ;
1806 #Show optional CC Mailadresses
1809 <td><br> $Lang ::tr{'acct mailrcpt'}</td>
1810 <td><br> $mailrcpt </td>
1813 <td><br> $Lang ::tr{'acct ccmail'}</td>
1814 <td><br><input type='text' name='txt_ccmail' value=' $cgiparams {'txt_ccmail'}' style='width: 24.3em;'></td>
1822 print "<table style='width:100%;'><tr><td align='right'>" ;
1823 #Print SAVE or EDIT Button
1824 if ( $cgiparams { 'update' } eq 'on' ){
1825 print "<input type='submit' name='BILLACTION' value=' $Lang ::tr{'update'}'>" ;
1826 print "<input type='hidden' name='oldname' value=' $cgiparams {'oldname'}'>" ;
1827 print "<input type='hidden' name='oldccmail' value=' $ccmailrcpt '>" ;
1829 print "<input type='submit' name='BILLACTION' value=' $Lang ::tr{'save'}'>" ;
1831 print "</td></tr></table><br></form><br>" ;
1832 & Header
:: closebox
();
1835 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1836 <table style='width:100%;'>
1839 <input type='submit' name='ACTION' value=' $Lang ::tr{'back'}'>
1845 #Show Box for fixed positions if update
1846 if ( $cgiparams { 'update' } eq 'on' ){
1847 & viewtablebillpos
( $cgiparams { 'txt_billgroup' });
1850 & viewtablebillgroups
;
1854 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'hint'}" );
1855 print " $Lang ::tr{'acct hint billgrp'}" ;
1856 & Header
:: closebox
();
1859 <table style='width:100%;'>
1861 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1862 <td align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'back'}'></td>
1868 & Header
:: closebigbox
();
1869 & Header
:: closepage
();
1873 sub viewtablebillgroups
{
1875 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'acct billgroup'}" );
1876 #Get DATA from table BILLINGGRP
1877 my $res = & ACCT
:: getbillgroups
;
1879 #Print table billinggroup
1881 <table style='width:100%;' cellspacing='0' class='tbl'>
1883 <th align='left'> $Lang ::tr{'name'}</th>
1884 <th align='left'> $Lang ::tr{'acct hoster'}</th>
1885 <th align='left'> $Lang ::tr{'acct customer'}</th>
1886 <th align='left'> $Lang ::tr{'acct members'}</th>
1887 <th align='left' colspan='5'></th>
1890 foreach my $line ( @
$res ){
1893 $col = "style='background-color: $color {'color22'}'" ;
1895 $col = "style='background-color: $color {'color20'}'" ;
1897 my ( $name , $host , $cust , $txt , $amount , $cent ) = @
$line ;
1903 <td $col > $amount </td>
1904 <td width='1%' $col >
1906 my $members =& ACCT
:: listhosts
( $name );
1907 my @mem = split ( /\|/ , $members );
1909 foreach my $m ( @mem ){
1912 print "<img src='/images/computer.png' alt= $Lang ::tr{'acct members'} title='" . $msg . "' /></td>" ;
1915 <td width='1%' $col >
1916 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1917 <input type='image' src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' title=' $Lang ::tr{'edit'}' />
1918 <input type='hidden' name='BILLACTION' value='edit_billgroup'>
1919 <input type='hidden' name='txt_billgroup' value=' $name '>
1920 <input type='hidden' name='txt_billtext1' value=' $txt '>
1921 <input type='hidden' name='dd_host' value=' $host '>
1922 <input type='hidden' name='dd_cust' value=' $cust '>
1923 <input type='hidden' name='sel_hosts' value=' $members '>
1924 <input type='hidden' name='txt_cent' value=' $cent '>
1928 <td width='1%' $col >
1929 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1930 <input type='image' src='/images/folder-open.png' alt=' $Lang ::tr{'edit'}' title=' $Lang ::tr{'acct billarchive'}' />
1931 <input type='hidden' name='BILLACTION' value='open_billgroup'>
1932 <input type='hidden' name='txt_billgroup' value=' $name '>
1936 <td width='1%' $col >
1937 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1938 <input type='image' src='/images/document-new.png' alt=' $Lang ::tr{'acct preview'}' title=' $Lang ::tr{'acct preview'}' />
1939 <input type='hidden' name='BILLACTION' value='open_preview'>
1940 <input type='hidden' name='txt_billgroup' value=' $name '>
1943 <td width='1%' $col >
1944 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1945 <input type='image' src='/images/delete.gif' alt= $Lang ::tr{'delete'} title=" $Lang ::tr{'delete'}" />
1946 <input type='hidden' name='BILLACTION' value='delete_billgroup'>
1947 <input type='hidden' name='txt_billgroup' value=' $name '>
1955 & Header
:: closebox
();
1959 $dbh =& ACCT
:: connectdb
;
1960 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'acct hosts' });
1963 my ( $from , $till )=& ACCT
:: getmonth
( $mon , $year );
1965 #Menu to display another month
1967 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1968 <table style='width:100%;'>
1970 <td style='width:5%; text-align:center;'> $Lang ::tr{'acct month'}</td>
1971 <td style='width:10%; text-align: center;'> $Lang ::tr{'acct year'}</td>
1975 <td><select name='month'>
1977 for ( my $i = 1 ; $i < 13 ; $i ++){
1979 print "<option selected> $i </option>" ;
1981 print "<option> $i </option>" ;
1986 <td style='text-align: center;'><select name='year'>
1988 for ( my $j = 2014 ; $j <=( $year ); $j ++){
1990 print "<option selected> $j </option>" ;
1992 print "<option> $j </option>" ;
1997 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'acct view'}'></td>
2002 #View table with all hosts
2004 <table style='width:100%;' class='tbl'>
2006 <th> $Lang ::tr{'name'}</th>
2007 <th> $Lang ::tr{'acct traffic'}</th>
2008 <th> $Lang ::tr{'from'}</th>
2009 <th> $Lang ::tr{'to'}</th>
2013 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;" );
2018 foreach my $row ( @
$res ) {
2023 $col = "background-color: $color {'color22'};" ;
2025 $col = "background-color: $color {'color20'};" ;
2027 my ( $bytes , $mintime , $maxtime , $name ) = @
$row ;
2029 ( $lineval , $type ) = & calcbytes
( $bytes );
2031 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>" ;
2034 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2035 <input type='image' src='/images/utilities-system-monitor.png' alt=" $Lang ::tr{'status'}" title=" $Lang ::tr{'status'}" />
2036 <input type='hidden' name='ACTION' value='viewgraph'>
2037 <input type='hidden' name='host' value=' $name '>
2038 <input type='hidden' name='month' value=' $mon '>
2039 <input type='hidden' name='year' value=' $year '>
2040 <input type='hidden' name='traffic' value=" $Lang ::tr{'acct sum'} $Lang ::tr{'acct traffic'} $lineval $type ">
2048 print "<tr><td colspan='5'><center> $Lang ::tr{'acct no data'}</td></tr>" ;
2051 & Header
:: closebox
();
2055 sub viewtablebillpos
{
2057 #BOX for extra billpositions
2058 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'acct fix billpos'} $grp " );
2059 #Table for optional billpositions
2061 <center><table style='width:65%' cellspacing='0' class='tbl' border='0'>
2063 <th align='left'> $Lang ::tr{'acct amount'}</th>
2064 <th align='left' style='padding-left:1.2em'> $Lang ::tr{'acct name'}</th>
2065 <th align='left'> $Lang ::tr{'acct price pp'}</th>
2069 #Fill Table for extra billpositions if any
2070 if ( $cgiparams { 'update' } eq 'on' ){
2071 my $res = & ACCT
:: getextrabillpos
( $cgiparams { 'txt_billgroup' });
2073 foreach my $line ( @
$res ){
2076 $col = "style='background-color: $color {'color22'}'" ;
2078 $col = "style='background-color: $color {'color20'}'" ;
2080 my ( $grp , $amnt , $pos , $price ) = @
$line ;
2081 setlocale
( LC_NUMERIC
, " $mainsettings {'LANGUAGE'}_ $uplang " );
2082 my $locale_price = sprintf "%.2f" , $price ;
2083 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>" ;
2084 print "<td $col ><input type='image' src='/images/delete.gif' alt= $Lang ::tr{'delete'} title= $Lang ::tr{'delete'} >" ;
2085 print "<input type='hidden' name='BILLPOS' value='delpos'>" ;
2086 print "<input type='hidden' name='txt_billgroup' value=' $grp '>" ;
2087 print "<input type='hidden' name='txt_billpos' value=' $pos '></form></tr>" ;
2093 <td ><form method='post' action=' $ENV {'SCRIPT_NAME'}'><input type='text' name='txt_amount' value=' $cgiparams {'txt_amount'}' size='3'></td>
2094 <td><input type='text' name='txt_name' value=' $cgiparams {'txt_name'}' size='40'></td>
2095 <td ><input type='text' name='txt_price' value=' $cgiparams {'txt_price'}' size='6'></td>
2099 <table style='width:100%'>
2101 <td align='right'><input type='submit' name='BILLPOS' value=' $Lang ::tr{'save'}'></td>
2102 <input type='hidden' name='txt_billgroup' value=' $grp '>
2108 & Header
:: closebox
();
2116 & Header
:: openpage
( $Lang :: tr
{ 'acct billoverview' }, 1 , '' );
2117 & Header
:: openbigbox
( '100%' , 'center' );
2118 & Header
:: openbox
( '100%' , 'left' , $grp );
2119 my $res =& ACCT
:: getbills
( $grp );
2123 <table style='width:100%' cellspacing='0' class='tbl' border='0'>
2125 <th> $Lang ::tr{'acct nr'}</th>
2126 <th> $Lang ::tr{'acct path'}</th>
2127 <th> $Lang ::tr{'name'}</th>
2128 <th> $Lang ::tr{'acct generated'}</th>
2133 foreach my $row ( @
$res ){
2136 $col = "style='background-color: $color {'color22'}'" ;
2138 $col = "style='background-color: $color {'color20'}'" ;
2140 my ( $no , $path , $name , $date , $dbgrp ) = @
$row ;
2142 print "<tr><td $col > $no </td><td $col > $path </td><td $col > $name </td><td $col > $date </td><td $col >" ;
2143 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'}' />" ;
2144 print "<input type='hidden' name='BILLVIEW' value='show'>" ;
2145 my $file = " $path / $name " ;
2146 print "<input type='hidden' name='file' value=' $file '>" ;
2147 print "<input type='hidden' name='name' value=' $name '>" ;
2148 print "</form></td></tr>" ;
2150 print "</table><br>" ;
2152 print "<center> $Lang ::tr{'acct no data'}" ;
2154 & Header
:: closebox
();
2158 <table style='width:100%'>
2160 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2161 <td align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'back'}'></td>
2166 & Header
:: closebigbox
();
2167 & Header
:: closepage
();
2171 sub checkmailsettings
{
2172 #Check if mailserver is an ip address or a domain
2173 if ( $cgiparams { 'txt_mailserver' } =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/ ){
2174 if (! & General
:: validip
( $cgiparams { 'txt_mailserver' })){
2175 $errormessage .= " $Lang ::tr{'acct invalid mailip'} $cgiparams {'txt_mailserver'}<br>" ;
2177 } elsif (! & General
:: validfqdn
( $cgiparams { 'txt_mailserver' })){
2178 $errormessage .= " $Lang ::tr{'acct invalid mailfqdn'} $cgiparams {'txt_mailserver'}<br>" ;
2180 #Check valid mailserverport
2181 if ( $cgiparams { 'txt_mailport' } < 1 || $cgiparams { 'txt_mailport' } > 65535 ){
2182 $errormessage .= " $Lang ::tr{'acct invalid mailport'} $cgiparams {'txt_mailport'}<br>" ;
2185 if (! $cgiparams { 'txt_mailsender' }){
2186 $errormessage .= " $Lang ::tr{'acct empty field'} $Lang ::tr{'acct mailsender'}<br>" ;
2188 if (! & General
:: validemail
( $cgiparams { 'txt_mailsender' })){
2189 $errormessage .= "<br> $Lang ::tr{'acct invalid'} $Lang ::tr{'acct mailsender'}<br>" ;
2192 return $errormessage ;