#===================================================================== # LedgerSMB Small Medium Business Accounting # Copyright (c) 2001 # # Author: DWS Systems Inc. # Web: http://sourceforge.net/projects/ledger-smb/ # # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #====================================================================== # # administration # #====================================================================== use SL::AM; use SL::CA; use SL::Form; use SL::User; use SL::RP; use SL::GL; 1; # end of main sub add { &{ "add_$form->{type}" } }; sub edit { &{ "edit_$form->{type}" } }; sub save { &{ "save_$form->{type}" } }; sub delete { &{ "delete_$form->{type}" } }; sub save_as_new { delete $form->{id}; &save; } sub add_account { $form->{title} = "Add"; $form->{charttype} = "A"; $form->{callback} = "$form->{script}?action=list_account&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback}; &account_header; &form_footer; } sub edit_account { $form->{title} = "Edit"; $form->{accno} =~ s/\\'/'/g; $form->{accno} =~ s/\\\\/\\/g; AM->get_account(\%myconfig, \%$form); foreach my $item (split(/:/, $form->{link})) { $form->{$item} = "checked"; } &account_header; &form_footer; } sub account_header { $form->{title} = $locale->text("$form->{title} Account"); $checked{$form->{charttype}} = "checked"; $checked{contra} = "checked" if $form->{contra}; $checked{"$form->{category}_"} = "checked"; for (qw(accno description)) { $form->{$_} = $form->quote($form->{$_}) } # this is for our parser only! # type=submit $locale->text('Add Account') # type=submit $locale->text('Edit Account') $form->header; print qq|
{script}> {id}> {inventory_accno_id}> {income_accno_id}> {expense_accno_id}> {fxgain_accno_id}> {fxloss_accno_id}>
$form->{title}
|; if ($form->{charttype} eq "A") { print qq| |; } print qq|
|.$locale->text('Account Number').qq|
|.$locale->text('Description').qq|
|.$locale->text('Account Type').qq|
 |.$locale->text('Asset').qq|\n
 |.$locale->text('Liability').qq|\n
 |.$locale->text('Equity').qq|\n
 |.$locale->text('Income').qq|\n
 |.$locale->text('Expense') .qq|
 |.$locale->text('Contra').qq|  |.$locale->text('Heading').qq|
 |.$locale->text('Account') .qq|
|.$locale->text('Is this a summary account to record').qq| {AR}> |.$locale->text('AR') .qq| {AP}> |.$locale->text('AP') .qq| {IC}> |.$locale->text('Inventory') .qq|
|.$locale->text('Include in drop-down menus').qq|
|.$locale->text('Receivables').qq| |.$locale->text('Payables').qq| |.$locale->text('Tracking Items').qq| |.$locale->text('Non-tracking Items').qq|
{AR_amount}> |.$locale->text('Income').qq|\n
{AR_paid}> |.$locale->text('Payment').qq|\n
{AR_tax}> |.$locale->text('Tax') .qq|
{AP_amount}> |.$locale->text('Expense/Asset').qq|\n
{AP_paid}> |.$locale->text('Payment').qq|\n
{AP_tax}> |.$locale->text('Tax') .qq|
{IC_sale}> |.$locale->text('Income').qq|\n
{IC_cogs}> |.$locale->text('COGS').qq|\n
{IC_taxpart}> |.$locale->text('Tax') .qq|
{IC_income}> |.$locale->text('Income').qq|\n
{IC_expense}> |.$locale->text('Expense').qq|\n
{IC_taxservice}> |.$locale->text('Tax') .qq|
|.$locale->text('GIFI').qq| {gifi_accno}>

|; } sub form_footer { $form->hide_form(qw(callback path login sessionid)); # type=submit $locale->text('Save') # type=submit $locale->text('Save as new') # type=submit $locale->text('Delete') %button = (); if ($form->{id}) { $button{'Save'} = { ndx => 3, key => 'S', value => $locale->text('Save') }; $button{'Save as new'} = { ndx => 7, key => 'N', value => $locale->text('Save as new') }; if ($form->{orphaned}) { $button{'Delete'} = { ndx => 16, key => 'D', value => $locale->text('Delete') }; } } else { $button{'Save'} = { ndx => 3, key => 'S', value => $locale->text('Save') }; } for (sort { $button{$a}->{ndx} <=> $button{$b}->{ndx} } keys %button) { $form->print_button(\%button, $_) } if ($form->{menubar}) { require "$form->{path}/menu.pl"; &menubar; } print qq|
|; } sub save_account { $form->isblank("accno", $locale->text('Account Number missing!')); $form->isblank("category", $locale->text('Account Type missing!')); # check for conflicting accounts if ($form->{AR} || $form->{AP} || $form->{IC}) { $a = ""; for (qw(AR AP IC)) { $a .= $form->{$_} } $form->error($locale->text('Cannot set account for more than one of AR, AP or IC')) if length $a > 2; for (qw(AR_amount AR_tax AR_paid AP_amount AP_tax AP_paid IC_taxpart IC_taxservice IC_sale IC_cogs IC_income IC_expense)) { $form->error("$form->{AR}$form->{AP}$form->{IC} ". $locale->text('account cannot be set to any other type of account')) if $form->{$_} } } foreach $item ("AR", "AP") { $i = 0; for ("${item}_amount", "${item}_paid", "${item}_tax") { $i++ if $form->{$_} } $form->error($locale->text('Cannot set multiple options for')." $item") if $i > 1; } if (AM->save_account(\%myconfig, \%$form)) { $form->redirect($locale->text('Account saved!')); } else { $form->error($locale->text('Cannot save account!')); } } sub list_account { CA->all_accounts(\%myconfig, \%$form); $form->{title} = $locale->text('Chart of Accounts'); # construct callback $callback = "$form->{script}?action=list_account&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; @column_index = qw(accno gifi_accno description debit credit link); $column_header{accno} = qq||.$locale->text('Account').qq||; $column_header{gifi_accno} = qq||.$locale->text('GIFI').qq||; $column_header{description} = qq||.$locale->text('Description').qq||; $column_header{debit} = qq||.$locale->text('Debit').qq||; $column_header{credit} = qq||.$locale->text('Credit').qq||; $column_header{link} = qq||.$locale->text('Link').qq||; $form->header; $colspan = $#column_index + 1; print qq| |; for (@column_index) { print "$column_header{$_}\n" } print qq| |; # escape callback $callback = $form->escape($callback); foreach $ca (@{ $form->{CA} }) { $ca->{debit} = " "; $ca->{credit} = " "; if ($ca->{amount} > 0) { $ca->{credit} = $form->format_amount(\%myconfig, $ca->{amount}, 2, " "); } if ($ca->{amount} < 0) { $ca->{debit} = $form->format_amount(\%myconfig, -$ca->{amount}, 2, " "); } $ca->{link} =~ s/:/
/og; $gifi_accno = $form->escape($ca->{gifi_accno}); if ($ca->{charttype} eq "H") { print qq||; $column_data{accno} = qq||; $column_data{gifi_accno} = qq||; $column_data{description} = qq||; $column_data{debit} = qq||; $column_data{credit} = qq| |; $column_data{link} = qq||; } else { $i++; $i %= 2; print qq| |; $column_data{accno} = qq||; $column_data{gifi_accno} = qq||; $column_data{description} = qq||; $column_data{debit} = qq||; $column_data{credit} = qq||; $column_data{link} = qq||; } for (@column_index) { print "$column_data{$_}\n" } print "\n"; } print qq|
$form->{title}
{script}?action=edit_account&id=$ca->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ca->{accno}{script}?action=edit_gifi&accno=$gifi_accno&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ca->{gifi_accno} $ca->{description}    
{script}?action=edit_account&id=$ca->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ca->{accno}{script}?action=edit_gifi&accno=$gifi_accno&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ca->{gifi_accno} $ca->{description} $ca->{debit}$ca->{credit}$ca->{link} 

|; } sub delete_account { $form->{title} = $locale->text('Delete Account'); foreach $id (qw(inventory_accno_id income_accno_id expense_accno_id fxgain_accno_id fxloss_accno_id)) { if ($form->{id} == $form->{$id}) { $form->error($locale->text('Cannot delete default account!')); } } if (AM->delete_account(\%myconfig, \%$form)) { $form->redirect($locale->text('Account deleted!')); } else { $form->error($locale->text('Cannot delete account!')); } } sub list_gifi { @{ $form->{fields} } = qw(accno description); $form->{table} = "gifi"; AM->gifi_accounts(\%myconfig, \%$form); $form->{title} = $locale->text('GIFI'); # construct callback $callback = "$form->{script}?action=list_gifi&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; @column_index = qw(accno description); $column_header{accno} = qq||.$locale->text('GIFI').qq||; $column_header{description} = qq||.$locale->text('Description').qq||; $form->header; $colspan = $#column_index + 1; print qq| |; for (@column_index) { print "$column_header{$_}\n" } print qq| |; # escape callback $callback = $form->escape($callback); foreach $ca (@{ $form->{ALL} }) { $i++; $i %= 2; print qq| |; $accno = $form->escape($ca->{accno}); $column_data{accno} = qq||; $column_data{description} = qq||; for (@column_index) { print "$column_data{$_}\n" } print "\n"; } print qq|
$form->{title}
{script}?action=edit_gifi&coa=1&accno=$accno&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ca->{accno}$ca->{description} 

|; } sub add_gifi { $form->{title} = "Add"; # construct callback $form->{callback} = "$form->{script}?action=list_gifi&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; $form->{coa} = 1; &gifi_header; &gifi_footer; } sub edit_gifi { $form->{title} = "Edit"; AM->get_gifi(\%myconfig, \%$form); $form->error($locale->text('Account does not exist!')) unless $form->{accno}; &gifi_header; &gifi_footer; } sub gifi_header { $form->{title} = $locale->text("$form->{title} GIFI"); # $locale->text('Add GIFI') # $locale->text('Edit GIFI') for (qw(accno description)) { $form->{$_} = $form->quote($form->{$_}) } $form->header; print qq|
{script}>
$form->{title}
|.$locale->text('GIFI').qq|
|.$locale->text('Description').qq|

|; } sub gifi_footer { $form->hide_form(qw(callback path login sessionid)); # type=submit $locale->text('Save') # type=submit $locale->text('Copy to COA') # type=submit $locale->text('Delete') %button = (); $button{'Save'} = { ndx => 3, key => 'S', value => $locale->text('Save') }; if ($form->{accno}) { if ($form->{orphaned}) { $button{'Delete'} = { ndx => 16, key => 'D', value => $locale->text('Delete') }; } } if ($form->{coa}) { $button{'Copy to COA'} = { ndx => 7, key => 'C', value => $locale->text('Copy to COA') }; } for (sort { $button{$a}->{ndx} <=> $button{$b}->{ndx} } keys %button) { $form->print_button(\%button, $_) } if ($form->{menubar}) { require "$form->{path}/menu.pl"; &menubar; } print qq|
|; } sub save_gifi { $form->isblank("accno", $locale->text('GIFI missing!')); AM->save_gifi(\%myconfig, \%$form); $form->redirect($locale->text('GIFI saved!')); } sub copy_to_coa { $form->isblank("accno", $locale->text('GIFI missing!')); AM->save_gifi(\%myconfig, \%$form); delete $form->{id}; $form->{gifi_accno} = $form->{accno}; $form->{title} = "Add"; $form->{charttype} = "A"; &account_header; &form_footer; } sub delete_gifi { AM->delete_gifi(\%myconfig, \%$form); $form->redirect($locale->text('GIFI deleted!')); } sub add_department { $form->{title} = "Add"; $form->{role} = "P"; $form->{callback} = "$form->{script}?action=add_department&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback}; &department_header; &form_footer; } sub edit_department { $form->{title} = "Edit"; AM->get_department(\%myconfig, \%$form); &department_header; &form_footer; } sub list_department { AM->departments(\%myconfig, \%$form); $href = "$form->{script}?action=list_department&direction=$form->{direction}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; $form->sort_order(); $form->{callback} = "$form->{script}?action=list_department&direction=$form->{direction}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; $callback = $form->escape($form->{callback}); $form->{title} = $locale->text('Departments'); @column_index = qw(description cost profit); $column_header{description} = qq||.$locale->text('Description').qq||; $column_header{cost} = qq||.$locale->text('Cost Center').qq||; $column_header{profit} = qq||.$locale->text('Profit Center').qq||; $form->header; print qq|
$form->{title}
|; for (@column_index) { print "$column_header{$_}\n" } print qq| |; foreach $ref (@{ $form->{ALL} }) { $i++; $i %= 2; print qq| |; $costcenter = ($ref->{role} eq "C") ? "*" : " "; $profitcenter = ($ref->{role} eq "P") ? "*" : " "; $column_data{description} = qq||; $column_data{cost} = qq||; $column_data{profit} = qq||; for (@column_index) { print "$column_data{$_}\n" } print qq| |; } print qq|
{script}?action=edit_department&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{description}$costcenter$profitcenter


{script}> |; $form->{type} = "department"; $form->hide_form(qw(type callback path login sessionid)); print qq| |; if ($form->{menubar}) { require "$form->{path}/menu.pl"; &menubar; } print qq|
|; } sub department_header { $form->{title} = $locale->text("$form->{title} Department"); # $locale->text('Add Department') # $locale->text('Edit Department') $form->{description} = $form->quote($form->{description}); if (($rows = $form->numtextrows($form->{description}, 60)) > 1) { $description = qq||; } else { $description = qq||; } $costcenter = "checked" if $form->{role} eq "C"; $profitcenter = "checked" if $form->{role} eq "P"; $form->header; print qq|
{script}> {id}>
$form->{title}
|.$locale->text('Description').qq| $description
|.$locale->text('Cost Center').qq| |.$locale->text('Profit Center').qq|

|; } sub save_department { $form->isblank("description", $locale->text('Description missing!')); AM->save_department(\%myconfig, \%$form); $form->redirect($locale->text('Department saved!')); } sub delete_department { AM->delete_department(\%myconfig, \%$form); $form->redirect($locale->text('Department deleted!')); } sub add_business { $form->{title} = "Add"; $form->{callback} = "$form->{script}?action=add_business&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback}; &business_header; &form_footer; } sub edit_business { $form->{title} = "Edit"; AM->get_business(\%myconfig, \%$form); &business_header; $form->{orphaned} = 1; &form_footer; } sub list_business { AM->business(\%myconfig, \%$form); $href = "$form->{script}?action=list_business&direction=$form->{direction}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; $form->sort_order(); $form->{callback} = "$form->{script}?action=list_business&direction=$form->{direction}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; $callback = $form->escape($form->{callback}); $form->{title} = $locale->text('Type of Business'); @column_index = qw(description discount); $column_header{description} = qq||.$locale->text('Description').qq||; $column_header{discount} = qq||.$locale->text('Discount').qq| %|; $form->header; print qq|
$form->{title}
|; for (@column_index) { print "$column_header{$_}\n" } print qq| |; foreach $ref (@{ $form->{ALL} }) { $i++; $i %= 2; print qq| |; $discount = $form->format_amount(\%myconfig, $ref->{discount} * 100, 2, " "); $column_data{description} = qq||; $column_data{discount} = qq||; for (@column_index) { print "$column_data{$_}\n" } print qq| |; } print qq|
{script}?action=edit_business&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{description}$discount


{script}> |; $form->{type} = "business"; $form->hide_form(qw(type callback path login sessionid)); print qq| |; if ($form->{menubar}) { require "$form->{path}/menu.pl"; &menubar; } print qq|
|; } sub business_header { $form->{title} = $locale->text("$form->{title} Business"); # $locale->text('Add Business') # $locale->text('Edit Business') $form->{description} = $form->quote($form->{description}); $form->{discount} = $form->format_amount(\%myconfig, $form->{discount} * 100); $form->header; print qq|
{script}> {id}>
$form->{title}
|.$locale->text('Type of Business').qq|
|.$locale->text('Discount').qq| % {discount}>

|; } sub save_business { $form->isblank("description", $locale->text('Description missing!')); AM->save_business(\%myconfig, \%$form); $form->redirect($locale->text('Business saved!')); } sub delete_business { AM->delete_business(\%myconfig, \%$form); $form->redirect($locale->text('Business deleted!')); } sub add_sic { $form->{title} = "Add"; $form->{callback} = "$form->{script}?action=add_sic&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback}; &sic_header; &form_footer; } sub edit_sic { $form->{title} = "Edit"; $form->{code} =~ s/\\'/'/g; $form->{code} =~ s/\\\\/\\/g; AM->get_sic(\%myconfig, \%$form); $form->{id} = $form->{code}; &sic_header; $form->{orphaned} = 1; &form_footer; } sub list_sic { AM->sic(\%myconfig, \%$form); $href = "$form->{script}?action=list_sic&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; $form->sort_order(); $form->{callback} = "$form->{script}?action=list_sic&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; $callback = $form->escape($form->{callback}); $form->{title} = $locale->text('Standard Industrial Codes'); @column_index = $form->sort_columns(qw(code description)); $column_header{code} = qq||.$locale->text('Code').qq||; $column_header{description} = qq||.$locale->text('Description').qq||; $form->header; print qq|
$form->{title}
|; for (@column_index) { print "$column_header{$_}\n" } print qq| |; foreach $ref (@{ $form->{ALL} }) { $i++; $i %= 2; if ($ref->{sictype} eq 'H') { print qq| |; $column_data{code} = qq||; $column_data{description} = qq||; } else { print qq| |; $column_data{code} = qq||; $column_data{description} = qq||; } for (@column_index) { print "$column_data{$_}\n" } print qq| |; } print qq|
{script}?action=edit_sic&code=$ref->{code}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{code}$ref->{description}
{script}?action=edit_sic&code=$ref->{code}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{code}$ref->{description}


{script}> |; $form->{type} = "sic"; $form->hide_form(qw(type callback path login sessionid)); print qq| |; if ($form->{menubar}) { require "$form->{path}/menu.pl"; &menubar; } print qq|
|; } sub sic_header { $form->{title} = $locale->text("$form->{title} SIC"); # $locale->text('Add SIC') # $locale->text('Edit SIC') for (qw(code description)) { $form->{$_} = $form->quote($form->{$_}) } $checked = ($form->{sictype} eq 'H') ? "checked" : ""; $form->header; print qq|
{script}>
$form->{title}
|.$locale->text('Code').qq|
|.$locale->text('Heading').qq|
|.$locale->text('Description').qq|

|; } sub save_sic { $form->isblank("code", $locale->text('Code missing!')); $form->isblank("description", $locale->text('Description missing!')); AM->save_sic(\%myconfig, \%$form); $form->redirect($locale->text('SIC saved!')); } sub delete_sic { AM->delete_sic(\%myconfig, \%$form); $form->redirect($locale->text('SIC deleted!')); } sub add_language { $form->{title} = "Add"; $form->{callback} = "$form->{script}?action=add_language&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback}; &language_header; &form_footer; } sub edit_language { $form->{title} = "Edit"; $form->{code} =~ s/\\'/'/g; $form->{code} =~ s/\\\\/\\/g; AM->get_language(\%myconfig, \%$form); $form->{id} = $form->{code}; &language_header; $form->{orphaned} = 1; &form_footer; } sub list_language { AM->language(\%myconfig, \%$form); $href = "$form->{script}?action=list_language&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; $form->sort_order(); $form->{callback} = "$form->{script}?action=list_language&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; $callback = $form->escape($form->{callback}); $form->{title} = $locale->text('Languages'); @column_index = $form->sort_columns(qw(code description)); $column_header{code} = qq||.$locale->text('Code').qq||; $column_header{description} = qq||.$locale->text('Description').qq||; $form->header; print qq|
$form->{title}
|; for (@column_index) { print "$column_header{$_}\n" } print qq| |; foreach $ref (@{ $form->{ALL} }) { $i++; $i %= 2; print qq| |; $column_data{code} = qq||; $column_data{description} = qq||; for (@column_index) { print "$column_data{$_}\n" } print qq| |; } print qq|
{script}?action=edit_language&code=$ref->{code}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{code}$ref->{description}


{script}> |; $form->{type} = "language"; $form->hide_form(qw(type callback path login sessionid)); print qq| |; if ($form->{menubar}) { require "$form->{path}/menu.pl"; &menubar; } print qq|
|; } sub language_header { $form->{title} = $locale->text("$form->{title} Language"); # $locale->text('Add Language') # $locale->text('Edit Language') for (qw(code description)) { $form->{$_} = $form->quote($form->{$_}) } $form->header; print qq|
{script}>
$form->{title}
|.$locale->text('Code').qq|
|.$locale->text('Description').qq|

|; } sub save_language { $form->isblank("code", $locale->text('Code missing!')); $form->isblank("description", $locale->text('Description missing!')); $form->{code} =~ s/(\.\.|\*)//g; AM->save_language(\%myconfig, \%$form); if (! -d "$myconfig{templates}/$form->{code}") { umask(002); if (mkdir "$myconfig{templates}/$form->{code}", oct("771")) { umask(007); opendir TEMPLATEDIR, "$myconfig{templates}" or $form->error("$myconfig{templates} : $!"); @templates = grep !/^(\.|\.\.)/, readdir TEMPLATEDIR; closedir TEMPLATEDIR; foreach $file (@templates) { if (-f "$myconfig{templates}/$file") { open(TEMP, "$myconfig{templates}/$file") or $form->error("$myconfig{templates}/$file : $!"); open(NEW, ">$myconfig{templates}/$form->{code}/$file") or $form->error("$myconfig{templates}/$form->{code}/$file : $!"); while ($line = ) { print NEW $line; } close(TEMP); close(NEW); } } } else { $form->error("${templates}/$form->{code} : $!"); } } $form->redirect($locale->text('Language saved!')); } sub delete_language { $form->{title} = $locale->text('Confirm!'); $form->header; print qq| {script}> |; for (qw(action nextsub)) { delete $form->{$_} } $form->hide_form; print qq|

$form->{title}

|.$locale->text('Deleting a language will also delete the templates for the language').qq| $form->{invnumber}

|; } sub yes_delete_language { AM->delete_language(\%myconfig, \%$form); # delete templates $dir = "$myconfig{templates}/$form->{code}"; if (-d $dir) { unlink <$dir/*>; rmdir "$myconfig{templates}/$form->{code}"; } $form->redirect($locale->text('Language deleted!')); } sub display_stylesheet { $form->{file} = "css/$myconfig{stylesheet}"; &display_form; } sub list_templates { AM->language(\%myconfig, \%$form); if (! @{ $form->{ALL} }) { &display_form; exit; } unshift @{ $form->{ALL} }, { code => '.', description => $locale->text('Default Template') }; $href = "$form->{script}?action=list_templates&direction=$form->{direction}&oldsort=$form->{oldsort}&file=$form->{file}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; $form->sort_order(); $form->{callback} = "$form->{script}?action=list_templates&direction=$form->{direction}&oldsort=$form->{oldsort}&file=$form->{file}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; $callback = $form->escape($form->{callback}); chomp $myconfig{templates}; $form->{file} =~ s/$myconfig{templates}//; $form->{file} =~ s/\///; $form->{title} = $form->{file}; @column_index = $form->sort_columns(qw(code description)); $column_header{code} = qq||.$locale->text('Code').qq||; $column_header{description} = qq||.$locale->text('Description').qq||; $form->header; print qq|
$form->{title}
|; for (@column_index) { print "$column_header{$_}\n" } print qq| |; foreach $ref (@{ $form->{ALL} }) { $i++; $i %= 2; print qq| |; $column_data{code} = qq||; $column_data{description} = qq||; for (@column_index) { print "$column_data{$_}\n" } print qq| |; } print qq|
{script}?action=display_form&file=$myconfig{templates}/$ref->{code}/$form->{file}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&code=$ref->{code}&callback=$callback>$ref->{code}$ref->{description}


{script}> {path}> {login}> {sessionid}> |; if ($form->{menubar}) { require "$form->{path}/menu.pl"; &menubar; } print qq|
|; } sub display_form { $form->{file} =~ s/^(.:)*?\/|\.\.\///g; $form->{file} =~ s/^\/*//g; $form->{file} =~ s/$userspath//; $form->{file} =~ s/$memberfile//; $form->error("$!: $form->{file}") unless -f $form->{file}; AM->load_template(\%$form); $form->{title} = $form->{file}; $form->{body} =~ s/<%include (.*?)%>/{script}\?action=display_form&file=$myconfig{templates}\/$form->{code}\/$1&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}>$1<\/a>/g; # if it is anything but html if ($form->{file} !~ /\.html$/) { $form->{body} = "
\n$form->{body}\n
"; } $form->header; print qq| $form->{body}
{script}> |; $form->{type} = "template"; $form->hide_form(qw(file type path login sessionid)); print qq| |; if ($form->{menubar}) { require "$form->{path}/menu.pl"; &menubar; } print qq|
|; } sub edit_template { AM->load_template(\%$form); $form->{title} = $locale->text('Edit Template'); # convert   to &nbsp; $form->{body} =~ s/ /&nbsp;/gi; $form->header; print qq|
{script}> {file}> {path}> {login}> {sessionid}>
|; if ($form->{menubar}) { require "$form->{path}/menu.pl"; &menubar; } print q|
|; } sub save_template { AM->save_template(\%$form); $form->redirect($locale->text('Template saved!')); } sub defaults { # get defaults for account numbers and last numbers AM->defaultaccounts(\%myconfig, \%$form); foreach $key (keys %{ $form->{accno} }) { foreach $accno (sort keys %{ $form->{accno}{$key} }) { $form->{account}{$key} .= "

"; if ($form->{removeaudittrail}) { $msg .= $locale->text('Audit trail removed up to') ." ".$locale->date(\%myconfig, $form->{removeaudittrail}, 1); } $form->redirect($msg); } sub add_warehouse { $form->{title} = "Add"; $form->{callback} = "$form->{script}?action=add_warehouse&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback}; &warehouse_header; &form_footer; } sub edit_warehouse { $form->{title} = "Edit"; AM->get_warehouse(\%myconfig, \%$form); &warehouse_header; &form_footer; } sub list_warehouse { AM->warehouses(\%myconfig, \%$form); $href = "$form->{script}?action=list_warehouse&direction=$form->{direction}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; $form->sort_order(); $form->{callback} = "$form->{script}?action=list_warehouse&direction=$form->{direction}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; $callback = $form->escape($form->{callback}); $form->{title} = $locale->text('Warehouses'); @column_index = qw(description); $column_header{description} = qq||.$locale->text('Description').qq||; $form->header; print qq|
$form->{title}
|; for (@column_index) { print "$column_header{$_}\n" } print qq| |; foreach $ref (@{ $form->{ALL} }) { $i++; $i %= 2; print qq| |; $column_data{description} = qq||; for (@column_index) { print "$column_data{$_}\n" } print qq| |; } print qq|
{script}?action=edit_warehouse&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{description}


{script}> |; $form->{type} = "warehouse"; $form->hide_form(qw(type callback path login sessionid)); print qq| |; if ($form->{menubar}) { require "$form->{path}/menu.pl"; &menubar; } print qq|
|; } sub warehouse_header { $form->{title} = $locale->text("$form->{title} Warehouse"); # $locale->text('Add Warehouse') # $locale->text('Edit Warehouse') $form->{description} = $form->quote($form->{description}); if (($rows = $form->numtextrows($form->{description}, 60)) > 1) { $description = qq||; } else { $description = qq||; } $form->header; print qq|
{script}> {id}>
$form->{title}
|.$locale->text('Description').qq| $description

|; } sub save_warehouse { $form->isblank("description", $locale->text('Description missing!')); AM->save_warehouse(\%myconfig, \%$form); $form->redirect($locale->text('Warehouse saved!')); } sub delete_warehouse { AM->delete_warehouse(\%myconfig, \%$form); $form->redirect($locale->text('Warehouse deleted!')); } sub yearend { AM->earningsaccounts(\%myconfig, \%$form); $chart = ""; for (@{ $form->{chart} }) { $chart .= "
|; } sub edit_recurring { %links = ( ar => 'create_links', ap => 'create_links', gl => 'create_links', is => 'invoice_links', ir => 'invoice_links', oe => 'order_links', ); %prepare = ( is => 'prepare_invoice', ir => 'prepare_invoice', oe => 'prepare_order', ); $form->{callback} = "$form->{script}?action=recurring_transactions&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; $form->{type} = "transaction"; if ($form->{module} eq 'ar') { if ($form->{invoice}) { $form->{type} = "invoice"; $form->{module} = "is"; } } if ($form->{module} eq 'ap') { if ($form->{invoice}) { $form->{type} = "invoice"; $form->{module} = "ir"; } } if ($form->{module} eq 'oe') { %tr = ( so => sales_order, po => purchase_order, ); $form->{type} = $tr{$form->{transaction}}; } $form->{script} = "$form->{module}.pl"; do "$form->{path}/$form->{script}"; &{ $links{$form->{module}} }; # return if transaction doesn't exist $form->redirect unless $form->{recurring}; if ($prepare{$form->{module}}) { &{ $prepare{$form->{module}} }; } $form->{selectformat} = qq|