]>
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' };
59 my $mailfile = "${General::swroot}/dma/mail.conf" ;
61 & Header
:: getcgihash
( \
%cgiparams );
62 & General
:: readhash
( "${General::swroot}/main/settings" , \
%mainsettings );
63 & General
:: readhash
( "/srv/web/ipfire/html/themes/" . $mainsettings { 'THEME' }. "/include/colors.txt" , \
%color );
64 & General
:: readhash
( " $settingsfile " , \
%settings ) if (- f
$settingsfile );
67 & General
:: readhash
( $mailfile , \
%mail );
70 #Find out which lang is set (used later to set decimal separator correctly)
71 my $uplang = uc ( $mainsettings { 'LANGUAGE' });
72 setlocale LC_NUMERIC
, " $mainsettings {'LANGUAGE'}_ $uplang " ;
74 if ( $cgiparams { 'BILLVIEW' } eq "show" ){
75 my $file = $cgiparams { 'file' };
76 my $name = $cgiparams { 'name' };
77 open ( DLFILE
, "< $file " ) or die "Unable to open $file : $!" ;
78 my @fileholder = < DLFILE
>;
79 print "Content-Type:application/pdf \n " ;
80 my @fileinfo = stat ( " $file " );
81 print "Content-Length: $fileinfo [7] \n " ;
82 print "Content-Disposition:attachment;filename=' $name '; \n\n " ;
86 if ( $cgiparams { 'BILLACTION' } eq "open_preview" ){
87 #Generate preview Bill
88 my $rggrp = $cgiparams { 'txt_billgroup' };
89 my $address_cust = & ACCT
:: getTaAddress
( $rggrp , 'CUST' );
90 my $address_host = & ACCT
:: getTaAddress
( $rggrp , 'HOST' );
91 my $billpos = & ACCT
:: getextrabillpos
( $rggrp );
92 my $mwst = $settings { 'MWST' };
93 my $cur = $settings { 'CURRENCY' };
94 my @now = localtime ( time );
95 $now [ 5 ] = $now [ 5 ] + 1900 ;
96 my $actmonth = $now [ 4 ]+ 1 ;
97 my $actyear = $now [ 5 ];
98 my ( $from , $till )=& ACCT
:: getmonth
( $actmonth , $actyear );
99 my @billar = & ACCT
:: GetTaValues
( $from , $till , $rggrp );
100 my $tempfile =& ACCT
:: pdf2
( \
@billar , $actmonth , $actyear , $mwst , $address_cust , $address_host , $billpos , $rggrp , $cur , "on" );
102 open ( DLFILE
, "< $tempfile " ) or die "Unable to open tmp.pdf: $!" ;
103 my @fileholder = < DLFILE
>;
104 print "Content-Type:application/pdf \n " ;
105 my @fileinfo = stat ( $tempfile );
106 print "Content-Length: $fileinfo [7] \n " ;
107 print "Content-Disposition:attachment;filename='tmp.pdf'; \n\n " ;
113 & Header
:: showhttpheaders
();
115 if ( $cgiparams { 'ACTION' } eq " $Lang ::tr{'acct config'}" ){ #ConfigButton from Menu
118 if ( $cgiparams { 'ACTION' } eq " $Lang ::tr{'acct addresses'}" ){ #AddressmgmntButton from Menu
121 if ( $cgiparams { 'ACTION' } eq " $Lang ::tr{'acct billgroup'}" ){ #BillgroupButton from Menu
124 if ( $cgiparams { 'ACTION' } eq " $Lang ::tr{'acct maintenance'}" ){ #MaintenanceButton from Menu
127 if ( $cgiparams { 'ACTION' } eq " $Lang ::tr{'save'}" ){ #SaveButton on configsite
128 my @val = split ( ' \r\n ' , $cgiparams { 'txt_skipurls' });
130 foreach my $line ( @val ){
131 $skipurls .= "|" . $line ;
133 $skipurls = $skipurls . "|" ;
134 $skipurls =~ s/\|\|/\|/g ;
135 my @txt = split ( ' \r\n ' , $cgiparams { 'txt_mailtxt' });
137 foreach my $txt ( @txt ){
141 if ( $cgiparams { 'USEMAIL' } eq 'on' ){
142 $errormessage =& checkmailsettings
;
143 } elsif ( $cgiparams { 'USEMAIL' } ne 'on' ){
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 { 'MAILSENDER' } = $cgiparams { 'txt_mailsender' };
159 $settings { 'MAILSUB' } = $cgiparams { 'txt_mailsubject' };
160 $settings { 'MAILTXT' } = $mailtxt ;
161 & General
:: writehash
( " $settingsfile " , \
%settings );
163 $cgiparams { 'update' }= 'on' ;
167 if ( $cgiparams { 'ACTION' } eq " $Lang ::tr{'acct view'}" ){ #If special month and year is given on mainsite
168 & mainsite
( $cgiparams { 'month' }, $cgiparams { 'year' });
171 if ( $cgiparams { 'ACTION' } eq " $Lang ::tr{'acct commit'}" ){ #Maintenance function
172 & ACCT
:: logger
( $settings { 'LOG' }, "Clear DB (all data) committed). \n " );
176 if ( $cgiparams { 'ACTION2' } eq " $Lang ::tr{'acct commit'}" ){ #Maintenance function
177 & ACCT
:: logger
( $settings { 'LOG' }, "Clear DB (only traffic data) committed). \n " );
181 if ( $cgiparams { 'ACTION1' } eq " $Lang ::tr{'acct commit'}" ){ #Maintenance Function
183 my ( $a , $b )=& ACCT
:: getmonth
( $cgiparams { 'expmonth' }, $cgiparams { 'expyear' });
184 & ACCT
:: delbefore
(( $a - 1 ));
187 if ( $cgiparams { 'ACTION' } eq "viewgraph" ){ #Graph icon on hosttable (viewhosttable)
188 & graphsite
( $cgiparams { 'month' }, $cgiparams { 'year' }, $cgiparams { 'host' });
190 if ( $cgiparams { 'ACTION1' } eq " $Lang ::tr{'save'}" ){ #SaveButton when adding Address
191 $errormessage =& checkaddress
;
194 & addressmgmnt
( $errormessage );
197 $cgiparams { 'txt_company' },
198 $cgiparams { 'rdo_companytype' },
199 $cgiparams { 'txt_name1' },
200 $cgiparams { 'txt_str' },
201 $cgiparams { 'txt_str_nr' },
202 $cgiparams { 'txt_plz' },
203 $cgiparams { 'txt_city' },
204 $cgiparams { 'txt_bank' },
205 $cgiparams { 'txt_iban' },
206 $cgiparams { 'txt_bic' },
207 $cgiparams { 'txt_blz' },
208 $cgiparams { 'txt_kto' },
209 $cgiparams { 'txt_email' },
210 $cgiparams { 'txt_inet' },
211 $cgiparams { 'txt_hrb' },
212 $cgiparams { 'txt_ustid' },
213 $cgiparams { 'txt_tel' },
214 $cgiparams { 'txt_fax' },
216 & ACCT
:: logger
( $settings { 'LOG' }, "Created new address $cgiparams {'txt_company'} as $cgiparams {'rdo_companytype'}. \n " );
221 if ( $cgiparams { 'ACTION' } eq "edit_addr" ){ #Pencil icon in Address overwiev on Addressmgmnt site
222 $cgiparams { 'update' } = 'on' ;
223 $cgiparams { 'oldcompname' }= $cgiparams { 'txt_company' };
226 if ( $cgiparams { 'ACTION' } eq " $Lang ::tr{'update'}" ){ #UpdateButton when editing Address
227 $cgiparams { 'update' } = 'on' ;
228 $errormessage =& checkaddress
;
230 & addressmgmnt
( $errormessage );
233 $cgiparams { 'rdo_companytype' },
234 $cgiparams { 'txt_company' },
235 $cgiparams { 'txt_name1' },
236 $cgiparams { 'txt_str' },
237 $cgiparams { 'txt_str_nr' },
238 $cgiparams { 'txt_plz' },
239 $cgiparams { 'txt_city' },
240 $cgiparams { 'txt_bank' },
241 $cgiparams { 'txt_iban' },
242 $cgiparams { 'txt_bic' },
243 $cgiparams { 'txt_blz' },
244 $cgiparams { 'txt_kto' },
245 $cgiparams { 'txt_email' },
246 $cgiparams { 'txt_inet' },
247 $cgiparams { 'txt_hrb' },
248 $cgiparams { 'txt_ustid' },
249 $cgiparams { 'txt_tel' },
250 $cgiparams { 'txt_fax' },
251 $cgiparams { 'oldcompname' }
253 my $res =& ACCT
:: getbillgroups
;
254 foreach my $line ( @
$res ){
255 my ( $name , $host , $cust )= @
$line ;
256 if ( $host eq $cgiparams { 'oldcompname' }){
257 & ACCT
:: updatebillgrouphost
( $cgiparams { 'oldcompname' }, $cgiparams { 'txt_company' });
258 } elsif ( $cust eq $cgiparams { 'oldcompname' }){
259 & ACCT
:: updatebillgroupcust
( $cgiparams { 'oldcompname' }, $cgiparams { 'txt_company' });
263 & ACCT
:: logger
( $settings { 'LOG' }, "Edited address $cgiparams {'oldcompname'}. \n " );
268 if ( $cgiparams { 'ACTION' } eq "del_addr" ){ #Trash icon in Address overview on Addressmgmnt site
269 my $res =& ACCT
:: checkbillgrp
;
270 foreach my $line ( @
$res ){
271 my ( $grp , $host , $cust ) = @
$line ;
272 if ( $cgiparams { 'txt_company' } eq $host ){
273 $errormessage = " $Lang ::tr{'acct err hostdel'} $grp " ;
275 if ( $cgiparams { 'txt_company' } eq $cust ){
276 $errormessage = " $Lang ::tr{'acct err custdel'} $grp " ;
279 if (! $errormessage ){
280 & ACCT
:: deladdr
( $cgiparams { 'txt_company' });
281 & ACCT
:: logger
( $settings { 'LOG' }, "Deleted address $cgiparams {'txt_company'}. \n " );
283 $cgiparams { 'txt_company' }= '' ;
286 if ( $cgiparams { 'BILLACTION' } eq " $Lang ::tr{'save'}" ){ #SaveButton when adding BillingGroups
287 #check if a group with the same name already exists in DB
288 my $res =& ACCT
:: getbillgroups
;
289 foreach my $row ( @
$res ) {
291 if ( $group eq $cgiparams { 'txt_billgroup' }){
292 $errormessage .= $Lang :: tr
{ 'acct billgroupexists' };
295 #Check if a selected user is in another group already
296 if ( $settings { 'MULTIUSER' } ne 'on' ){
297 #split hosts into array
298 my @user = split ( /\|/ , $cgiparams { 'sel_hosts' });
299 my $res =& ACCT
:: checkusergrp
;
300 foreach my $val ( @
$res ){
301 my ( $grp , $usr )= @
$val ;
302 foreach my $wanted ( @user ){
304 $errormessage .= " $usr $Lang ::tr{'acct usermulti'} $grp <br>" ;
310 if (!& validtextfield
( $cgiparams { 'txt_billgroup' })){
311 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'name'}<br>" ;
313 #FIXME: Validate CENT amount (num with .)
314 #if used colon, replace with .
315 $cgiparams { 'txt_cent' } =~ tr/,/./ ;
316 if (!& validnumfield
( $cgiparams { 'txt_cent' })){
317 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct cent'}<br>" ;
320 my @ips = split ( /\|/ , $cgiparams { 'sel_hosts' });
322 #Check if we use extra bill positions
323 if ( $cgiparams { 'txt_amount' } || $cgiparams { 'txt_name' }|| $cgiparams { 'txt_price' }){
324 if (! $cgiparams { 'txt_amount' } || ! $cgiparams { 'txt_name' } || ! $cgiparams { 'txt_price' }){
325 $errormessage .= " $Lang ::tr{'acct invalid billpos'}<br>" ;
329 if (! & validnumfield
( $cgiparams { 'txt_amount' })){
330 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct amount'}<br>" ;
331 } elsif (! & validtextfield
( $cgiparams { 'txt_name' })){
332 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct name'}<br>" ;
333 } elsif (! & validnumfield
( $cgiparams { 'txt_price' })){
334 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct price pp'}<br>" ;
340 & billgroupsite
( $errormessage );
342 #check if we use extra positions
343 if ( $cgiparams { 'txt_amount' }){
345 $cgiparams { 'txt_posbillgroup' },
346 $cgiparams { 'txt_amount' },
347 $cgiparams { 'txt_name' },
348 $cgiparams { 'txt_price' });
349 & ACCT
:: logger
( $settings { 'LOG' }, "Saved new fixed billposition $cgiparams {'txt_name'} into billgroup $cgiparams {'txt_posbillgroup'} . \n " );
353 & ACCT
:: savebillgroup
(
354 $cgiparams { 'txt_billgroup' },
355 $cgiparams { 'txt_billtext1' },
356 $cgiparams { 'dd_host' },
357 $cgiparams { 'dd_cust' },
358 $cgiparams { 'txt_cent' },
360 & ACCT
:: logger
( $settings { 'LOG' }, "Saved new billgroup $cgiparams {'txt_billgroup'}. \n " );
365 if ( $cgiparams { 'BILLACTION' } eq " $Lang ::tr{'update'}" ){ #UpdateButton when editing BillingGroups
368 my $filename = $cgiparams { 'uploaded_file' };
370 #First check if logo dir exists
371 if (! - d
" $logopath / $cgiparams {'logo_grp'}" ){
372 mkpath
( " $logopath / $cgiparams {'logo_grp'}" , 0 , 01777 );
375 my ( $filehandle ) = CGI
:: upload
( 'uploaded_file' );
376 open ( UPLOADFILE
, "> $logopath / $cgiparams {'logo_grp'}/logo.png" );
378 while ( < $filehandle > ) {
383 #Check dimensions of uploaded file
384 open ( PNG
, "< $logopath / $cgiparams {'logo_grp'}/logo.png" ) ;
388 my ( $width , $height )=& ACCT
:: pngsize
( $PNG1 ) ;
390 if (! & validnumfield
( $width )){
391 $errormessage .= " $Lang ::tr{'acct invalid png'}<br>" ;
392 unlink ( " $logopath / $cgiparams {'logo_grp'}/logo.png" );
393 } elsif ( $width > 400 || $height > 150 ){
394 $errormessage .= " $Lang ::tr{'acct invalid pngsize'} width: $width height: $height <br>" ;
395 unlink ( " $logopath / $cgiparams {'logo_grp'}/logo.png" );
399 #Check if a group with the same name already exists in DB
400 my $res =& ACCT
:: getbillgroups
;
401 foreach my $row ( @
$res ) {
403 if (( $group eq $cgiparams { 'txt_billgroup' }) && ( $cgiparams { 'oldname' } ne $cgiparams { 'txt_billgroup' })){
404 $errormessage .= $Lang :: tr
{ 'acct billgroupexists' };
407 #Check if a selected user is in another group already
408 if ( $settings { 'MULTIUSER' } ne 'on' ){
409 #split hosts into array
410 my @user = split ( /\|/ , $cgiparams { 'sel_hosts' });
411 my $res =& ACCT
:: checkusergrp
;
412 foreach my $val ( @
$res ){
413 my ( $grp , $usr )= @
$val ;
414 foreach my $wanted ( @user ){
415 if ( $usr eq $wanted && $grp ne $cgiparams { 'txt_billgroup' }){
416 $errormessage .= " $usr $Lang ::tr{'acct usermulti'} $grp <br>" ;
422 if (!& validtextfield
( $cgiparams { 'txt_billgroup' })){
423 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'name'}" ;
425 #Validate CENT amount (num with .)
426 #if used colon, replace with .
427 $cgiparams { 'txt_cent' } =~ tr/,/./ ;
428 if (!& validnumfield
( $cgiparams { 'txt_cent' })){
429 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct cent'}<br>" ;
433 my @ips = split ( /\|/ , $cgiparams { 'sel_hosts' });
435 #Check if we use extra bill positions
436 if ( $cgiparams { 'txt_amount' } || $cgiparams { 'txt_name' }|| $cgiparams { 'txt_price' }){
437 if (! $cgiparams { 'txt_amount' } || ! $cgiparams { 'txt_name' } || ! $cgiparams { 'txt_price' }){
438 $errormessage .= " $Lang ::tr{'acct invalid billpos'}<br>" ;
442 if (! & validnumfield
( $cgiparams { 'txt_amount' })){
443 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct amount'}<br>" ;
444 } elsif (! & validtextfield
( $cgiparams { 'txt_name' })){
445 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct name'}<br>" ;
446 } elsif (! & validnumfield
( $cgiparams { 'txt_price' })){
447 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct price pp'}<br>" ;
451 #Check if we added some CC mail recipients
452 if ( $cgiparams { 'txt_ccmail' }){
453 $cgiparams { 'txt_ccmail' }=~ s/ //g ;
454 #Split line into single addresses and check each one
455 my @ccaddr = split ( "," , $cgiparams { 'txt_ccmail' });
456 foreach my $cc ( @ccaddr ){
457 if (! & General
:: validemail
( $cc )){
458 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct ccmail'} $cc <br>" ;
463 $cgiparams { 'update' } = 'on' ;
466 #update fixedbillpositions if defined
467 if ( $cgiparams { 'oldname' } ne $cgiparams { 'txt_billgroup' }){
468 & ACCT
:: updatebillpos
( $cgiparams { 'oldname' }, $cgiparams { 'txt_billgroup' });
470 #Check if we use extra positions
471 if ( $cgiparams { 'txt_amount' }){
473 $cgiparams { 'txt_billgroup' },
474 $cgiparams { 'txt_amount' },
475 $cgiparams { 'txt_name' },
476 $cgiparams { 'txt_price' });
478 #Check if we have NEW cc Mails
479 if ( $cgiparams { 'txt_ccmail' } ne $cgiparams { 'oldccmail' }){
480 & ACCT
:: updateccaddr
( $cgiparams { 'txt_ccmail' }, $cgiparams { 'dd_cust' });
482 & ACCT
:: deletebillgroup
( $cgiparams { 'oldname' });
483 & ACCT
:: savebillgroup
(
484 $cgiparams { 'txt_billgroup' },
485 $cgiparams { 'txt_billtext1' },
486 $cgiparams { 'dd_host' },
487 $cgiparams { 'dd_cust' },
488 $cgiparams { 'txt_cent' },
494 if ( $cgiparams { 'BILLACTION' } eq "edit_billgroup" ){ #Pencil icon in Billgroup table
495 $cgiparams { 'update' } = 'on' ;
498 if ( $cgiparams { 'BILLACTION' } eq "delete_billgroup" ){ #Trash icon in Billgroup table
499 & deletefiles
( $cgiparams { 'txt_billgroup' });
500 & ACCT
:: delbillpos
( $cgiparams { 'txt_billgroup' });
501 & ACCT
:: deletebillgroup
( $cgiparams { 'txt_billgroup' });
502 & ACCT
:: logger
( $settings { 'LOG' }, "Deleted billgroup $cgiparams {'txt_billgroup'}. \n " );
505 if ( $cgiparams { 'BILLACTION' } eq "open_billgroup" ){ #Folder icon on billgrouptable (viewtablebillgroup)
506 & billoverview
( $cgiparams { 'txt_billgroup' });
508 if ( $cgiparams { 'BILLPOS' } eq "delpos" ){ #Trash icon in Billpos table
509 $cgiparams { 'update' } = 'on' ;
510 & ACCT
:: delbillpos_single
( $cgiparams { 'txt_billpos' }, $cgiparams { 'txt_billgroup' });
511 & ACCT
:: logger
( $settings { 'LOG' }, "Deleted fixed billposition $cgiparams {'txt_billpos'} from billgroup $cgiparams {'txt_billgroup'}. \n " );
514 if ( $cgiparams { 'BILLPOS' } eq " $Lang ::tr{'save'}" ){ #Savebutton in Billpos table
515 $cgiparams { 'update' }= 'on' ;
516 #Check if we use extra bill positions
517 if ( $cgiparams { 'txt_amount' } || $cgiparams { 'txt_name' }|| $cgiparams { 'txt_price' }){
518 if (! $cgiparams { 'txt_amount' } || ! $cgiparams { 'txt_name' } || ! $cgiparams { 'txt_price' }){
519 $errormessage .= " $Lang ::tr{'acct invalid billpos'}<br>" ;
523 #if used colon, replace with .
524 $cgiparams { 'txt_price' } =~ tr/,/./ ;
525 if (! & validnumfield
( $cgiparams { 'txt_amount' })){
526 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct amount'}<br>" ;
527 } elsif (! & validtextfield
( $cgiparams { 'txt_name' })){
528 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct name'}<br>" ;
529 } elsif (! & validnumfield
( $cgiparams { 'txt_price' })){
530 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct price pp'}<br>" ;
535 & billgroupsite
( $errormessage );
537 #check if we use extra positions
538 if ( $cgiparams { 'txt_amount' }){
540 $cgiparams { 'txt_billgroup' },
541 $cgiparams { 'txt_amount' },
542 $cgiparams { 'txt_name' },
543 $cgiparams { 'txt_price' });
545 & ACCT
:: logger
( $settings { 'LOG' }, "Added fixed billposition $cgiparams {'txt_amount'} $cgiparams {'txt_name'} with price $cgiparams {'txt_price'} to billgroup $cgiparams {'txt_billgroup'}. \n " );
552 #Check if we already have settings
553 if ( - z
$settingsfile ){
556 & mainsite
(( $mon + 1 ),( $year + 1900 ));
562 my $blockactivation = '' ;
563 #If update set fieldvalues new
564 if ( $cgiparams { 'update' } eq 'on' ){
565 $settings { 'USEMAIL' } = 'on' ;
566 $settings { 'MAILSUB' } = $cgiparams { 'txt_mailsubject' };
567 $settings { 'MAILTXT' } = $cgiparams { 'txt_mailtxt' };
570 $checked { 'expert' }{ $settings { 'EXPERT' }} = 'CHECKED' ;
571 $checked { 'logging' }{ $settings { 'LOG' }} = 'CHECKED' ;
572 $checked { 'multiuser' }{ $settings { 'MULTIUSER' }} = 'CHECKED' ;
573 $checked { 'usemail' }{ $settings { 'USEMAIL' }} = 'CHECKED' ;
576 & Header
:: openpage
( $Lang :: tr
{ 'acct settings' }, 1 , '' );
577 & Header
:: openbigbox
( '100%' , 'center' );
579 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'acct config' });
581 #### JAVA SCRIPT ####
584 \$(document).ready(function() {
585 // Show/Hide elements when NAT checkbox is checked.
586 if (\$("#MAIL").attr("checked")) {
589 \$(".MAILSRV").hide();
592 // Show NAT area when "use nat" checkbox is clicked
593 \$("#MAIL").change(function() {
594 \$(".MAILSRV").toggle();
600 #######################
601 $settings { 'SKIPURLS' } =~ tr/|/\r\n/ ;
602 $settings { 'MAILTXT' } =~ tr/|/\r\n/ ;
603 my $col = "style='background-color: $color {'color22'}'" ;
605 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
606 <table style='width:100%'>
608 <th colspan='3'></th>
611 <td style='width:24em'> $Lang ::tr{'acct logging'}</td>
612 <td><input type='checkbox' name='logging' $checked {'logging'}{'on'}></td>
616 <td> $Lang ::tr{'acct expert'}</td>
617 <td><input type='checkbox' name='expert' $checked {'expert'}{'on'}></td>
621 <td> $Lang ::tr{'acct multiuser'}</td>
622 <td><input type='checkbox' name='multiuser' $checked {'multiuser'}{'on'}></td>
626 <td> $Lang ::tr{'acct mwst'}</td>
627 <td><input type='text' name='txt_mwst' value=' $settings {'MWST'}' style='width:22em;'></td>
631 <td> $Lang ::tr{'acct currency'}</td>
632 <td><input type='text' name='txt_currency' value=' $settings {'CURRENCY'}' style='width:22em;'></td>
636 <td valign='top'> $Lang ::tr{'acct skipurl'}</td>
637 <td style='padding-left:0.2em;'><textarea name="txt_skipurls" cols="20" rows="6" style='width:22em;'> $settings {'SKIPURLS'}</textarea></td>
642 if ( $mail { 'USEMAIL' } eq 'on' ){
643 if (! $settings { 'MAILSENDER' }){
644 $settings { 'MAILSENDER' } = $mail { 'SENDER' };
648 <td> $Lang ::tr{'acct usemail'}</td>
649 <td><label><input type='checkbox' name='USEMAIL' id='MAIL' $checked {'usemail'}{'on'}></label></td>
657 <div class="MAILSRV">
658 <table style='width:100%;'>
660 <td style='width:24em'> $Lang ::tr{'acct mailsender'}</td>
661 <td><input type='text' name='txt_mailsender' value=' $settings {'MAILSENDER'}' style='width:22em;'></td>
664 <td> $Lang ::tr{'acct subject'}</td>
665 <td><input type='text' name='txt_mailsubject' value=' $settings {'MAILSUB'}' style='width:22em;'></td>
668 <td valign='top' > $Lang ::tr{'acct mailtxt'}</td>
669 <td style='padding-left:0.2em;'><textarea name="txt_mailtxt" cols="34" rows="6" style='width: 22em;'> $settings {'MAILTXT'}</textarea></td>
674 <table style='width:100%;'>
676 <td colspan='3' display:inline align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'save'}'></td>
685 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
686 <table style='width:100%;'>
689 <td align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'back'}'></td>
694 & Header
:: closebigbox
();
695 & Header
:: closepage
();
701 rmtree
( " $logopath / $grp " );
702 rmtree
( "${General::swroot}/accounting/bill/ $grp " );
708 if ( $_ [ 0 ]){ $mon = $_ [ 0 ];}
709 & Header
:: openpage
( $Lang :: tr
{ 'acct title' }, 1 , '' );
710 & Header
:: openbigbox
( '100%' , 'center' );
714 & viewtablehosts
(( $mon ), $year );
715 & Header
:: closebigbox
();
716 & Header
:: closepage
();
720 & Header
:: openpage
( $Lang :: tr
{ 'acct maintenance' }, 1 , '' );
721 & Header
:: openbigbox
( '100%' , 'center' );
723 #Get size of Databasefile
724 my $sizedb = - s
"/var/ipfire/accounting/acct.db" ;
725 $sizedb = sprintf "%.2f" , $sizedb /( 1024 * 1024 );
726 #Get size of Directory, where all bills are stored
728 find
( sub { $sizerrd += - s
if - f
$_ }, "${General::swroot}/accounting/bill" );
729 $sizerrd = sprintf "%.2f" , $sizerrd /( 1024 * 1024 );
732 #Get latest and earliest entry of DB
733 my ( $min , $max ) = & ACCT
:: getminmax
;
737 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'acct status' });
739 <table style='width:100%;' cellspacong='0' class='tbl'>
741 <th align='left' width='30%'> $Lang ::tr{'name'}</th>
742 <th align='left'> $Lang ::tr{'acct value'}</th>
745 <td> $Lang ::tr{'acct dbsize'}</td>
749 <td> $Lang ::tr{'acct rrdsize'}</td>
753 <td> $Lang ::tr{'acct oldestdb'}</td>
757 <td> $Lang ::tr{'acct latestdb'}</td>
764 #print Database maintenance table
765 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'acct dbmaintenance' });
768 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
769 <table style='width:100%;' cellspacing='0' class='tbl'>
771 <th> $Lang ::tr{'acct task'}</th>
772 <th> $Lang ::tr{'acct parameter'}</th>
773 <th> $Lang ::tr{'acct action'}</th>
776 <td> $Lang ::tr{'acct emptydb'}</td>
778 <td><input type='submit' name='ACTION2' value=' $Lang ::tr{'acct commit'}' style='width:10em'></td>
781 <td> $Lang ::tr{'acct emptydbtraf'}</td>
783 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'acct commit'}' style='width:10em'></td>
786 <td> $Lang ::tr{'acct delbefore'} (ACCT,ACCT_HIST)</td>
787 <td><select name='expmonth'>
789 for ( my $i = 1 ; $i < 13 ; $i ++){
790 print "<option> $i </option>" ;
792 print "</select><select name='expyear'>" ;
793 for ( my $i = 2014 ; $i <=( $year + 1900 ); $i ++){
794 print "<option> $i </option>" ;
798 <td><input type='submit' name='ACTION1' value=' $Lang ::tr{'acct commit'}' style='width:10em'></td>
806 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
807 <table style='width:100%;'>
810 <td align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'back'}'></td>
817 & Header
:: closebigbox
();
818 & Header
:: closepage
();
824 #GET : Timestamp in seconds since 1.1.1970
825 #GIVES: Date in Format dd.mm.yyyy HH:MM:SS
827 my $y = sprintf ( " %02d " ,( localtime ( $val ))[ 5 ]- 100 );
828 my $Y = sprintf ( " %04d " ,( localtime ( $val ))[ 5 ]+ 1900 );
829 my $m = sprintf ( " %02d " ,( localtime ( $val ))[ 4 ]+ 1 );
830 my $d = sprintf ( " %02d " ,( localtime ( $val ))[ 3 ]);
831 my $H = sprintf ( " %02d " ,( localtime ( $val ))[ 2 ]);
832 my $M = sprintf ( " %02d " ,( localtime ( $val ))[ 1 ]);
833 my $S = sprintf ( " %02d " ,( localtime ( $val ))[ 0 ]);
835 return " $d . $m . $Y $H : $M : $S " ;
839 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'menu' });
841 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
842 <table style='width: 100%;'>
844 <td style='display:inline;'>
845 <input type='submit' name='ACTION' value=' $Lang ::tr{'acct config'}'>
846 <input type='submit' name='ACTION' value=' $Lang ::tr{'acct addresses'}'>
847 <input type='submit' name='ACTION' value=' $Lang ::tr{'acct billgroup'}'>
849 if ( $settings { 'EXPERT' } eq 'on' ){
850 print "<input type='submit' name='ACTION' value=' $Lang ::tr{'acct maintenance'}'>" ;
866 & Header
:: openpage
( " $Lang ::tr{'acct host detail'} $grhost " , 1 , '' );
867 & Header
:: openbigbox
( '100%' , 'center' );
868 & Header
:: openbox
( '100%' , 'left' , );
870 & generatemonthgraph
( $grmon , $gryear , $grhost );
873 & Header
:: closebigbox
();
874 & Header
:: closepage
();
878 sub generatemonthgraph
{
882 my ( $from , $till ) = & ACCT
:: getmonth
( $grmon , $gryear );
886 #If we want to show Data from within last 2 months, get DATA from ACCT
887 if ( $grmon == ( $mon )+ 1 && $gryear == ( $year + 1900 )){
888 $sth =& ACCT
:: getmonthgraphdata
( "ACCT" , $from , $till , $grhost );
890 #If we want to show data from a date older than last two months, use ACCT_HIST
891 $sth =& ACCT
:: getmonthgraphdata
( "ACCT_HIST" , $from , $till , $grhost );
895 foreach my $i ( 0 ..$ #$_) {
896 push ( @
{ $values [ $i ]},( $_ ->[ $i ]));
900 for my $graph ( GD
:: Graph
:: area
-> new ( 600 , 200 ))
902 my $name = $cgiparams { 'host' };
907 accentclr
=> 'dblue' ,
908 valuesclr
=> '#ffff77' ,
910 axislabelcl
=> 'black' ,
914 dclrs
=> [ qw(lgreen lred) ],
915 x_label
=> $Lang :: tr
{ 'date' },
916 y_label
=> $Lang :: tr
{ 'acct mb' },
919 #x_label_skip => 3, #skip every 3 x-axis title
920 x_label_position
=> 0 ,
924 $graph -> set_legend ( " $Lang ::tr{'acct traffic'}" );
925 $graph -> set ( x_labels_vertical
=> 1 , values_vertical
=> 1 );
926 my $gd = $graph -> plot ( \
@values );
927 open ( IMG
, '>/srv/web/ipfire/html/accounting/tmpgraph.png' ) or die $!;
931 #Show Box with monthly graph for this host
932 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'acct traffic monthly' });
933 print "<center><img src='/accounting/tmpgraph.png' alt=' $grhost '></center>" ;
934 print "<b> $cgiparams {'traffic'}</b>" ;
937 <table style='width:100%;'>
939 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
940 <td align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'back'}'></td>
947 sub generatehourgraph
{
951 my ( $from , $till ) = & ACCT
:: getmonth
( $grmon , $gryear );
955 #If we want to show Data from within last 2 months, get DATA from ACCT
956 if ( ! $grmon < ( $mon + 1 ) && $gryear == ( $year + 1900 )){
957 $sth =& ACCT
:: getgraphdata
( "ACCT" , $from , $till , $grhost );
959 #If we want to show data from a date older than last two months, use ACCT_HIST
960 $sth =& ACCT
:: getgraphdata
( "ACCT_HIST" , $from , $till , $grhost );
964 foreach my $i ( 0 ..$ #$_) {
967 push ( @
{ $values [ $i ]},( $_ ->[ $i ] /1024/ 1024 ));
969 push ( @
{ $values [ $i ]}, $_ ->[ $i ]);
976 for my $graph ( GD
:: Graph
:: area
-> new ( 600 , 200 ))
978 my $name = $cgiparams { 'host' };
979 print STDERR
"Processing $name mit sosse \n " ;
982 x_label
=> 'X Label' ,
983 y_label
=> 'Y label' ,
984 title
=> 'An Area Graph' ,
988 #accent_treshold => 41,
992 $graph -> set_legend ( 'one' , 'two' );
993 my $gd = $graph -> plot ( \
@values );
994 open ( IMG
, '>/srv/web/ipfire/html/test/file.png' ) or die $!;
999 print "<img src='/test/file.png' alt='Tanzmaus'>" ;
1006 if ( $proxsrv eq $Lang :: tr
{ 'stopped' }){
1007 $bgcolor1 = "bgcolor='${Header::colourred}' align='center'" ;
1008 $message = "<br> $Lang ::tr{'acct proxy_enable'}" ;
1010 $bgcolor1 = "bgcolor='${Header::colourgreen}' align='center'" ;
1012 if ( $proxlog eq $Lang :: tr
{ 'stopped' }){
1013 $bgcolor2 = "bgcolor='${Header::colourred}' align='center'" ;
1014 $message = $message . "<br> $Lang ::tr{'acct proxylog_enable'}" ;
1016 $bgcolor2 = "bgcolor='${Header::colourgreen}' align='center'" ;
1018 & Header
:: openbox
( '100%' , 'left' , );
1020 <center><table width='50%' class='tbl'>
1022 <th> $Lang ::tr{'service'}</th>
1023 <th> $Lang ::tr{'status'}</th>
1026 <td bgcolor=' $color {'color22'}'> $Lang ::tr{'proxy'}</td>
1027 <td $bgcolor1 ><font color='white'> $proxsrv </td>
1030 <td bgcolor=' $color {'color20'}'> $Lang ::tr{'logging'}</td>
1031 <td $bgcolor2 ><font color='white'> $proxlog </td>
1035 print "<tr><td colspan='2'><font color='red'> $message <br> $Lang ::tr{'acct nodata'}</td></tr>" ;
1038 & Header
:: closebox
();
1043 #GIVES: Value (in MB,GB,TB) With Type ("MB","GB","TB")
1046 if (( $val / 1024 ) < 1024 ){
1048 $val = sprintf "%.2f" , $val / 1024 ;
1049 $type = $Lang :: tr
{ 'acct kb' };
1050 } elsif (( $val /( 1024 * 1024 )) < 1024 ){
1052 $val = sprintf "%.2f" , $val /( 1024 * 1024 );
1053 $type = $Lang :: tr
{ 'acct mb' };
1054 } elsif (( $val /( 1024 * 1024 * 1024 )) < 1024 ){
1056 $val = sprintf "%.2f" , $val /( 1024 * 1024 * 1024 );
1057 $type = $Lang :: tr
{ 'acct gb' };
1058 } elsif (( $val /( 1024 * 1024 * 1024 * 1024 )) < 1024 ){
1060 $val = sprintf "%.2f" , $val /( 1024 * 1024 * 1024 * 1024 );
1061 $type = $Lang :: tr
{ 'acct tb' };
1063 return ( $val , $type );
1067 #This function shows the site "address management"
1068 & Header
:: openpage
( " $Lang ::tr{'acct addresses'}" , 1 , '' );
1069 & Header
:: openbigbox
( '100%' , 'center' );
1074 #Get all Addresses from DB
1075 my $res = & ACCT
:: getaddresses
;
1077 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'acct edit_addr' } );
1079 #When no address preselected, set COMPANYTYPE to "CUST"
1080 if ( $cgiparams { 'rdo_companytype' } eq '' ){
1081 $cgiparams { 'rdo_companytype' } = 'CUST' ;
1083 $checked { 'rdo_companytype' }{ $cgiparams { 'rdo_companytype' }} = 'CHECKED' ;
1087 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1088 <table style=width:100%;'>
1090 <td style='width:8em;'></td>
1092 <td colspan='2'><font size="1"> $Lang ::tr{'acct hint_hoster'}:</font></td>
1095 <td> $Lang ::tr{'acct companytype'}</td>
1097 <input type='radio' name='rdo_companytype' value='CUST' $checked {'rdo_companytype'}{'CUST'}> $Lang ::tr{'acct customer'}
1098 <input type='radio' name='rdo_companytype' value='HOST' $checked {'rdo_companytype'}{'HOST'}> $Lang ::tr{'acct hoster'}</td>
1099 <td style='width:8em;'> $Lang ::tr{'acct bank'}<img src='/blob.gif' alt='*' /></td>
1101 <input type='text' name='txt_bank' value=' $cgiparams {'txt_bank'}' style='width:25em;'></td>
1104 <td> $Lang ::tr{'acct company'}<img src='/blob.gif' alt='*' /></td>
1106 <input type='text' name='txt_company' value=' $cgiparams {'txt_company'}' style='width:25em;'></td>
1107 <td> $Lang ::tr{'acct iban'}</td>
1109 <input type='text' name='txt_iban' value=' $cgiparams {'txt_iban'}' style='width:25em;'></td>
1112 <td> $Lang ::tr{'acct name1'}</td>
1114 <input type='text' name='txt_name1' value=' $cgiparams {'txt_name1'}' style='width:25em;'></td>
1115 <td> $Lang ::tr{'acct bic'}</td>
1117 <input type='text' name='txt_bic' maxlength='8' value=' $cgiparams {'txt_bic'}' style='width:25em;'></td>
1120 <td> $Lang ::tr{'acct str'}<img src='/blob.gif' alt='*' /></td>
1122 <input type='text' name='txt_str' value=' $cgiparams {'txt_str'}' style='width:25em;'></td>
1123 <td> $Lang ::tr{'acct blz'}</td>
1125 <input type='text' name='txt_blz' maxlength='8' value=' $cgiparams {'txt_blz'}' style='width:25em;'></td>
1128 <td> $Lang ::tr{'acct str_nr'}<img src='/blob.gif' alt='*' /></td>
1129 <td><input type='text' name='txt_str_nr' value=' $cgiparams {'txt_str_nr'}' style='width:25em;'></td>
1130 <td> $Lang ::tr{'acct kto'}</td>
1132 <input type='text' name='txt_kto' value=' $cgiparams {'txt_kto'}' style='width:25em;'></td>
1137 <td> $Lang ::tr{'acct plz'}<img src='/blob.gif' alt='*' /></td>
1139 <input type='text' name='txt_plz' value=' $cgiparams {'txt_plz'}' style='width:25em;'></td>
1140 <td> $Lang ::tr{'acct email'}<img src='/blob.gif' alt='*' /></td>
1141 <td><input type='text' name='txt_email' value=' $cgiparams {'txt_email'}' style='width:25em;'></td>
1144 <td> $Lang ::tr{'acct city'}<img src='/blob.gif' alt='*' /></td>
1145 <td><input type='text' name='txt_city' value=' $cgiparams {'txt_city'}' style='width:25em;'></td>
1146 <td> $Lang ::tr{'acct inet'}</td>
1148 <input type='text' name='txt_inet' value=' $cgiparams {'txt_inet'}' style='width:25em;'></td>
1153 <td> $Lang ::tr{'acct hrb'}<img src='/blob.gif' alt='*' /></td>
1155 <input type='text' name='txt_hrb' value=' $cgiparams {'txt_hrb'}' style='width:25em;'></td>
1160 <td> $Lang ::tr{'acct ustid'}<img src='/blob.gif' alt='*' /></td>
1161 <td><input type='text' name='txt_ustid' value=' $cgiparams {'txt_ustid'}' style='width:25em;'></td>
1166 <td> $Lang ::tr{'acct tel'}</td>
1168 <input type='text' name='txt_tel' value=' $cgiparams {'txt_tel'}' style='width:25em;'></td>
1173 <td> $Lang ::tr{'acct fax'}</td>
1175 <input type='text' name='txt_fax' value=' $cgiparams {'txt_fax'}' style='width:25em;'></td>
1178 <td colspan='6'><img src='/blob.gif' alt='*' /><font size="1"> $Lang ::tr{'acct not optional'}</font></td>
1182 if ( $cgiparams { 'update' } eq 'on' ){
1183 print "<input type='hidden' name='oldcompname' value=' $cgiparams {'oldcompname'}'>" ;
1184 print "<td colspan='6' align='right' display:inline><input type='submit' name='ACTION' value=' $Lang ::tr{'update'}'></td>" ;
1186 print "<td colspan='6' align='right' display:inline><input type='submit' name='ACTION1' value=' $Lang ::tr{'save'}'></td>" ;
1188 print "</tr></table></form>" ;
1189 & Header
:: closebox
();
1192 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1193 <table style='width:100%;'>
1195 <td align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'back'}'></td>
1200 #Check if we need to show HOSTBOX and/or CUSTBOX
1201 foreach my $row ( @
$res ) {
1202 my ( $gr , $comp , $type , $name1 , $str , $nr , $plz , $city , $bank , $iban , $bic , $blz , $kto , $email , $inet , $hrb , $ustid , $tel , $fax ) = @
$row ;
1203 if ( $type eq 'HOST' ){
1206 if ( $type eq 'CUST' ){
1210 #Show HOSTER Addresses if any
1214 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'acct exst_host_addr' } );
1216 print "<table style='width:100%'>" ;
1217 foreach my $row ( @
$res ) {
1218 #SET colors for tablerows
1219 $col = "style='background-color: $color {'color22'}'" ;
1220 $col1 = "style='background-color:#e2d8d8'" ;
1221 my ( $gr , $comp , $type , $name1 , $str , $nr , $plz , $city , $bank , $iban , $bic , $blz , $kto , $email , $inet , $hrb , $ustid , $tel , $fax ) = @
$row ;
1222 if ( $cgiparams { 'oldcompname' } eq $comp ){
1223 $col = "style='background-color:yellow'" ;
1224 $col1 = "style='background-color:yellow'" ;
1226 if ( $type eq 'HOST' ){
1229 print "<tr><td width='50%' valign='top' align='center'>" ;
1231 print "</td><td width='50%' valign='top' align='center'>" ;
1234 <table style='width:90%;' cellspacing='0' class='tbl'>
1236 <th align='left' width='50%'> $Lang ::tr{'acct company'}</th>
1237 <th align='left' width='10%' > $Lang ::tr{'acct bank'}</th>
1238 <th width='38%' ></th>
1239 <th align='right' width='1%' style="PADDING: 0px">
1240 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1241 <input type='image' src='/images/edit.gif' alt= $Lang ::tr{'acct edit'} title=' $Lang ::tr{'acct edit'}' />
1242 <input type='hidden' name='ACTION' value='edit_addr'>
1243 <input type='hidden' name='rdo_companytype' value=' $type '>
1244 <input type='hidden' name='txt_company' value=' $comp '>
1245 <input type='hidden' name='txt_name1' value=' $name1 '>
1246 <input type='hidden' name='txt_str' value=' $str '>
1247 <input type='hidden' name='txt_str_nr' value=' $nr '>
1248 <input type='hidden' name='txt_plz' value=' $plz '>
1249 <input type='hidden' name='txt_city' value=' $city '>
1250 <input type='hidden' name='txt_bank' value=' $bank '>
1251 <input type='hidden' name='txt_iban' value=' $iban '>
1252 <input type='hidden' name='txt_bic' value=' $bic '>
1253 <input type='hidden' name='txt_blz' value=' $blz '>
1254 <input type='hidden' name='txt_kto' value=' $kto '>
1255 <input type='hidden' name='txt_email' value=' $email '>
1256 <input type='hidden' name='txt_inet' value=' $inet '>
1257 <input type='hidden' name='txt_hrb' value=' $hrb '>
1258 <input type='hidden' name='txt_ustid' value=' $ustid '>
1259 <input type='hidden' name='txt_tel' value=' $tel '>
1260 <input type='hidden' name='txt_fax' value=' $fax '>
1262 <th width='1%' style="PADDING: 0px">
1263 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1264 <input type='image' src='/images/delete.gif' alt= $Lang ::tr{'acct deladr'} title= $Lang ::tr{'acct deladr'} />
1265 <input type='hidden' name='txt_company' value=' $comp '>
1266 <input type='hidden' name='ACTION' value='del_addr'>
1271 <td $col ><b> $comp </b></td>
1273 <td colspan='3' $col1 ></td>
1276 <td $col > $name1 </td>
1277 <td $col1 width='35%'> $Lang ::tr{'acct bank'}</td>
1278 <td colspan='3' $col1 > $bank </td>
1282 <td $col1 > $Lang ::tr{'acct iban'}</td>
1283 <td colspan='3' $col1 > $iban </td>
1286 <td $col > $str $nr </td>
1287 <td $col1 > $Lang ::tr{'acct bic'}</td>
1288 <td colspan='3' $col1 > $bic </td>
1291 <td $col > $plz $city </td>
1292 <td $col1 > $Lang ::tr{'acct blz'}</td>
1293 <td colspan='3' $col1 > $blz </td>
1297 <td $col1 > $Lang ::tr{'acct kto'}</td>
1298 <td colspan='3' $col1 > $kto </td>
1310 print "<td width='50%' valign='top' align='center'></td></tr>" ;
1313 & Header
:: closebox
();
1315 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'acct exst_host_addr' } );
1316 print $Lang :: tr
{ 'acct host empty' };
1317 & Header
:: closebox
();
1319 #Show CUSTOMER Addresses if any
1322 #EXISTING CUSTOMER BOX
1323 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'acct exst_cust_addr' } );
1324 print "<table style='width:100%;'><tr>" ;
1325 foreach my $row ( @
$res ) {
1326 #SET colors for tablerows
1327 $col = "style='background-color: $color {'color22'}'" ;
1328 my ( $gr , $comp , $type , $name1 , $str , $nr , $plz , $city , $bank , $iban , $bic , $blz , $kto , $email , $inet , $hrb , $ustid , $tel , $fax ) = @
$row ;
1329 if ( $cgiparams { 'oldcompname' } eq $comp ){
1330 $col = "style='background-color:yellow'" ;
1332 if ( $type eq 'CUST' ){
1334 print "<td width='15%' valign='top' align='center'>" ;
1337 <table style='width:90%;' cellspacing='0' class='tbl'>
1340 $Lang ::tr{'acct company'}
1342 <th width='1%' style="PADDING: 0px">
1343 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1344 <input type='image' src='/images/edit.gif' alt=' $Lang ::tr{'acct edit'}' title=' $Lang ::tr{'acct edit'}' />
1345 <input type='hidden' name='ACTION' value='edit_addr'>
1346 <input type='hidden' name='rdo_companytype' value=' $type '>
1347 <input type='hidden' name='txt_company' value=' $comp '>
1348 <input type='hidden' name='txt_name1' value=' $name1 '>
1349 <input type='hidden' name='txt_str' value=' $str '>
1350 <input type='hidden' name='txt_str_nr' value=' $nr '>
1351 <input type='hidden' name='txt_plz' value=' $plz '>
1352 <input type='hidden' name='txt_city' value=' $city '>
1353 <input type='hidden' name='txt_bank' value=' $bank '>
1354 <input type='hidden' name='txt_iban' value=' $iban '>
1355 <input type='hidden' name='txt_bic' value=' $bic '>
1356 <input type='hidden' name='txt_blz' value=' $blz '>
1357 <input type='hidden' name='txt_kto' value=' $kto '>
1358 <input type='hidden' name='txt_email' value=' $email '>
1359 <input type='hidden' name='txt_inet' value=' $inet '>
1360 <input type='hidden' name='txt_hrb' value=' $hrb '>
1361 <input type='hidden' name='txt_ustid' value=' $ustid '>
1362 <input type='hidden' name='txt_tel' value=' $tel '>
1363 <input type='hidden' name='txt_fax' value=' $fax '>
1366 <th width='1%' style="padding: 0px">
1367 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1368 <input type='image' src='/images/delete.gif' alt= $Lang ::tr{'acct deladr'} title= $Lang ::tr{'acct deladr'} />
1369 <input type='hidden' name='ACTION' value='del_addr' />
1370 <input type='hidden' name='txt_company' value=' $comp ' />
1375 <td colspan='3' $col ><b> $comp </b></td>
1378 <td colspan='3' $col > $name1 </td>
1381 <td colspan='3' $col > $str $nr </td>
1384 <td colspan='3' $col > $plz $city </td>
1390 if (! ( $count % 3 )) {
1397 print "<td width='15%' valign='top' align='center'></td></tr>" ;
1400 & Header
:: closebox
();
1402 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'acct exst_cust_addr' } );
1403 print $Lang :: tr
{ 'acct cust empty' };
1404 & Header
:: closebox
();
1406 & Header
:: closebigbox
();
1407 & Header
:: closepage
();
1413 my $fieldvalue = $_ [ 1 ];
1414 my $errormessage = $_ [ 2 ];
1416 if (!& validtextfield
( $fieldvalue )){
1418 $errormessage .= " $Lang ::tr{'acct empty field'} $field <br>" ;
1420 $errormessage .= " $Lang ::tr{'acct invalid'} $field <br>" ;
1423 return $errormessage ;
1427 #Check if an address with the same name alread exists
1428 if ( $cgiparams { 'update' } ne 'on' ){
1429 my $res =& ACCT
:: getaddresses
;
1430 foreach my $row ( @
$res ) {
1431 my ( $anz , $name )= @
$row ;
1432 if ( $name eq $cgiparams { 'txt_company' }){
1433 $errormessage .= $Lang :: tr
{ 'acct companyexists' };
1438 $errormessage =& checkfield
( $Lang :: tr
{ 'acct company' }, $cgiparams { 'txt_company' }, $errormessage );
1441 if ( $cgiparams { 'txt_name1' }){
1442 $errormessage =& checkfield
( $Lang :: tr
{ 'acct name1' }, $cgiparams { 'txt_name1' }, $errormessage );
1446 if ( $cgiparams { 'txt_name2' }){
1447 $errormessage =& checkfield
( $Lang :: tr
{ 'acct name2' }, $cgiparams { 'txt_name2' }, $errormessage );
1451 $errormessage =& checkfield
( $Lang :: tr
{ 'acct str' }, $cgiparams { 'txt_str' }, $errormessage );
1454 if (! $cgiparams { 'txt_str_nr' }){
1455 $errormessage .= " $Lang ::tr{'acct empty field'} $Lang ::tr{'acct str_nr'}<br>" ;
1457 if (! & validalphanumfield
( $cgiparams { 'txt_str_nr' })){
1458 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct str_nr'}<br>" ;
1463 if (! $cgiparams { 'txt_plz' }){
1464 $errormessage .= " $Lang ::tr{'acct empty field'} $Lang ::tr{'acct plz'}<br>" ;
1466 if (! & validnumfield
( $cgiparams { 'txt_plz' })){
1467 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct plz'}<br>" ;
1472 $errormessage =& checkfield
( $Lang :: tr
{ 'acct city' }, $cgiparams { 'txt_city' }, $errormessage );
1475 if (! $cgiparams { 'txt_email' }){
1476 $errormessage .= " $Lang ::tr{'acct empty field'} $Lang ::tr{'acct email'}<br>" ;
1478 if (! & General
:: validemail
( $cgiparams { 'txt_email' })){
1479 $errormessage .= "<br> $Lang ::tr{'acct invalid'} $Lang ::tr{'acct email'}" ;
1483 #Check all fields required for companytype "HOST"
1484 if ( $cgiparams { 'rdo_companytype' } eq 'HOST' ){
1486 $errormessage =& checkfield
( $Lang :: tr
{ 'acct bank' }, $cgiparams { 'txt_bank' }, $errormessage );
1488 #Check IBAN - optional
1489 if ( $cgiparams { 'txt_iban' }){
1490 if (!& validalphanumfield
( $cgiparams { 'txt_iban' })){
1491 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct iban'}<br>" ;
1494 if ( $cgiparams { 'txt_bic' }){
1495 if (!& validalphanumfield
( $cgiparams { 'txt_bic' })){
1496 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct bic'}<br>" ;
1499 if (( $cgiparams { 'txt_iban' } && $cgiparams { 'txt_blz' })||(! $cgiparams { 'txt_iban' } && $cgiparams { 'txt_blz' })){
1501 if (! & validnumfield
( $cgiparams { 'txt_blz' })){
1502 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct blz'}<br>" ;
1505 if ( $cgiparams { 'txt_kto' }){
1506 if (! & validnumfield
( $cgiparams { 'txt_kto' })){
1507 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct kto'}<br>" ;
1509 } elsif (! $cgiparams { 'txt_kto' }){
1510 $errormessage .= " $Lang ::tr{'acct empty field'} $Lang ::tr{'acct kto'}<br>" ;
1512 } elsif (! $cgiparams { 'txt_iban' } && ! $cgiparams { 'txt_blz' }){
1513 $errormessage .= " $Lang ::tr{'acct empty field'} $Lang ::tr{'acct blz'}<br>" ;
1515 if ( $cgiparams { 'txt_kto' }){
1516 if (! & validnumfield
( $cgiparams { 'txt_kto' })){
1517 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct kto'}<br>" ;
1519 } elsif (! $cgiparams { 'txt_kto' }){
1520 $errormessage .= " $Lang ::tr{'acct empty field'} $Lang ::tr{'acct kto'}<br>" ;
1525 if ( $cgiparams { 'txt_inet' }){
1526 if ( $cgiparams { 'txt_inet' } =~ m/([a-z]+:\/ \
/)??([a-z0-9\-]+\.){1}(([a-z0-9\-]+\.){0,})([a-z0-9\-]+){1}/o ) {
1527 $cgiparams { 'txt_inet' }= $2 . $3 . $5 ;
1529 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct inet'}<br>" ;
1533 if ( $cgiparams { 'txt_hrb' }){
1534 $errormessage =& checkfield
( $Lang :: tr
{ 'acct hrb' }, $cgiparams { 'txt_hrb' }, $errormessage );
1540 if ( $cgiparams { 'txt_tel' }){
1541 if (!& validphonefield
( $cgiparams { 'txt_tel' })){
1542 $errormessage .= " $Lang ::tr{'acct invalid'} $Lang ::tr{'acct tel'}<br>" ;
1546 return $errormessage ;
1550 if (- f
"${General::swroot}/proxy/enable" ){
1551 $proxsrv = $Lang :: tr
{ 'running' };
1553 $proxsrv = $Lang :: tr
{ 'stopped' };
1555 my $srce = "${General::swroot}/proxy/squid.conf" ;
1556 my $string1 = 'access\.log' ;
1558 while ( my $line = < FH
>) {
1559 if ( $line =~ m/$string1/ ) {
1560 $proxlog = $Lang :: tr
{ 'running' };
1568 #GET: Input from a Textfield
1569 #GIVES: True if valid, false if not valid
1572 # Each part should be at least two characters in length
1573 # but no more than 63 characters
1574 if ( length ( $remark ) < 1 || length ( $remark ) > 255 ) {
1576 # Only valid characters are a-z, A-Z, 0-9 and -
1577 if ( $remark !~ /^[a-zĆ¤Ć¶Ć¼A-ZĆĆĆ0-9-.:;\&\|\Ć_()\/ \s
]*$/) {
1579 # First character can only be a letter or a digit
1580 if ( substr ( $remark , 0 , 1 ) !~ /^[a-zĆ¤Ć¶Ć¼A-ZĆĆĆ0-9(]*$/ ) {
1582 # Last character can only be a letter or a digit
1583 if ( substr ( $remark , - 1 , 1 ) !~ /^[a-zĆ¶Ć¤Ć¼A-ZĆĆĆ0-9.:;_)]*$/ ) {
1589 #GET: Input from a numeric field
1590 #GIVES: True if valid, false if not valid
1593 # Each part should be at least two characters in length
1594 # but no more than 63 characters
1595 if ( length ( $num ) < 1 || length ( $num ) > 255 ) {
1597 # Only valid characters are a-z, A-Z, 0-9 and -
1598 if ( $num !~ /^[0-9.]*$/ ) {
1600 # First character can only be a letter or a digit
1601 if ( substr ( $num , 0 , 1 ) !~ /^[0-9]*$/ ) {
1603 # Last character can only be a letter or a digit
1604 if ( substr ( $num , - 1 , 1 ) !~ /^[0-9]*$/ ) {
1609 sub validphonefield
{
1610 #GET: Input from a numeric field
1611 #GIVES: True if valid, false if not valid
1614 # Each part should be at least two characters in length
1615 # but no more than 63 characters
1616 if ( length ( $num ) < 1 || length ( $num ) > 255 ) {
1618 # Only valid characters are a-z, A-Z, 0-9 and -
1619 if ( $num !~ /^[0-9-()\+ ]*$/ ) {
1621 # First character can only be a letter or a digit
1622 if ( substr ( $num , 0 , 1 ) !~ /^[0-9(\+]*$/ ) {
1624 # Last character can only be a digit
1625 if ( substr ( $num , - 1 , 1 ) !~ /^[0-9]*$/ ) {
1630 sub validalphanumfield
{
1631 #GET: Input from a numeric field
1632 #GIVES: True if valid, false if not valid
1635 # Each part should be at least two characters in length
1636 # but no more than 63 characters
1637 if ( length ( $remark ) < 1 || length ( $remark ) > 255 ) {
1639 # Only valid characters are a-z, A-Z, 0-9 and -
1640 if ( $remark !~ /^[0-9a-zA-Z]*$/ ) {
1642 # First character can only be a letter or a digit
1643 if ( substr ( $remark , 0 , 1 ) !~ /^[0-9A-Za-z]*$/ ) {
1645 # Last character can only be a letter or a digit
1646 if ( substr ( $remark , - 1 , 1 ) !~ /^[0-9a-zA-Z]*$/ ) {
1652 if ( $errormessage ) {
1653 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
1654 print "<class name='base'> $errormessage \n " ;
1655 print " </class> \n " ;
1656 & Header
:: closebox
();
1661 & Header
:: openpage
( " $Lang ::tr{'acct billgroup'}" , 1 , '' );
1662 & Header
:: openbigbox
( '100%' , 'center' );
1670 #Get addresses from DB
1671 my $res = & ACCT
:: getaddresses
;
1672 #Check if we need to show NEW-BillGROUP-BOX or Hint
1673 foreach my $row ( @
$res ) {
1674 my ( $gr , $comp , $type , $name1 , $str , $nr , $plz , $city , $bank , $iban , $bic , $blz , $kto , $email , $inet , $hrb , $ust , $tel , $fax , $ccmail ) = @
$row ;
1677 $ccmailrcpt = $ccmail ;
1678 if ( $type eq 'HOST' ){
1681 if ( $type eq 'CUST' ){
1685 if ( $host && $cust ){
1687 if (! $cgiparams { 'txt_ccmail' }){
1688 $cgiparams { 'txt_ccmail' }= $ccmailrcpt ;
1690 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'acct edit_addr'}" );
1692 <form method='post' action=' $ENV {'SCRIPT_NAME'}' ENCTYPE='multipart/form-data'>
1693 <table style='width:100%;'>
1695 <td style='width: 22em;'> $Lang ::tr{'name'}</td>
1696 <td><input type='text' name='txt_billgroup' value=' $cgiparams {'txt_billgroup'}' style='width: 24em;'></td>
1702 <td valign='top'> $Lang ::tr{'acct billtext1'}<img src='/blob.gif' alt='*' /></td>
1703 <td><textarea name='txt_billtext1' cols='40' rows='5' style='width: 24em;' maxlength='300'> $cgiparams {'txt_billtext1'}</textarea></td>
1705 <tr><td><br></td></tr>
1707 #Print Dropdown Menu for HOSTER and CUSTOMER
1708 print "<tr><td> $Lang ::tr{'acct hoster'}</td><td><select name='dd_host' style='width: 24.3em;'>" ;
1709 foreach my $row ( @
$res ) {
1710 my ( $gr , $comp , $type ) = @
$row ;
1711 if ( $type eq 'HOST' ){
1712 if ( $cgiparams { 'dd_host' } eq $comp ){
1713 print "<option selected> $comp </option>" ;
1715 print "<option> $comp </option>" ;
1719 print "</select></td></tr><tr><td><br></td></tr>" ;
1720 print "<tr><td> $Lang ::tr{'acct customer'}</td><td><select name='dd_cust' style='width: 24.3em;'>" ;
1721 foreach my $row ( @
$res ) {
1722 my ( $gr , $comp , $type ) = @
$row ;
1723 if ( $type eq 'CUST' ){
1724 if ( $cgiparams { 'dd_cust' } eq $comp ){
1725 print "<option selected> $comp </option>" ;
1727 print "<option> $comp </option>" ;
1731 print "</select></td></tr>" ;
1732 print "<tr><td><br></td></tr>" ;
1733 #Print multiselectbox for hosts/users which should be part of this group
1734 my $hosts =& ACCT
:: gethosts
;
1735 print "<tr><td valign='top'> $Lang ::tr{'acct members'}</td><td><select name='sel_hosts' multiple size='8' style='width: 24em;' >" ;
1736 #If update, split $cgiparams{'sel_hosts'} and preselect values from selectbox
1737 if ( $cgiparams { 'update' } eq 'on' ){
1738 $cgiparams { 'oldname' }= $cgiparams { 'txt_billgroup' };
1739 @oldhosts = split ( /\|/ , $cgiparams { 'sel_hosts' });
1741 foreach my $row ( @
$hosts ) {
1744 foreach my $old ( @oldhosts ){
1750 print "<option selected> $val </option>" ;
1752 print "<option> $val </option>" ;
1755 print "</select></td></tr>" ;
1756 print "<tr><td><br></td></tr>" ;
1757 #set right decimal seperator for cent value
1758 setlocale
( LC_NUMERIC
, " $mainsettings {'LANGUAGE'}_ $uplang " );
1759 my $val = sprintf "%.3f" , $cgiparams { 'txt_cent' };
1760 print "<tr><td> $Lang ::tr{'acct cent'}</td><td><input type='text' name='txt_cent' value=' $val ' size='3'> $settings {'CURRENCY'} </td></tr>" ;
1762 print "<tr><td colspan='2' align='left'><img src='/blob.gif' alt='*' /><font size='1'> $Lang ::tr{'acct optional'}</font></td></tr>" ;
1763 print "<tr><td colspan='2' align='right'><br><br>" ;
1764 print "</td></tr></table>" ;
1766 #LOGO Upload if update eq 'on'
1767 if ( $cgiparams { 'update' } eq 'on' ){
1769 <table style='width:100%;'>
1771 <td style='width: 22em;'> $Lang ::tr{'acct logo upload'}</td>
1772 <td><INPUT TYPE="file" NAME="uploaded_file" SIZE=30 MAXLENGTH=80></td>
1773 <input type='hidden' name='logo_grp' value=' $cgiparams {'txt_billgroup'}' />
1776 <td><br> $Lang ::tr{'acct logo'}</td>
1778 #Show Logo in webinterface with 1/2 size if set
1779 if (- f
" $logopath / $cgiparams {'txt_billgroup'}/logo.png" ){
1780 print "<td><img src='/accounting/logo/ $cgiparams {'txt_billgroup'}/logo.png' alt=' $logopath / $cgiparams {'txt_billgroup'}/logo.png' width='25%' height='25%' /></td></tr>" ;
1782 print "<td><br> $Lang ::tr{'no'}</td></tr>" ;
1784 #Show optional CC Mailadresses
1787 <td><br> $Lang ::tr{'acct mailrcpt'}</td>
1788 <td><br> $mailrcpt </td>
1791 <td><br> $Lang ::tr{'acct ccmail'}</td>
1792 <td><br><input type='text' name='txt_ccmail' value=' $cgiparams {'txt_ccmail'}' style='width: 24.3em;'></td>
1800 print "<table style='width:100%;'><tr><td align='right'>" ;
1801 #Print SAVE or EDIT Button
1802 if ( $cgiparams { 'update' } eq 'on' ){
1803 print "<input type='submit' name='BILLACTION' value=' $Lang ::tr{'update'}'>" ;
1804 print "<input type='hidden' name='oldname' value=' $cgiparams {'oldname'}'>" ;
1805 print "<input type='hidden' name='oldccmail' value=' $ccmailrcpt '>" ;
1807 print "<input type='submit' name='BILLACTION' value=' $Lang ::tr{'save'}'>" ;
1809 print "</td></tr></table><br></form><br>" ;
1810 & Header
:: closebox
();
1813 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1814 <table style='width:100%;'>
1817 <input type='submit' name='ACTION' value=' $Lang ::tr{'back'}'>
1823 #Show Box for fixed positions if update
1824 if ( $cgiparams { 'update' } eq 'on' ){
1825 & viewtablebillpos
( $cgiparams { 'txt_billgroup' });
1828 & viewtablebillgroups
;
1832 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'hint'}" );
1833 print " $Lang ::tr{'acct hint billgrp'}" ;
1834 & Header
:: closebox
();
1837 <table style='width:100%;'>
1839 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1840 <td align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'back'}'></td>
1846 & Header
:: closebigbox
();
1847 & Header
:: closepage
();
1851 sub viewtablebillgroups
{
1853 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'acct billgroup'}" );
1854 #Get DATA from table BILLINGGRP
1855 my $res = & ACCT
:: getbillgroups
;
1857 #Print table billinggroup
1859 <table style='width:100%;' cellspacing='0' class='tbl'>
1861 <th align='left'> $Lang ::tr{'name'}</th>
1862 <th align='left'> $Lang ::tr{'acct hoster'}</th>
1863 <th align='left'> $Lang ::tr{'acct customer'}</th>
1864 <th align='left'> $Lang ::tr{'acct members'}</th>
1865 <th align='left' colspan='5'></th>
1868 foreach my $line ( @
$res ){
1871 $col = "style='background-color: $color {'color22'}'" ;
1873 $col = "style='background-color: $color {'color20'}'" ;
1875 my ( $name , $host , $cust , $txt , $amount , $cent ) = @
$line ;
1881 <td $col > $amount </td>
1882 <td width='1%' $col >
1884 my $members =& ACCT
:: listhosts
( $name );
1885 my @mem = split ( /\|/ , $members );
1887 foreach my $m ( @mem ){
1890 print "<img src='/images/computer.png' alt= $Lang ::tr{'acct members'} title='" . $msg . "' /></td>" ;
1893 <td width='1%' $col >
1894 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1895 <input type='image' src='/images/edit.gif' alt=' $Lang ::tr{'edit'}' title=' $Lang ::tr{'edit'}' />
1896 <input type='hidden' name='BILLACTION' value='edit_billgroup'>
1897 <input type='hidden' name='txt_billgroup' value=' $name '>
1898 <input type='hidden' name='txt_billtext1' value=' $txt '>
1899 <input type='hidden' name='dd_host' value=' $host '>
1900 <input type='hidden' name='dd_cust' value=' $cust '>
1901 <input type='hidden' name='sel_hosts' value=' $members '>
1902 <input type='hidden' name='txt_cent' value=' $cent '>
1906 <td width='1%' $col >
1907 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1908 <input type='image' src='/images/folder-open.png' alt=' $Lang ::tr{'edit'}' title=' $Lang ::tr{'acct billarchive'}' />
1909 <input type='hidden' name='BILLACTION' value='open_billgroup'>
1910 <input type='hidden' name='txt_billgroup' value=' $name '>
1914 <td width='1%' $col >
1915 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1916 <input type='image' src='/images/document-new.png' alt=' $Lang ::tr{'acct preview'}' title=' $Lang ::tr{'acct preview'}' />
1917 <input type='hidden' name='BILLACTION' value='open_preview'>
1918 <input type='hidden' name='txt_billgroup' value=' $name '>
1921 <td width='1%' $col >
1922 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1923 <input type='image' src='/images/delete.gif' alt= $Lang ::tr{'delete'} title=" $Lang ::tr{'delete'}" />
1924 <input type='hidden' name='BILLACTION' value='delete_billgroup'>
1925 <input type='hidden' name='txt_billgroup' value=' $name '>
1933 & Header
:: closebox
();
1937 $dbh =& ACCT
:: connectdb
;
1938 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'acct hosts' });
1941 my ( $from , $till )=& ACCT
:: getmonth
( $mon1 , $year1 );
1943 #Menu to display another month
1945 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
1946 <table style='width:100%;'>
1948 <td style='width:5%; text-align:center;'> $Lang ::tr{'acct month'}</td>
1949 <td style='width:10%; text-align: center;'> $Lang ::tr{'acct year'}</td>
1953 <td><select name='month'>
1955 for ( my $i = 1 ; $i < 13 ; $i ++){
1957 print "<option selected> $i </option>" ;
1959 print "<option> $i </option>" ;
1964 <td style='text-align: center;'><select name='year'>
1966 for ( my $j = 2014 ; $j <=( $year1 ); $j ++){
1968 print "<option selected> $j </option>" ;
1970 print "<option> $j </option>" ;
1975 <td><input type='submit' name='ACTION' value=' $Lang ::tr{'acct view'}'></td>
1980 #View table with all hosts
1982 <table style='width:100%;' class='tbl'>
1984 <th> $Lang ::tr{'name'}</th>
1985 <th> $Lang ::tr{'acct traffic'}</th>
1986 <th> $Lang ::tr{'from'}</th>
1987 <th> $Lang ::tr{'to'}</th>
1992 if (( $mon )+ 1 == $mon1 && ( $year )+ 1900 == $year1 ){
1993 $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;" );
1995 $res = $dbh -> selectall_arrayref ( "SELECT SUM(BYTES),min(strftime(' %s ',TIME_RUN)),max(strftime(' %s ',TIME_RUN)),NAME from ACCT_HIST where date(TIME_RUN) > date( $from ,'unixepoch') and date(TIME_RUN) < date( $till ,'unixepoch') group by NAME;" );
2001 foreach my $row ( @
$res ) {
2006 $col = "background-color: $color {'color22'};" ;
2008 $col = "background-color: $color {'color20'};" ;
2010 my ( $bytes , $mintime , $maxtime , $name ) = @
$row ;
2012 ( $lineval , $type ) = & calcbytes
( $bytes );
2014 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>" ;
2017 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2018 <input type='image' src='/images/utilities-system-monitor.png' alt=" $Lang ::tr{'status'}" title=" $Lang ::tr{'status'}" />
2019 <input type='hidden' name='ACTION' value='viewgraph'>
2020 <input type='hidden' name='host' value=' $name '>
2021 <input type='hidden' name='month' value=' $mon1 '>
2022 <input type='hidden' name='year' value=' $year1 '>
2023 <input type='hidden' name='traffic' value=" $Lang ::tr{'acct sum'} $Lang ::tr{'acct traffic'} $lineval $type ">
2031 print "<tr><td colspan='5'><center> $Lang ::tr{'acct no data'}</td></tr>" ;
2034 & Header
:: closebox
();
2038 sub viewtablebillpos
{
2040 #BOX for extra billpositions
2041 & Header
:: openbox
( '100%' , 'left' , " $Lang ::tr{'acct fix billpos'} $grp " );
2042 #Table for optional billpositions
2044 <center><table style='width:65%' cellspacing='0' class='tbl' border='0'>
2046 <th align='left'> $Lang ::tr{'acct amount'}</th>
2047 <th align='left' style='padding-left:1.2em'> $Lang ::tr{'acct name'}</th>
2048 <th align='left'> $Lang ::tr{'acct price pp'}</th>
2052 #Fill Table for extra billpositions if any
2053 if ( $cgiparams { 'update' } eq 'on' ){
2054 my $res = & ACCT
:: getextrabillpos
( $cgiparams { 'txt_billgroup' });
2056 foreach my $line ( @
$res ){
2059 $col = "style='background-color: $color {'color22'}'" ;
2061 $col = "style='background-color: $color {'color20'}'" ;
2063 my ( $grp , $amnt , $pos , $price ) = @
$line ;
2064 setlocale
( LC_NUMERIC
, " $mainsettings {'LANGUAGE'}_ $uplang " );
2065 my $locale_price = sprintf "%.2f" , $price ;
2066 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>" ;
2067 print "<td $col ><input type='image' src='/images/delete.gif' alt= $Lang ::tr{'delete'} title= $Lang ::tr{'delete'} >" ;
2068 print "<input type='hidden' name='BILLPOS' value='delpos'>" ;
2069 print "<input type='hidden' name='txt_billgroup' value=' $grp '>" ;
2070 print "<input type='hidden' name='txt_billpos' value=' $pos '></form></tr>" ;
2076 <td ><form method='post' action=' $ENV {'SCRIPT_NAME'}'><input type='text' name='txt_amount' value=' $cgiparams {'txt_amount'}' size='3'></td>
2077 <td><input type='text' name='txt_name' value=' $cgiparams {'txt_name'}' size='40'></td>
2078 <td ><input type='text' name='txt_price' value=' $cgiparams {'txt_price'}' size='6'></td>
2082 <table style='width:100%'>
2084 <td align='right'><input type='submit' name='BILLPOS' value=' $Lang ::tr{'save'}'></td>
2085 <input type='hidden' name='txt_billgroup' value=' $grp '>
2091 & Header
:: closebox
();
2099 & Header
:: openpage
( $Lang :: tr
{ 'acct billoverview' }, 1 , '' );
2100 & Header
:: openbigbox
( '100%' , 'center' );
2101 & Header
:: openbox
( '100%' , 'left' , $grp );
2102 my $res =& ACCT
:: getbills
( $grp );
2106 <table style='width:100%' cellspacing='0' class='tbl' border='0'>
2108 <th> $Lang ::tr{'acct nr'}</th>
2109 <th> $Lang ::tr{'acct path'}</th>
2110 <th> $Lang ::tr{'name'}</th>
2111 <th> $Lang ::tr{'acct generated'}</th>
2116 foreach my $row ( @
$res ){
2119 $col = "style='background-color: $color {'color22'}'" ;
2121 $col = "style='background-color: $color {'color20'}'" ;
2123 my ( $no , $path , $name , $date , $dbgrp ) = @
$row ;
2125 print "<tr><td $col > $no </td><td $col > $path </td><td $col > $name </td><td $col > $date </td><td $col >" ;
2126 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'}' />" ;
2127 print "<input type='hidden' name='BILLVIEW' value='show'>" ;
2128 my $file = " $path / $name " ;
2129 print "<input type='hidden' name='file' value=' $file '>" ;
2130 print "<input type='hidden' name='name' value=' $name '>" ;
2131 print "</form></td></tr>" ;
2133 print "</table><br>" ;
2135 print "<center> $Lang ::tr{'acct no data'}" ;
2137 & Header
:: closebox
();
2141 <table style='width:100%'>
2143 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
2144 <td align='right'><input type='submit' name='ACTION' value=' $Lang ::tr{'back'}'></td>
2149 & Header
:: closebigbox
();
2150 & Header
:: closepage
();
2154 sub checkmailsettings
{
2156 if (! $cgiparams { 'txt_mailsender' }){
2157 $errormessage .= " $Lang ::tr{'acct empty field'} $Lang ::tr{'acct mailsender'}<br>" ;
2159 if (! & General
:: validemail
( $cgiparams { 'txt_mailsender' })){
2160 $errormessage .= "<br> $Lang ::tr{'acct invalid'} $Lang ::tr{'acct mailsender'}<br>" ;
2163 return $errormessage ;