1 #=====================================================================
2 # SQL-Ledger, Accounting
5 # Author: Dieter Simader
6 # Email: dsimader@sql-ledger.org
7 # Web: http://www.sql-ledger.org
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #======================================================================
26 #======================================================================
38 $label = "Add ".ucfirst $form->{db};
39 $form->{title} = $locale->text($label);
41 $form->{callback} = "$form->{script}?action=add&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback};
43 &{ "$form->{db}_links" };
48 sub search { &{ "search_$form->{db}" } };
53 $form->{title} = $locale->text('Employees');
60 <form method=post action=$form->{script}>
64 <th class=listtop>$form->{title}</th>
71 <th align=right nowrap>|.$locale->text('Employee Number').qq|</th>
72 <td colspan=3><input name=employeenumber size=20></td>
75 <th align=right nowrap>|.$locale->text('Employee Name').qq|</th>
76 <td colspan=3><input name=name size=35></td>
79 <th align=right nowrap>|.$locale->text('Startdate').qq|</th>
80 <td><input name=startdate size=11 title="$myconfig{dateformat}" value=$form->{startdate}></td>
81 <th>|.$locale->text('Enddate').qq|</th>
82 <td><input name=enddate size=11 title="$myconfig{dateformat}" value=$form->{enddate}></td>
85 <th align=right nowrap>|.$locale->text('Notes').qq|</th>
86 <td colspan=3><input name=notes size=40></td>
90 <td colspan=3><input name=status class=radio type=radio value=all checked> |.$locale->text('All').qq|
91 <input name=status class=radio type=radio value=sales> |.$locale->text('Sales').qq|
92 <input name=status class=radio type=radio value=orphaned> |.$locale->text('Orphaned').qq|</td>
95 <th align=right nowrap>|.$locale->text('Include in Report').qq|</th>
99 <td><input name="l_id" type=checkbox class=checkbox value=Y> |.$locale->text('ID').qq|</td>
100 <td><input name="l_employeenumber" type=checkbox class=checkbox value=Y checked> |.$locale->text('Employee Number').qq|</td>
101 <td><input name="l_name" type=checkbox class=checkbox value=Y checked> |.$locale->text('Employee Name').qq|</td>
102 <td><input name="l_address" type=checkbox class=checkbox value=Y> |.$locale->text('Address').qq|</td>
103 <td><input name="l_city" type=checkbox class=checkbox value=Y> |.$locale->text('City').qq|</td>
106 <td><input name="l_state" type=checkbox class=checkbox value=Y> |.$locale->text('State/Province').qq|</td>
107 <td><input name="l_zipcode" type=checkbox class=checkbox value=Y> |.$locale->text('Zip/Postal Code').qq|</td>
108 <td><input name="l_country" type=checkbox class=checkbox value=Y> |.$locale->text('Country').qq|</td>
109 <td><input name="l_workphone" type=checkbox class=checkbox value=Y checked> |.$locale->text('Work Phone').qq|</td>
112 <td><input name="l_homephone" type=checkbox class=checkbox value=Y checked> |.$locale->text('Home Phone').qq|</td>
113 <td><input name="l_startdate" type=checkbox class=checkbox value=Y checked> |.$locale->text('Startdate').qq|</td>
114 <td><input name="l_enddate" type=checkbox class=checkbox value=Y checked> |.$locale->text('Enddate').qq|</td>
115 <td><input name="l_sales" type=checkbox class=checkbox value=Y> |.$locale->text('Sales').qq|</td>
118 <td><input name="l_manager" type=checkbox class=checkbox value=Y> |.$locale->text('Manager').qq|</td>
119 <td><input name="l_role" type=checkbox class=checkbox value=Y checked> |.$locale->text('Role').qq|</td>
120 <td><input name="l_login" type=checkbox class=checkbox value=Y checked> |.$locale->text('Login').qq|</td>
121 <td><input name="l_email" type=checkbox class=checkbox value=Y> |.$locale->text('E-mail').qq|</td>
124 <td><input name="l_ssn" type=checkbox class=checkbox value=Y> |.$locale->text('SSN').qq|</td>
125 <td><input name="l_dob" type=checkbox class=checkbox value=Y> |.$locale->text('DOB').qq|</td>
126 <td><input name="l_iban" type=checkbox class=checkbox value=Y> |.$locale->text('IBAN').qq|</td>
127 <td><input name="l_bic" type=checkbox class=checkbox value=Y> |.$locale->text('BIC').qq|</td>
128 <td><input name="l_notes" type=checkbox class=checkbox value=Y> |.$locale->text('Notes').qq|</td>
137 <td><hr size=3 noshade></td>
141 <input type=hidden name=nextsub value=list_employees>
142 <input type=hidden name=db value=$form->{db}>
144 <input type=hidden name=path value=$form->{path}>
145 <input type=hidden name=login value=$form->{login}>
146 <input type=hidden name=sessionid value=$form->{sessionid}>
149 <input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
160 HR->employees(\%myconfig, \%$form);
162 $href = "$form->{script}?action=list_employees&direction=$form->{direction}&oldsort=$form->{oldsort}&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&status=$form->{status}";
166 $callback = "$form->{script}?action=list_employees&direction=$form->{direction}&oldsort=$form->{oldsort}&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&status=$form->{status}";
168 @columns = $form->sort_columns(qw(id employeenumber name address city state zipcode country workphone homephone email startdate enddate ssn dob iban bic sales role manager login notes));
170 foreach $item (@columns) {
171 if ($form->{"l_$item"} eq "Y") {
172 push @column_index, $item;
174 # add column to href and callback
175 $callback .= "&l_$item=Y";
176 $href .= "&l_$item=Y";
180 %role = ( user => $locale->text('User'),
181 supervisor => $locale->text('Supervisor'),
182 manager => $locale->text('Manager'),
183 admin => $locale->text('Administrator')
186 $option = $locale->text('All');
188 if ($form->{status} eq 'sales') {
189 $option = $locale->text('Sales');
191 if ($form->{status} eq 'orphaned') {
192 $option = $locale->text('Orphaned');
194 if ($form->{employeenumber}) {
195 $callback .= "&employeenumber=".$form->escape($form->{employeenumber},1);
196 $href .= "&employeenumber=".$form->escape($form->{employeenumber});
197 $option .= "\n<br>".$locale->text('Employee Number')." : $form->{employeenumber}";
200 $callback .= "&name=".$form->escape($form->{name},1);
201 $href .= "&name=".$form->escape($form->{name});
202 $option .= "\n<br>".$locale->text('Employee Name')." : $form->{name}";
204 if ($form->{startdate}) {
205 $callback .= "&startdate=$form->{startdate}";
206 $href .= "&startdate=$form->{startdate}";
207 $option .= "\n<br>" if ($option);
208 $option .= $locale->text('Startdate')." ".$locale->date(\%myconfig, $form->{startdate}, 1);
210 if ($form->{enddate}) {
211 $callback .= "&enddate=$form->{enddate}";
212 $href .= "&enddate=$form->{enddate}";
213 $option .= "\n<br>" if ($option);
214 $option .= $locale->text('Enddate')." ".$locale->date(\%myconfig, $form->{enddate}, 1);
216 if ($form->{notes}) {
217 $callback .= "¬es=".$form->escape($form->{notes},1);
218 $href .= "¬es=".$form->escape($form->{notes});
219 $option .= "\n<br>" if $option;
220 $option .= $locale->text('Notes')." : $form->{notes}";
223 $form->{callback} = "$callback&sort=$form->{sort}";
224 $callback = $form->escape($form->{callback});
226 $column_header{id} = qq|<th class=listheading>|.$locale->text('ID').qq|</th>|;
227 $column_header{employeenumber} = qq|<th><a class=listheading href=$href&sort=employeenumber>|.$locale->text('Number').qq|</a></th>|;
228 $column_header{name} = qq|<th><a class=listheading href=$href&sort=name>|.$locale->text('Name').qq|</a></th>|;
229 $column_header{manager} = qq|<th><a class=listheading href=$href&sort=manager>|.$locale->text('Manager').qq|</a></th>|;
230 $column_header{address} = qq|<th class=listheading>|.$locale->text('Address').qq|</a></th>|;
231 $column_header{city} = qq|<th><a class=listheading href=$href&sort=city>|.$locale->text('City').qq|</a></th>|;
232 $column_header{state} = qq|<th><a class=listheading href=$href&sort=state>|.$locale->text('State/Province').qq|</a></th>|;
233 $column_header{zipcode} = qq|<th><a class=listheading href=$href&sort=zipcode>|.$locale->text('Zip/Postal Code').qq|</a></th>|;
234 $column_header{country} = qq|<th><a class=listheading href=$href&sort=country>|.$locale->text('Country').qq|</a></th>|;
235 $column_header{workphone} = qq|<th><a class=listheading href=$href&sort=workphone>|.$locale->text('Work Phone').qq|</a></th>|;
236 $column_header{homephone} = qq|<th><a class=listheading href=$href&sort=homephone>|.$locale->text('Home Phone').qq|</a></th>|;
238 $column_header{startdate} = qq|<th><a class=listheading href=$href&sort=startdate>|.$locale->text('Startdate').qq|</a></th>|;
239 $column_header{enddate} = qq|<th><a class=listheading href=$href&sort=enddate>|.$locale->text('Enddate').qq|</a></th>|;
240 $column_header{notes} = qq|<th><a class=listheading href=$href&sort=notes>|.$locale->text('Notes').qq|</a></th>|;
241 $column_header{role} = qq|<th><a class=listheading href=$href&sort=role>|.$locale->text('Role').qq|</a></th>|;
242 $column_header{login} = qq|<th><a class=listheading href=$href&sort=login>|.$locale->text('Login').qq|</a></th>|;
244 $column_header{sales} = qq|<th class=listheading>|.$locale->text('S').qq|</th>|;
245 $column_header{email} = qq|<th><a class=listheading href=$href&sort=email>|.$locale->text('E-mail').qq|</a></th>|;
246 $column_header{ssn} = qq|<th><a class=listheading href=$href&sort=ssn>|.$locale->text('SSN').qq|</a></th>|;
247 $column_header{dob} = qq|<th><a class=listheading href=$href&sort=dob>|.$locale->text('DOB').qq|</a></th>|;
248 $column_header{iban} = qq|<th><a class=listheading href=$href&sort=iban>|.$locale->text('IBAN').qq|</a></th>|;
249 $column_header{bic} = qq|<th><a class=listheading href=$href&sort=bic>|.$locale->text('BIC').qq|</a></th>|;
251 $form->{title} = $locale->text('Employees');
260 <th class=listtop>$form->{title}</th>
269 <tr class=listheading>
272 map { print "$column_header{$_}\n" } @column_index;
278 foreach $ref (@{ $form->{all_employee} }) {
280 map { $column_data{$_} = "<td>$ref->{$_} </td>" } @column_index;
282 $column_data{sales} = ($ref->{sales}) ? "<td>x</td>" : "<td> </td>";
283 $column_data{role} = qq|<td>$role{"$ref->{role}"} </td>|;
284 $column_date{address} = qq|$ref->{address1} $ref->{address2}|;
286 $column_data{name} = "<td><a href=$form->{script}?action=edit&db=employee&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&status=$form->{status}&callback=$callback>$ref->{name} </td>";
289 $email = $ref->{email};
290 $email =~ s/</\</;
291 $email =~ s/>/\>/;
293 $column_data{email} = qq|<td><a href="mailto:$ref->{email}">$email</a></td>|;
301 map { print "$column_data{$_}\n" } @column_index;
310 $button{'HR--Employees--Add Employee'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Add Employee').qq|"> |;
311 $button{'HR--Employees--Add Employee'}{order} = $i++;
313 foreach $item (split /;/, $myconfig{acs}) {
314 delete $button{$item};
322 <td><hr size=3 noshade></td>
327 <form method=post action=$form->{script}>
329 <input name=callback type=hidden value="$form->{callback}">
331 <input type=hidden name=db value=$form->{db}>
333 <input type=hidden name=path value=$form->{path}>
334 <input type=hidden name=login value=$form->{login}>
335 <input type=hidden name=sessionid value=$form->{sessionid}>
338 foreach $item (sort { $a->{order} <=> $b->{order} } %button) {
342 if ($form->{menubar}) {
343 require "$form->{path}/menu.pl";
359 # $locale->text('Edit Employee')
360 # $locale->text('Edit Deduction')
362 $label = ucfirst $form->{db};
363 $form->{title} = "Edit $label";
365 &{ "$form->{db}_links" };
372 #$form->{deductions} = 1;
373 HR->get_employee(\%myconfig, \%$form);
375 map { $form->{$_} = $form->quote($form->{$_}) } keys %$form;
377 if ($form->{all_deduction}) {
378 $form->{selectdeduction} = "<option>\n";
379 map { $form->{selectdeduction} .= qq|<option value="$_->{description}--$_->{id}">$_->{description}\n| } @{ $form->{all_deduction} };
382 $form->{manager} = "$form->{manager}--$form->{managerid}";
384 if ($form->{all_manager}) {
385 $form->{selectmanager} = "<option>\n";
386 map { $form->{selectmanager} .= qq|<option value="$_->{name}--$_->{id}">$_->{name}\n| } @{ $form->{all_manager} };
389 %role = ( user => $locale->text('User'),
390 supervisor => $locale->text('Supervisor'),
391 manager => $locale->text('Manager'),
392 admin => $locale->text('Administrator')
395 $form->{selectrole} = "<option>\n";
396 map { $form->{selectrole} .= "<option value=$_>$role{$_}\n" } qw(user supervisor manager admin);
399 foreach $ref (@{ $form->{all_employeededuction} }) {
400 $form->{"deduction_$i"} = "$ref->{description}--$ref->{id}";
401 map { $form->{"${_}_$i"} = $ref->{$_} } qw(before after rate);
404 $form->{deduction_rows} = $i - 1;
412 sub employee_header {
414 $sales = qq|<input type=hidden name=sales value=$form->{sales}>|;
415 $form->{sales} = ($form->{sales}) ? "checked" : "";
417 $form->{selectrole} =~ s/ selected//;
418 $form->{selectrole} =~ s/option value=\Q$form->{role}\E>/option value=$form->{role} selected>/;
420 $form->{selectdeduction} = $form->unescape($form->{selectdeduction});
422 $form->{selectmanager} = $form->unescape($form->{selectmanager});
423 $form->{selectmanager} =~ s/ selected//;
424 $form->{selectmanager} =~ s/(<option value="\Q$form->{manager}\E")/$1 selected/;
427 <input type=hidden name=role value=$form->{role}>
428 <input type=hidden name=manager value=$form->{manager}>
431 if ($myconfig{role} ne 'user') {
434 <th align=right>|.$locale->text('Sales').qq|</th>
435 <td><input name=sales class=checkbox type=checkbox value=1 $form->{sales}></td>
438 <th align=right>|.$locale->text('Role').qq|</th>
439 <td><select name=role>$form->{selectrole}</select></td>
443 if ($form->{selectmanager}) {
446 <th align=right>|.$locale->text('Manager').qq|</th>
447 <td><select name=manager>$form->{selectmanager}</select></td>
453 $form->{deduction_rows}++;
455 for ($i = 1; $i <= $form->{deduction_rows}; $i++) {
456 $form->{"selectdeduction_$i"} = $form->{selectdeduction};
457 if ($form->{"deduction_$i"}) {
458 $form->{"selectdeduction_$i"} =~ s/(<option value="\Q$form->{"deduction_$i"}\E")/$1 selected/;
462 $form->{selectdeduction} = $form->escape($form->{selectdeduction},1);
463 $form->{selectmanager} = $form->escape($form->{selectmanager},1);
470 <form method=post action=$form->{script}>
472 <input type=hidden name=selectdeduction value="$form->{selectdeduction}">
473 <input type=hidden name=deduction_rows value=$form->{deduction_rows}>
475 <input type=hidden name=selectmanager value="$form->{selectmanager}">
476 <input type=hidden name=selectrole value="$form->{selectrole}">
478 <input type=hidden name=status value=$form->{status}>
480 <input type=hidden name=title value="$form->{title}">
484 <th class=listtop>$form->{title}</th>
494 <th align=right nowrap>|.$locale->text('Number').qq|</th>
495 <td><input name=employeenumber size=32 maxlength=32 value="$form->{employeenumber}"></td>
498 <th align=right nowrap>|.$locale->text('Name').qq|</th>
499 <td><input name=name size=35 maxlength=64 value="$form->{name}"></td>
502 <th align=right nowrap>|.$locale->text('Address').qq|</th>
503 <td><input name=address1 size=35 maxlength=32 value="$form->{address1}"></td>
507 <td><input name=address2 size=35 maxlength=32 value="$form->{address2}"></td>
510 <th align=right nowrap>|.$locale->text('City').qq|</th>
511 <td><input name=city size=35 maxlength=32 value="$form->{city}"></td>
514 <th align=right nowrap>|.$locale->text('State/Province').qq|</th>
515 <td><input name=state size=35 maxlength=32 value="$form->{state}"></td>
518 <th align=right nowrap>|.$locale->text('Zip/Postal Code').qq|</th>
519 <td><input name=zipcode size=10 maxlength=10 value="$form->{zipcode}"></td>
522 <th align=right nowrap>|.$locale->text('Country').qq|</th>
523 <td><input name=country size=35 maxlength=32 value="$form->{country}"></td>
526 <th align=right nowrap>|.$locale->text('E-mail').qq|</th>
527 <td><input name=email size=35 value="$form->{email}"></td>
536 <th align=right nowrap>|.$locale->text('Work Phone').qq|</th>
537 <td><input name=workphone size=20 maxlength=20 value="$form->{workphone}"></td>
540 <th align=right nowrap>|.$locale->text('Home Phone').qq|</th>
541 <td><input name=homephone size=20 maxlength=20 value="$form->{homephone}"></td>
544 <th align=right nowrap>|.$locale->text('Startdate').qq|</th>
545 <td><input name=startdate size=11 title="$myconfig{dateformat}" value=$form->{startdate}></td>
548 <th align=right nowrap>|.$locale->text('Enddate').qq|</th>
549 <td><input name=enddate size=11 title="$myconfig{dateformat}" value=$form->{enddate}></td>
553 <th align=right nowrap>|.$locale->text('SSN').qq|</th>
554 <td><input name=ssn size=20 maxlength=20 value="$form->{ssn}"></td>
557 <th align=right nowrap>|.$locale->text('DOB').qq|</th>
558 <td><input name=dob size=11 title="$myconfig{dateformat}" value=$form->{dob}></td>
561 <th align=right nowrap>|.$locale->text('IBAN').qq|</th>
562 <td><input name=iban size=34 maxlength=34 value="$form->{iban}"></td>
565 <th align=right nowrap>|.$locale->text('BIC').qq|</th>
566 <td><input name=bic size=11 maxlength=11 value="$form->{bic}"></td>
575 <th align=left nowrap>|.$locale->text('Notes').qq|</th>
578 <td><textarea name=notes rows=3 cols=60 wrap=soft>$form->{notes}</textarea></td>
582 if ($form->{selectdeduction}) {
588 <tr class=listheading>
589 <th class=listheading>|.$locale->text('Payroll Deduction').qq|</th>
590 <th class=listheading colspan=3>|.$locale->text('Allowances').qq|</th>
593 <tr class=listheading>
595 <th class=listheading>|.$locale->text('Before Deduction').qq|</th>
596 <th class=listheading>|.$locale->text('After Deduction').qq|</th>
597 <th class=listheading>|.$locale->text('Rate').qq|</th>
601 for ($i = 1; $i <= $form->{deduction_rows}; $i++) {
604 <td><select name="deduction_$i">$form->{"selectdeduction_$i"}</select></td>
605 <td><input name="before_$i" value=|.$form->format_amount(\%myconfig, $form->{"before_$i"}, 2).qq|></td>
606 <td><input name="after_$i" value=|.$form->format_amount(\%myconfig, $form->{"after_$i"}, 2).qq|></td>
607 <td><input name="rate_$i" size=5 value=|.$form->format_amount(\%myconfig, $form->{"rate_$i"}).qq|></td>
618 <td><hr size=3 noshade></td>
627 sub employee_footer {
630 <input name=id type=hidden value=$form->{id}>
632 <input type=hidden name=db value=$form->{db}>
633 <input type=hidden name=employeelogin value=$form->{employeelogin}>
635 <input type=hidden name=path value=$form->{path}>
636 <input type=hidden name=login value=$form->{login}>
637 <input type=hidden name=sessionid value=$form->{sessionid}>
639 <input type=hidden name=callback value="$form->{callback}">
643 <input class=submit type=submit name=action value="|.$locale->text('Update').qq|">
644 <input class=submit type=submit name=action value="|.$locale->text('Save').qq|">
648 print qq|<input class=submit type=submit name=action value="|.$locale->text('Save as new').qq|">\n|;
649 if ($form->{status} eq 'orphaned') {
650 print qq|<input class=submit type=submit name=action value="|.$locale->text('Delete').qq|">\n|;
654 if ($form->{menubar}) {
655 require "$form->{path}/menu.pl";
670 sub save { &{ "save_$form->{db}" } };
675 $form->isblank("name", $locale->text("Name missing!"));
676 HR->save_employee(\%myconfig, \%$form);
678 # if it is a login change memberfile and .conf
679 if ($form->{employeelogin}) {
680 $user = new User $memberfile, $form->{employeelogin};
682 map { $user->{$_} = $form->{$_} } qw(name email role);
683 map { $user->{"old_$_"} = $user->{$_} } qw(dbpassword password);
685 $user->save_member($memberfile, $userspath) if $user->{login};
688 $form->redirect($locale->text('Employee saved!'));
693 sub delete { &{ "delete_$form->{db}" } };
696 sub delete_employee {
698 HR->delete_employee(\%myconfig, \%$form);
699 $form->redirect($locale->text('Employee deleted!'));
704 sub continue { &{ $form->{nextsub} } };
706 sub add_employee { &add };
707 sub add_deduction { &add };
710 sub search_deduction {
712 HR->deductions(\%myconfig, \%$form);
714 $href = "$form->{script}?action=search_deduction&direction=$form->{direction}&oldsort=$form->{oldsort}&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
718 $callback = "$form->{script}?action=search_deduction&direction=$form->{direction}&oldsort=$form->{oldsort}&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
720 @column_index = $form->sort_columns(qw(description rate amount above below employeepays employerpays ap_accno expense_accno));
723 $form->{callback} = $callback;
724 $callback = $form->escape($form->{callback});
726 $column_header{description} = qq|<th class=listheading href=$href>|.$locale->text('Description').qq|</th>|;
727 $column_header{rate} = qq|<th class=listheading nowrap>|.$locale->text('Rate').qq|<br>%</th>|;
728 $column_header{amount} = qq|<th class=listheading>|.$locale->text('Amount').qq|</th>|;
729 $column_header{above} = qq|<th class=listheading>|.$locale->text('Above').qq|</th>|;
730 $column_header{below} = qq|<th class=listheading>|.$locale->text('Below').qq|</th>|;
731 $column_header{employerpays} = qq|<th class=listheading>|.$locale->text('Employer').qq|</th>|;
732 $column_header{employeepays} = qq|<th class=listheading>|.$locale->text('Employee').qq|</th>|;
734 $column_header{ap_accno} = qq|<th class=listheading>|.$locale->text('AP').qq|</th>|;
735 $column_header{expense_accno} = qq|<th class=listheading>|.$locale->text('Expense').qq|</th>|;
737 $form->{title} = $locale->text('Deductions');
746 <th class=listtop>$form->{title}</th>
755 <tr class=listheading>
758 map { print "$column_header{$_}\n" } @column_index;
765 foreach $ref (@{ $form->{all_deduction} }) {
767 $rate = $form->format_amount(\%myconfig, $ref->{rate} * 100, "", " ");
769 $column_data{rate} = "<td align=right>$rate</td>";
771 map { $column_data{$_} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{$_}, 2, " ")."</td>" } qw(amount below above);
773 map { $column_data{$_} = "<td>$ref->{$_} </td>" } qw(ap_accno expense_accno);
775 map { $column_data{$_} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{$_}, "", " ")."</td>" } qw(employerpays employeepays);
777 if ($ref->{description} ne $sameitem) {
778 $column_data{description} = "<td><a href=$form->{script}?action=edit&db=$form->{db}&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{description}</a></td>";
780 $column_data{description} = "<td> </td>";
788 map { print "$column_data{$_}\n" } @column_index;
794 $sameitem = $ref->{description};
799 $button{'HR--Deductions--Add Deduction'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Add Deduction').qq|"> |;
800 $button{'HR--Deductions--Add Deduction'}{order} = $i++;
802 foreach $item (split /;/, $myconfig{acs}) {
803 delete $button{$item};
811 <td><hr size=3 noshade></td>
816 <form method=post action=$form->{script}>
818 <input type=hidden name=db value=$form->{db}>
820 <input name=callback type=hidden value="$form->{callback}">
822 <input type=hidden name=path value=$form->{path}>
823 <input type=hidden name=login value=$form->{login}>
824 <input type=hidden name=sessionid value=$form->{sessionid}>
827 foreach $item (sort { $a->{order} <=> $b->{order} } %button) {
831 if ($form->{menubar}) {
832 require "$form->{path}/menu.pl";
846 sub deduction_links {
848 HR->get_deduction(\%myconfig, \%$form);
851 foreach $ref (@{ $form->{deductionrate} }) {
852 map { $form->{"${_}_$i"} = $ref->{$_} } keys %$ref;
855 $form->{rate_rows} = $i - 1;
858 foreach $ref (@{ $form->{deductionbase} }) {
859 $form->{"base_$i"} = "$ref->{description}--$ref->{id}";
860 $form->{"maximum_$i"} = $ref->{maximum};
863 $form->{base_rows} = $i - 1;
866 foreach $ref (@{ $form->{deductionafter} }) {
867 $form->{"after_$i"} = "$ref->{description}--$ref->{id}";
870 $form->{after_rows} = $i - 1;
872 $form->{employeepays} = 1;
874 $selectaccount = "<option>\n";
875 map { $selectaccount .= "<option>$_->{accno}--$_->{description}\n" } @{ $form->{ap_accounts} };
877 $form->{ap_accno} = qq|$form->{ap_accno}--$form->{ap_description}|;
878 $form->{selectap} = $selectaccount;
880 $selectaccount = "<option>\n";
881 map { $selectaccount .= "<option>$_->{accno}--$_->{description}\n" } @{ $form->{expense_accounts} };
883 $form->{expense_accno} = qq|$form->{expense_accno}--$form->{expense_description}|;
884 $form->{selectexpense} = $selectaccount;
886 map { $form->{"rate_$_"} *= 100 } (1 .. $form->{rate_rows});
888 $form->{selectbase} = "<option>\n";
889 map { $form->{selectbase} .= qq|<option value="$_->{description}--$_->{id}">$_->{description}\n| } @{ $form->{all_deduction} };
897 sub deduction_header {
899 $selectap = $form->{selectap};
900 $selectap =~ s/option>\Q$form->{ap_accno}\E/option selected>$form->{ap_accno}/;
901 $selectexpense = $form->{selectexpense};
902 $selectexpense =~ s/option>\Q$form->{expense_accno}\E/option selected>$form->{expense_accno}/;
905 $form->{rate_rows}++;
906 $form->{base_rows}++;
907 $form->{after_rows}++;
909 $form->{selectbase} = $form->unescape($form->{selectbase});
911 for ($i = 1; $i <= $form->{base_rows}; $i++) {
912 $form->{"selectbase_$i"} = $form->{selectbase};
913 if ($form->{"base_$i"}) {
914 $form->{"selectbase_$i"} =~ s/(<option value="\Q$form->{"base_$i"}\E")/$1 selected/;
917 for ($i = 1; $i <= $form->{after_rows}; $i++) {
918 $form->{"selectafter_$i"} = $form->{selectbase};
919 if ($form->{"after_$i"}) {
920 $form->{"selectafter_$i"} =~ s/(<option value="\Q$form->{"after_$i"}\E")/$1 selected/;
931 <form method=post action=$form->{script}>
933 <input type=hidden name=title value="$form->{title}">
935 <input type=hidden name=selectap value="$form->{selectap}">
936 <input type=hidden name=selectexpense value="$form->{selectexpense}">
937 <input type=hidden name=selectbase value="|.$form->escape($form->{selectbase},1).qq|">
939 <input type=hidden name=rate_rows value=$form->{rate_rows}>
940 <input type=hidden name=base_rows value=$form->{base_rows}>
941 <input type=hidden name=after_rows value=$form->{after_rows}>
945 <th class=listtop>$form->{title}</th>
952 <th align=right nowrap>|.$locale->text('Description').qq|</th>
953 <td><input name=description size=35 value="$form->{description}"></td>
956 <th align=right nowrap>|.$locale->text('AP').qq|</th>
957 <td><select name=ap_accno>$selectap</select></td>
958 <th align=right nowrap>|.$locale->text('Employee pays').qq| x</th>
959 <td><input name=employeepays size=4 value=|.$form->format_amount(\%myconfig, $form->{employeepays}).qq|></td>
962 <th align=right nowrap>|.$locale->text('Expense').qq|</th>
963 <td><select name=expense_accno>$selectexpense</select></td>
964 <th align=right nowrap>|.$locale->text('Employer pays').qq| x</th>
965 <td><input name=employerpays size=4 value=|.$form->format_amount(\%myconfig, $form->{employerpays}).qq|></td>
970 <th align=right nowrap>|.$locale->text('Excempt age <').qq|</th>
971 <td><input name=fromage size=4 value=|.$form->format_amount(\%myconfig, $form->{fromage}).qq|></td>
972 <th align=right nowrap>|.$locale->text('>').qq|</th>
973 <td><input name=toage size=4 value=|.$form->format_amount(\%myconfig, $form->{toage}).qq|>
979 <tr class=listheading>
980 <th class=listheading>|.$locale->text('Rate').qq| %</th>
981 <th class=listheading>|.$locale->text('Amount').qq|</th>
982 <th class=listheading>|.$locale->text('Above').qq|</th>
983 <th class=listheading>|.$locale->text('Below').qq|</th>
987 for ($i = 1; $i <= $form->{rate_rows}; $i++) {
990 <td><input name="rate_$i" size=10 value=|.$form->format_amount(\%myconfig, $form->{"rate_$i"}).qq|></td>
991 <td><input name="amount_$i" size=10 value=|.$form->format_amount(\%myconfig, $form->{"amount_$i"}, 2).qq|></td>
992 <td><input name="above_$i" size=10 value=|.$form->format_amount(\%myconfig, $form->{"above_$i"}, 2).qq|></td>
993 <td><input name="below_$i" size=10 value=|.$form->format_amount(\%myconfig, $form->{"below_$i"}, 2).qq|></td>
1013 $basedon = $locale->text('Based on');
1014 $maximum = $locale->text('Maximum');
1016 for ($i = 1; $i <= $form->{base_rows}; $i++) {
1020 <td><select name="base_$i">$form->{"selectbase_$i"}</select></td>
1022 <td><input name="maximum_$i" value=|.$form->format_amount(\%myconfig, $form->{"maximum_$i"}, 2).qq|></td>
1029 $deductafter = $locale->text('Deduct after');
1031 for ($i = 1; $i <= $form->{after_rows}; $i++) {
1034 <th>$deductafter</th>
1035 <td><select name="after_$i">$form->{"selectafter_$i"}</select></td>
1046 <td><hr size=3 noshade></td>
1055 sub deduction_footer {
1058 <input name=id type=hidden value=$form->{id}>
1060 <input type=hidden name=db value=$form->{db}>
1062 <input type=hidden name=path value=$form->{path}>
1063 <input type=hidden name=login value=$form->{login}>
1064 <input type=hidden name=sessionid value=$form->{sessionid}>
1066 <input type=hidden name=callback value="$form->{callback}">
1070 <input class=submit type=submit name=action value="|.$locale->text("Update").qq|">
1071 <input class=submit type=submit name=action value="|.$locale->text("Save").qq|">
1075 print qq|<input class=submit type=submit name=action value="|.$locale->text('Save as new').qq|">\n|;
1077 if ($form->{status} eq 'orphaned') {
1078 print qq|<input class=submit type=submit name=action value="|.$locale->text('Delete').qq|">\n|;
1082 if ($form->{menubar}) {
1083 require "$form->{path}/menu.pl";
1098 sub update { &{ "update_$form->{db}" }; }
1099 sub save { &{ "save_$form->{db}" } };
1102 sub update_deduction {
1104 # if rate or amount is blank remove row
1105 @flds = qw(rate amount above below);
1108 for $i (1 .. $form->{rate_rows}) {
1109 map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } @flds;
1110 if ($form->{"rate_$i"} || $form->{"amount_$i"}) {
1114 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
1118 $form->redo_rows(\@flds, \@a, $count, $form->{rate_rows});
1119 $form->{rate_rows} = $count;
1122 @flds = qw(base maximum);
1125 for $i (1 .. $form->{"base_rows"}) {
1126 $form->{"maximum_$i"} = $form->parse_amount(\%myconfig, $form->{"maximum_$i"});
1127 if ($form->{"base_$i"}) {
1131 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
1135 $form->redo_rows(\@flds, \@a, $count, $form->{"base_rows"});
1136 $form->{"base_rows"} = $count;
1142 for $i (1 .. $form->{"after_rows"}) {
1143 if ($form->{"after_$i"}) {
1147 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
1151 $form->redo_rows(\@flds, \@a, $count, $form->{"after_rows"});
1152 $form->{"after_rows"} = $count;
1160 sub update_employee {
1162 # if rate or amount is blank remove row
1163 @flds = qw(before after);
1166 for $i (1 .. $form->{deduction_rows}) {
1167 map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } @flds;
1168 if ($form->{"deduction_$i"}) {
1172 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
1176 $form->redo_rows(\@flds, \@a, $count, $form->{deduction_rows});
1177 $form->{deduction_rows} = $count;
1188 delete $form->{employeelogin};
1195 sub save_deduction {
1197 $form->isblank("description", $locale->text("Description missing!"));
1199 unless ($form->{"rate_1"} || $form->{"amount_1"}) {
1200 $form->isblank("rate_1", $locale->text("Rate missing!")) unless $form->{"amount_1"};
1201 $form->isblank("amount_1", $locale->text("Amount missing!"));
1204 HR->save_deduction(\%myconfig, \%$form);
1205 $form->redirect($locale->text('Deduction saved!'));
1210 sub delete_deduction {
1212 HR->delete_deduction(\%myconfig, \%$form);
1213 $form->redirect($locale->text('Deduction deleted!'));