summaryrefslogtreecommitdiff
path: root/bin/lynx/hr.pl
blob: 9b86d86b6f08dc53756c2e9c84f7d15e9f7c80fc (plain)
  1. #=====================================================================
  2. # LedgerSMB Small Medium Business Accounting
  3. # Copyright (c) 2004
  4. #
  5. # Author: DWS Systems Inc.
  6. # Web: http://sourceforge.net/projects/ledger-smb/
  7. #
  8. #
  9. # This program is free software; you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation; either version 2 of the License, or
  12. # (at your option) any later version.
  13. #
  14. # This program is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. # GNU General Public License for more details.
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program; if not, write to the Free Software
  20. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21. #======================================================================
  22. #
  23. # payroll module
  24. #
  25. #======================================================================
  26. use SL::HR;
  27. use SL::User;
  28. 1;
  29. # end of main
  30. sub add {
  31. $label = "Add ".ucfirst $form->{db};
  32. $form->{title} = $locale->text($label);
  33. $form->{callback} = "$form->{script}?action=add&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback};
  34. &{ "$form->{db}_links" };
  35. }
  36. sub search { &{ "search_$form->{db}" } };
  37. sub search_employee {
  38. $form->{title} = $locale->text('Employees');
  39. @a = ();
  40. push @a, qq|<input name="l_ndx" type=checkbox class=checkbox value=Y> |.$locale->text('Pos');
  41. push @a, qq|<input name="l_id" type=checkbox class=checkbox value=Y> |.$locale->text('ID');
  42. push @a, qq|<input name="l_employeenumber" type=checkbox class=checkbox value=Y checked> |.$locale->text('Employee Number');
  43. push @a, qq|<input name="l_name" type=checkbox class=checkbox value=Y checked> |.$locale->text('Employee Name');
  44. push @a, qq|<input name="l_address" type=checkbox class=checkbox value=Y> |.$locale->text('Address');
  45. push @a, qq|<input name="l_city" type=checkbox class=checkbox value=Y> |.$locale->text('City');
  46. push @a, qq|<input name="l_state" type=checkbox class=checkbox value=Y> |.$locale->text('State/Province');
  47. push @a, qq|<input name="l_zipcode" type=checkbox class=checkbox value=Y> |.$locale->text('Zip/Postal Code');
  48. push @a, qq|<input name="l_country" type=checkbox class=checkbox value=Y> |.$locale->text('Country');
  49. push @a, qq|<input name="l_workphone" type=checkbox class=checkbox value=Y checked> |.$locale->text('Work Phone');
  50. push @a, qq|<input name="l_homephone" type=checkbox class=checkbox value=Y checked> |.$locale->text('Home Phone');
  51. push @a, qq|<input name="l_startdate" type=checkbox class=checkbox value=Y checked> |.$locale->text('Startdate');
  52. push @a, qq|<input name="l_enddate" type=checkbox class=checkbox value=Y checked> |.$locale->text('Enddate');
  53. push @a, qq|<input name="l_sales" type=checkbox class=checkbox value=Y> |.$locale->text('Sales');
  54. push @a, qq|<input name="l_manager" type=checkbox class=checkbox value=Y> |.$locale->text('Manager');
  55. push @a, qq|<input name="l_role" type=checkbox class=checkbox value=Y checked> |.$locale->text('Role');
  56. push @a, qq|<input name="l_login" type=checkbox class=checkbox value=Y checked> |.$locale->text('Login');
  57. push @a, qq|<input name="l_email" type=checkbox class=checkbox value=Y> |.$locale->text('E-mail');
  58. push @a, qq|<input name="l_ssn" type=checkbox class=checkbox value=Y> |.$locale->text('SSN');
  59. push @a, qq|<input name="l_dob" type=checkbox class=checkbox value=Y> |.$locale->text('DOB');
  60. push @a, qq|<input name="l_iban" type=checkbox class=checkbox value=Y> |.$locale->text('IBAN');
  61. push @a, qq|<input name="l_bic" type=checkbox class=checkbox value=Y> |.$locale->text('BIC');
  62. push @a, qq|<input name="l_notes" type=checkbox class=checkbox value=Y> |.$locale->text('Notes');
  63. $form->header;
  64. print qq|
  65. <body>
  66. <form method=post action=$form->{script}>
  67. <table width=100%>
  68. <tr>
  69. <th class=listtop>$form->{title}</th>
  70. </tr>
  71. <tr height="5"></tr>
  72. <tr valign=top>
  73. <td>
  74. <table>
  75. <tr>
  76. <th align=right nowrap>|.$locale->text('Employee Number').qq|</th>
  77. <td colspan=3><input name=employeenumber size=20></td>
  78. </tr>
  79. <tr>
  80. <th align=right nowrap>|.$locale->text('Employee Name').qq|</th>
  81. <td colspan=3><input name=name size=35></td>
  82. </tr>
  83. <tr>
  84. <th align=right nowrap>|.$locale->text('Startdate').qq|</th>
  85. <td>|.$locale->text('From').qq| <input name=startdatefrom size=11 title="$myconfig{dateformat}"> |.$locale->text('To').qq| <input name=startdateto size=11 title="$myconfig{dateformat}"></td>
  86. </tr>
  87. <tr valign=top>
  88. <th align=right nowrap>|.$locale->text('Notes').qq|</th>
  89. <td colspan=3><input name=notes size=40></td>
  90. </tr>
  91. <tr>
  92. <td></td>
  93. <td colspan=3><input name=status class=radio type=radio value=all checked>&nbsp;|.$locale->text('All').qq|
  94. <input name=status class=radio type=radio value=active>&nbsp;|.$locale->text('Active').qq|
  95. <input name=status class=radio type=radio value=inactive>&nbsp;|.$locale->text('Inactive').qq|
  96. <input name=status class=radio type=radio value=orphaned>&nbsp;|.$locale->text('Orphaned').qq|
  97. <input name=sales class=checkbox type=checkbox value=Y>&nbsp;|.$locale->text('Sales').qq|
  98. </tr>
  99. <tr>
  100. <th align=right nowrap>|.$locale->text('Include in Report').qq|</th>
  101. <td colspan=3>
  102. <table>
  103. |;
  104. while (@a) {
  105. print qq|<tr>\n|;
  106. for (1 .. 5) {
  107. print qq|<td nowrap>|. shift @a;
  108. print qq|</td>\n|;
  109. }
  110. print qq|</tr>\n|;
  111. }
  112. print qq|
  113. </table>
  114. </td>
  115. </tr>
  116. </table>
  117. </td>
  118. </tr>
  119. <tr>
  120. <td><hr size=3 noshade></td>
  121. </tr>
  122. </table>
  123. <input type=hidden name=nextsub value=list_employees>
  124. |;
  125. $form->hide_form(qw(db path login sessionid));
  126. print qq|
  127. <br>
  128. <input type=submit class=submit name=action value="|.$locale->text('Continue').qq|">
  129. </form>
  130. |;
  131. if ($form->{menubar}) {
  132. require "$form->{path}/menu.pl";
  133. &menubar;
  134. }
  135. print qq|
  136. </body>
  137. </html>
  138. |;
  139. }
  140. sub list_employees {
  141. HR->employees(\%myconfig, \%$form);
  142. $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}";
  143. $form->sort_order();
  144. $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}";
  145. @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));
  146. unshift @columns, "ndx";
  147. foreach $item (@columns) {
  148. if ($form->{"l_$item"} eq "Y") {
  149. push @column_index, $item;
  150. # add column to href and callback
  151. $callback .= "&l_$item=Y";
  152. $href .= "&l_$item=Y";
  153. }
  154. }
  155. %role = ( user => $locale->text('User'),
  156. supervisor => $locale->text('Supervisor'),
  157. manager => $locale->text('Manager'),
  158. admin => $locale->text('Administrator')
  159. );
  160. $option = $locale->text('All');
  161. if ($form->{status} eq 'sales') {
  162. $option = $locale->text('Sales');
  163. }
  164. if ($form->{status} eq 'orphaned') {
  165. $option = $locale->text('Orphaned');
  166. }
  167. if ($form->{status} eq 'active') {
  168. $option = $locale->text('Active');
  169. }
  170. if ($form->{status} eq 'inactive') {
  171. $option = $locale->text('Inactive');
  172. }
  173. if ($form->{employeenumber}) {
  174. $callback .= "&employeenumber=".$form->escape($form->{employeenumber},1);
  175. $href .= "&employeenumber=".$form->escape($form->{employeenumber});
  176. $option .= "\n<br>".$locale->text('Employee Number')." : $form->{employeenumber}";
  177. }
  178. if ($form->{name}) {
  179. $callback .= "&name=".$form->escape($form->{name},1);
  180. $href .= "&name=".$form->escape($form->{name});
  181. $option .= "\n<br>".$locale->text('Employee Name')." : $form->{name}";
  182. }
  183. if ($form->{startdatefrom}) {
  184. $callback .= "&startdatefrom=$form->{startdatefrom}";
  185. $href .= "&startdatefrom=$form->{startdatefrom}";
  186. $fromdate = $locale->date(\%myconfig, $form->{startdatefrom}, 1);
  187. }
  188. if ($form->{startdateto}) {
  189. $callback .= "&startdateto=$form->{startdateto}";
  190. $href .= "&startdateto=$form->{startdateto}";
  191. $todate = $locale->date(\%myconfig, $form->{startdateto}, 1);
  192. }
  193. if ($fromdate || $todate) {
  194. $option .= "\n<br>".$locale->text('Startdate')." $fromdate - $todate";
  195. }
  196. if ($form->{notes}) {
  197. $callback .= "&notes=".$form->escape($form->{notes},1);
  198. $href .= "&notes=".$form->escape($form->{notes});
  199. $option .= "\n<br>" if $option;
  200. $option .= $locale->text('Notes')." : $form->{notes}";
  201. }
  202. $form->{callback} = "$callback&sort=$form->{sort}";
  203. $callback = $form->escape($form->{callback});
  204. $column_header{ndx} = qq|<th class=listheading>&nbsp;</th>|;
  205. $column_header{id} = qq|<th class=listheading>|.$locale->text('ID').qq|</th>|;
  206. $column_header{employeenumber} = qq|<th><a class=listheading href=$href&sort=employeenumber>|.$locale->text('Number').qq|</a></th>|;
  207. $column_header{name} = qq|<th><a class=listheading href=$href&sort=name>|.$locale->text('Name').qq|</a></th>|;
  208. $column_header{manager} = qq|<th><a class=listheading href=$href&sort=manager>|.$locale->text('Manager').qq|</a></th>|;
  209. $column_header{address} = qq|<th class=listheading>|.$locale->text('Address').qq|</a></th>|;
  210. $column_header{city} = qq|<th><a class=listheading href=$href&sort=city>|.$locale->text('City').qq|</a></th>|;
  211. $column_header{state} = qq|<th><a class=listheading href=$href&sort=state>|.$locale->text('State/Province').qq|</a></th>|;
  212. $column_header{zipcode} = qq|<th><a class=listheading href=$href&sort=zipcode>|.$locale->text('Zip/Postal Code').qq|</a></th>|;
  213. $column_header{country} = qq|<th><a class=listheading href=$href&sort=country>|.$locale->text('Country').qq|</a></th>|;
  214. $column_header{workphone} = qq|<th><a class=listheading href=$href&sort=workphone>|.$locale->text('Work Phone').qq|</a></th>|;
  215. $column_header{homephone} = qq|<th><a class=listheading href=$href&sort=homephone>|.$locale->text('Home Phone').qq|</a></th>|;
  216. $column_header{startdate} = qq|<th><a class=listheading href=$href&sort=startdate>|.$locale->text('Startdate').qq|</a></th>|;
  217. $column_header{enddate} = qq|<th><a class=listheading href=$href&sort=enddate>|.$locale->text('Enddate').qq|</a></th>|;
  218. $column_header{notes} = qq|<th><a class=listheading href=$href&sort=notes>|.$locale->text('Notes').qq|</a></th>|;
  219. $column_header{role} = qq|<th><a class=listheading href=$href&sort=role>|.$locale->text('Role').qq|</a></th>|;
  220. $column_header{login} = qq|<th><a class=listheading href=$href&sort=login>|.$locale->text('Login').qq|</a></th>|;
  221. $column_header{sales} = qq|<th class=listheading>|.$locale->text('S').qq|</th>|;
  222. $column_header{email} = qq|<th><a class=listheading href=$href&sort=email>|.$locale->text('E-mail').qq|</a></th>|;
  223. $column_header{ssn} = qq|<th><a class=listheading href=$href&sort=ssn>|.$locale->text('SSN').qq|</a></th>|;
  224. $column_header{dob} = qq|<th><a class=listheading href=$href&sort=dob>|.$locale->text('DOB').qq|</a></th>|;
  225. $column_header{iban} = qq|<th><a class=listheading href=$href&sort=iban>|.$locale->text('IBAN').qq|</a></th>|;
  226. $column_header{bic} = qq|<th><a class=listheading href=$href&sort=bic>|.$locale->text('BIC').qq|</a></th>|;
  227. $form->{title} = $locale->text('Employees');
  228. $form->header;
  229. print qq|
  230. <body>
  231. <table width=100%>
  232. <tr>
  233. <th class=listtop>$form->{title}</th>
  234. </tr>
  235. <tr height="5"></tr>
  236. <tr>
  237. <td>$option</td>
  238. </tr>
  239. <tr>
  240. <td>
  241. <table width=100%>
  242. <tr class=listheading>
  243. |;
  244. for (@column_index) { print "$column_header{$_}\n" }
  245. print qq|
  246. </tr>
  247. |;
  248. $i = 0;
  249. foreach $ref (@{ $form->{all_employee} }) {
  250. $i++;
  251. $ref->{notes} =~ s/\r?\n/<br>/g;
  252. for (@column_index) { $column_data{$_} = "<td>$ref->{$_}&nbsp;</td>" }
  253. $column_data{ndx} = "<td align=right>$i</td>";
  254. $column_data{sales} = ($ref->{sales}) ? "<td>x</td>" : "<td>&nbsp;</td>";
  255. $column_data{role} = qq|<td>$role{"$ref->{role}"}&nbsp;</td>|;
  256. $column_date{address} = qq|$ref->{address1} $ref->{address2}|;
  257. $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}&nbsp;</td>";
  258. if ($ref->{email}) {
  259. $email = $ref->{email};
  260. $email =~ s/</\&lt;/;
  261. $email =~ s/>/\&gt;/;
  262. $column_data{email} = qq|<td><a href="mailto:$ref->{email}">$email</a></td>|;
  263. }
  264. $j++; $j %= 2;
  265. print "
  266. <tr class=listrow$j>
  267. ";
  268. for (@column_index) { print "$column_data{$_}\n" }
  269. print qq|
  270. </tr>
  271. |;
  272. }
  273. $i = 1;
  274. $button{'HR--Employees--Add Employee'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Add Employee').qq|"> |;
  275. $button{'HR--Employees--Add Employee'}{order} = $i++;
  276. foreach $item (split /;/, $myconfig{acs}) {
  277. delete $button{$item};
  278. }
  279. print qq|
  280. </table>
  281. </td>
  282. </tr>
  283. <tr>
  284. <td><hr size=3 noshade></td>
  285. </tr>
  286. </table>
  287. <br>
  288. <form method=post action=$form->{script}>
  289. |;
  290. $form->hide_form(qw(callback db path login sessionid));
  291. foreach $item (sort { $a->{order} <=> $b->{order} } %button) {
  292. print $item->{code};
  293. }
  294. if ($form->{menubar}) {
  295. require "$form->{path}/menu.pl";
  296. &menubar;
  297. }
  298. print qq|
  299. </form>
  300. </body>
  301. </html>
  302. |;
  303. }
  304. sub edit {
  305. # $locale->text('Edit Employee')
  306. # $locale->text('Edit Deduction')
  307. $label = ucfirst $form->{db};
  308. $form->{title} = "Edit $label";
  309. &{ "$form->{db}_links" };
  310. }
  311. sub employee_links {
  312. #$form->{deductions} = 1;
  313. HR->get_employee(\%myconfig, \%$form);
  314. for (keys %$form) { $form->{$_} = $form->quote($form->{$_}) }
  315. if (@{ $form->{all_deduction} }) {
  316. $form->{selectdeduction} = "<option>\n";
  317. for (@{ $form->{all_deduction} }) { $form->{selectdeduction} .= qq|<option value="$_->{description}--$_->{id}">$_->{description}\n| }
  318. }
  319. $form->{manager} = "$form->{manager}--$form->{managerid}";
  320. if (@{ $form->{all_manager} }) {
  321. $form->{selectmanager} = "<option>\n";
  322. for (@{ $form->{all_manager} }) { $form->{selectmanager} .= qq|<option value="$_->{name}--$_->{id}">$_->{name}\n| }
  323. }
  324. %role = ( user => $locale->text('User'),
  325. supervisor => $locale->text('Supervisor'),
  326. manager => $locale->text('Manager'),
  327. admin => $locale->text('Administrator')
  328. );
  329. $form->{selectrole} = "<option>\n";
  330. for (qw(user supervisor manager admin)) { $form->{selectrole} .= "<option value=$_>$role{$_}\n" }
  331. $i = 1;
  332. foreach $ref (@{ $form->{all_employeededuction} }) {
  333. $form->{"deduction_$i"} = "$ref->{description}--$ref->{id}" if $ref->{id};
  334. for (qw(before after rate)) { $form->{"${_}_$i"} = $ref->{$_} }
  335. $i++;
  336. }
  337. $form->{deduction_rows} = $i - 1;
  338. &employee_header;
  339. &employee_footer;
  340. }
  341. sub employee_header {
  342. $sales = qq|<input type=hidden name=sales value=$form->{sales}>|;
  343. $form->{sales} = ($form->{sales}) ? "checked" : "";
  344. $form->{selectrole} =~ s/ selected//;
  345. $form->{selectrole} =~ s/option value=\Q$form->{role}\E>/option value=$form->{role} selected>/;
  346. $form->{selectdeduction} = $form->unescape($form->{selectdeduction});
  347. $form->{selectmanager} = $form->unescape($form->{selectmanager});
  348. $form->{selectmanager} =~ s/ selected//;
  349. $form->{selectmanager} =~ s/(<option value="\Q$form->{manager}\E")/$1 selected/;
  350. $sales .= qq|
  351. <input type=hidden name=role value=$form->{role}>
  352. <input type=hidden name=manager value=$form->{manager}>
  353. |;
  354. if ($myconfig{role} ne 'user') {
  355. $sales = qq|
  356. <tr>
  357. <th align=right>|.$locale->text('Sales').qq|</th>
  358. <td><input name=sales class=checkbox type=checkbox value=1 $form->{sales}></td>
  359. </tr>
  360. <tr>
  361. <th align=right>|.$locale->text('Role').qq|</th>
  362. <td><select name=role>$form->{selectrole}</select></td>
  363. </tr>
  364. |;
  365. if ($form->{selectmanager}) {
  366. $sales .= qq|
  367. <tr>
  368. <th align=right>|.$locale->text('Manager').qq|</th>
  369. <td><select name=manager>$form->{selectmanager}</select></td>
  370. </tr>
  371. |;
  372. }
  373. }
  374. $form->{deduction_rows}++;
  375. for $i (1 .. $form->{deduction_rows}) {
  376. $form->{"selectdeduction_$i"} = $form->{selectdeduction};
  377. if ($form->{"deduction_$i"}) {
  378. $form->{"selectdeduction_$i"} =~ s/(<option value="\Q$form->{"deduction_$i"}\E")/$1 selected/;
  379. }
  380. }
  381. $form->{selectdeduction} = $form->escape($form->{selectdeduction},1);
  382. $form->{selectmanager} = $form->escape($form->{selectmanager},1);
  383. $form->header;
  384. print qq|
  385. <body>
  386. <form method=post action=$form->{script}>
  387. <input type=hidden name=selectdeduction value="$form->{selectdeduction}">
  388. <input type=hidden name=deduction_rows value=$form->{deduction_rows}>
  389. <input type=hidden name=selectmanager value="$form->{selectmanager}">
  390. <input type=hidden name=selectrole value="$form->{selectrole}">
  391. <input type=hidden name=status value=$form->{status}>
  392. <input type=hidden name=title value="$form->{title}">
  393. <table width=100%>
  394. <tr>
  395. <th class=listtop>$form->{title}</th>
  396. </tr>
  397. <tr height="5"></tr>
  398. <tr>
  399. <td>
  400. <table>
  401. <tr valign=top>
  402. <td>
  403. <table>
  404. <tr>
  405. <th align=right nowrap>|.$locale->text('Number').qq|</th>
  406. <td><input name=employeenumber size=32 maxlength=32 value="$form->{employeenumber}"></td>
  407. </tr>
  408. <tr>
  409. <th align=right nowrap>|.$locale->text('Name').qq|</th>
  410. <td><input name=name size=35 maxlength=64 value="$form->{name}"></td>
  411. </tr>
  412. <tr>
  413. <th align=right nowrap>|.$locale->text('Address').qq|</th>
  414. <td><input name=address1 size=35 maxlength=32 value="$form->{address1}"></td>
  415. </tr>
  416. <tr>
  417. <th></th>
  418. <td><input name=address2 size=35 maxlength=32 value="$form->{address2}"></td>
  419. </tr>
  420. <tr>
  421. <th align=right nowrap>|.$locale->text('City').qq|</th>
  422. <td><input name=city size=35 maxlength=32 value="$form->{city}"></td>
  423. </tr>
  424. <tr>
  425. <th align=right nowrap>|.$locale->text('State/Province').qq|</th>
  426. <td><input name=state size=35 maxlength=32 value="$form->{state}"></td>
  427. </tr>
  428. <tr>
  429. <th align=right nowrap>|.$locale->text('Zip/Postal Code').qq|</th>
  430. <td><input name=zipcode size=10 maxlength=10 value="$form->{zipcode}"></td>
  431. </tr>
  432. <tr>
  433. <th align=right nowrap>|.$locale->text('Country').qq|</th>
  434. <td><input name=country size=35 maxlength=32 value="$form->{country}"></td>
  435. </tr>
  436. <tr>
  437. <th align=right nowrap>|.$locale->text('E-mail').qq|</th>
  438. <td><input name=email size=35 value="$form->{email}"></td>
  439. </tr>
  440. <tr>
  441. $sales
  442. </table>
  443. </td>
  444. <td>
  445. <table>
  446. <tr>
  447. <th align=right nowrap>|.$locale->text('Work Phone').qq|</th>
  448. <td><input name=workphone size=20 maxlength=20 value="$form->{workphone}"></td>
  449. </tr>
  450. <tr>
  451. <th align=right nowrap>|.$locale->text('Home Phone').qq|</th>
  452. <td><input name=homephone size=20 maxlength=20 value="$form->{homephone}"></td>
  453. </tr>
  454. <tr>
  455. <th align=right nowrap>|.$locale->text('Startdate').qq|</th>
  456. <td><input name=startdate size=11 title="$myconfig{dateformat}" value=$form->{startdate}></td>
  457. </tr>
  458. <tr>
  459. <th align=right nowrap>|.$locale->text('Enddate').qq|</th>
  460. <td><input name=enddate size=11 title="$myconfig{dateformat}" value=$form->{enddate}></td>
  461. </tr>
  462. <tr>
  463. <th align=right nowrap>|.$locale->text('SSN').qq|</th>
  464. <td><input name=ssn size=20 maxlength=20 value="$form->{ssn}"></td>
  465. </tr>
  466. <tr>
  467. <th align=right nowrap>|.$locale->text('DOB').qq|</th>
  468. <td><input name=dob size=11 title="$myconfig{dateformat}" value=$form->{dob}></td>
  469. </tr>
  470. <tr>
  471. <th align=right nowrap>|.$locale->text('IBAN').qq|</th>
  472. <td><input name=iban size=34 maxlength=34 value="$form->{iban}"></td>
  473. </tr>
  474. <tr>
  475. <th align=right nowrap>|.$locale->text('BIC').qq|</th>
  476. <td><input name=bic size=11 maxlength=11 value="$form->{bic}"></td>
  477. </tr>
  478. </table>
  479. </td>
  480. </tr>
  481. </table>
  482. </td>
  483. </tr>
  484. <tr>
  485. <th align=left nowrap>|.$locale->text('Notes').qq|</th>
  486. </tr>
  487. <tr>
  488. <td><textarea name=notes rows=3 cols=60 wrap=soft>$form->{notes}</textarea></td>
  489. </tr>
  490. |;
  491. if ($form->{selectdeduction}) {
  492. print qq|
  493. <tr>
  494. <td>
  495. <table width=100%>
  496. <tr class=listheading>
  497. <th class=listheading>|.$locale->text('Payroll Deduction').qq|</th>
  498. <th class=listheading colspan=3>|.$locale->text('Allowances').qq|</th>
  499. </tr>
  500. <tr class=listheading>
  501. <th></th>
  502. <th class=listheading>|.$locale->text('Before Deduction').qq|</th>
  503. <th class=listheading>|.$locale->text('After Deduction').qq|</th>
  504. <th class=listheading>|.$locale->text('Rate').qq|</th>
  505. </tr>
  506. |;
  507. for $i (1 .. $form->{deduction_rows}) {
  508. print qq|
  509. <tr>
  510. <td><select name="deduction_$i">$form->{"selectdeduction_$i"}</select></td>
  511. <td><input name="before_$i" value=|.$form->format_amount(\%myconfig, $form->{"before_$i"}, 2).qq|></td>
  512. <td><input name="after_$i" value=|.$form->format_amount(\%myconfig, $form->{"after_$i"}, 2).qq|></td>
  513. <td><input name="rate_$i" size=5 value=|.$form->format_amount(\%myconfig, $form->{"rate_$i"}).qq|></td>
  514. </tr>
  515. |;
  516. }
  517. }
  518. print qq|
  519. </table>
  520. </td>
  521. </tr>
  522. <tr>
  523. <td><hr size=3 noshade></td>
  524. </tr>
  525. </table>
  526. |;
  527. }
  528. sub employee_footer {
  529. print qq|
  530. <input name=id type=hidden value=$form->{id}>
  531. <input type=hidden name=db value=$form->{db}>
  532. <input type=hidden name=employeelogin value=$form->{employeelogin}>
  533. <input type=hidden name=path value=$form->{path}>
  534. <input type=hidden name=login value=$form->{login}>
  535. <input type=hidden name=sessionid value=$form->{sessionid}>
  536. <input type=hidden name=callback value="$form->{callback}">
  537. <br>
  538. <input class=submit type=submit name=action value="|.$locale->text('Update').qq|">
  539. <input class=submit type=submit name=action value="|.$locale->text('Save').qq|">
  540. |;
  541. if ($form->{id}) {
  542. print qq|<input class=submit type=submit name=action value="|.$locale->text('Save as new').qq|">\n|;
  543. if ($form->{status} eq 'orphaned') {
  544. print qq|<input class=submit type=submit name=action value="|.$locale->text('Delete').qq|">\n|;
  545. }
  546. }
  547. if ($form->{menubar}) {
  548. require "$form->{path}/menu.pl";
  549. &menubar;
  550. }
  551. print qq|
  552. </form>
  553. </body>
  554. </html>
  555. |;
  556. }
  557. sub save { &{ "save_$form->{db}" } };
  558. sub save_employee {
  559. $form->isblank("name", $locale->text("Name missing!"));
  560. HR->save_employee(\%myconfig, \%$form);
  561. # if it is a login change memberfile and .conf
  562. if ($form->{employeelogin}) {
  563. $user = new User $memberfile, $form->{employeelogin};
  564. for (qw(name email role)) { $user->{$_} = $form->{$_} }
  565. # assign $myconfig for db
  566. for (qw(dbconnect dbhost dbport dbpasswd)) { $user->{$_} = $myconfig{$_} }
  567. for (qw(dbpasswd password)) { $user->{"old_$_"} = $user->{$_} }
  568. $user->{packpw} = 1;
  569. $user->save_member($memberfile, $userspath) if $user->{login};
  570. }
  571. $form->redirect($locale->text('Employee saved!'));
  572. }
  573. sub delete { &{ "delete_$form->{db}" } };
  574. sub delete_employee {
  575. HR->delete_employee(\%myconfig, \%$form);
  576. $form->redirect($locale->text('Employee deleted!'));
  577. }
  578. sub continue { &{ $form->{nextsub} } };
  579. sub add_employee { &add };
  580. sub add_deduction { &add };
  581. sub search_deduction {
  582. HR->deductions(\%myconfig, \%$form);
  583. $href = "$form->{script}?action=search_deduction&direction=$form->{direction}&oldsort=$form->{oldsort}&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
  584. $form->sort_order();
  585. $callback = "$form->{script}?action=search_deduction&direction=$form->{direction}&oldsort=$form->{oldsort}&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
  586. @column_index = $form->sort_columns(qw(description rate amount above below employeepays employerpays ap_accno expense_accno));
  587. $form->{callback} = $callback;
  588. $callback = $form->escape($form->{callback});
  589. $column_header{description} = qq|<th class=listheading href=$href>|.$locale->text('Description').qq|</th>|;
  590. $column_header{rate} = qq|<th class=listheading nowrap>|.$locale->text('Rate').qq|<br>%</th>|;
  591. $column_header{amount} = qq|<th class=listheading>|.$locale->text('Amount').qq|</th>|;
  592. $column_header{above} = qq|<th class=listheading>|.$locale->text('Above').qq|</th>|;
  593. $column_header{below} = qq|<th class=listheading>|.$locale->text('Below').qq|</th>|;
  594. $column_header{employerpays} = qq|<th class=listheading>|.$locale->text('Employer').qq|</th>|;
  595. $column_header{employeepays} = qq|<th class=listheading>|.$locale->text('Employee').qq|</th>|;
  596. $column_header{ap_accno} = qq|<th class=listheading>|.$locale->text('AP').qq|</th>|;
  597. $column_header{expense_accno} = qq|<th class=listheading>|.$locale->text('Expense').qq|</th>|;
  598. $form->{title} = $locale->text('Deductions');
  599. $form->header;
  600. print qq|
  601. <body>
  602. <table width=100%>
  603. <tr>
  604. <th class=listtop>$form->{title}</th>
  605. </tr>
  606. <tr height="5"></tr>
  607. <tr>
  608. <td>$option</td>
  609. </tr>
  610. <tr>
  611. <td>
  612. <table width=100%>
  613. <tr class=listheading>
  614. |;
  615. for (@column_index) { print "$column_header{$_}\n" }
  616. print qq|
  617. </tr>
  618. |;
  619. foreach $ref (@{ $form->{all_deduction} }) {
  620. $rate = $form->format_amount(\%myconfig, $ref->{rate} * 100, "", "&nbsp;");
  621. $column_data{rate} = "<td align=right>$rate</td>";
  622. for (qw(amount below above)) { $column_data{$_} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{$_}, 2, "&nbsp;")."</td>" }
  623. for (qw(ap_accno expense_accno)) { $column_data{$_} = "<td>$ref->{$_}&nbsp;</td>" }
  624. for (qw(employerpays employeepays)) { $column_data{$_} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{$_}, "", "&nbsp;")."</td>" }
  625. if ($ref->{description} ne $sameitem) {
  626. $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>";
  627. } else {
  628. $column_data{description} = "<td>&nbsp;</td>";
  629. }
  630. $i++; $i %= 2;
  631. print "
  632. <tr class=listrow$i>
  633. ";
  634. for (@column_index) { print "$column_data{$_}\n" }
  635. print qq|
  636. </tr>
  637. |;
  638. $sameitem = $ref->{description};
  639. }
  640. $i = 1;
  641. $button{'HR--Deductions--Add Deduction'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Add Deduction').qq|"> |;
  642. $button{'HR--Deductions--Add Deduction'}{order} = $i++;
  643. foreach $item (split /;/, $myconfig{acs}) {
  644. delete $button{$item};
  645. }
  646. print qq|
  647. </table>
  648. </td>
  649. </tr>
  650. <tr>
  651. <td><hr size=3 noshade></td>
  652. </tr>
  653. </table>
  654. <br>
  655. <form method=post action=$form->{script}>
  656. <input type=hidden name=db value=$form->{db}>
  657. <input name=callback type=hidden value="$form->{callback}">
  658. <input type=hidden name=path value=$form->{path}>
  659. <input type=hidden name=login value=$form->{login}>
  660. <input type=hidden name=sessionid value=$form->{sessionid}>
  661. |;
  662. foreach $item (sort { $a->{order} <=> $b->{order} } %button) {
  663. print $item->{code};
  664. }
  665. if ($form->{menubar}) {
  666. require "$form->{path}/menu.pl";
  667. &menubar;
  668. }
  669. print qq|
  670. </form>
  671. </body>
  672. </html>
  673. |;
  674. }
  675. sub deduction_links {
  676. HR->get_deduction(\%myconfig, \%$form);
  677. $i = 1;
  678. foreach $ref (@{ $form->{deductionrate} }) {
  679. for (keys %$ref) { $form->{"${_}_$i"} = $ref->{$_} }
  680. $i++;
  681. }
  682. $form->{rate_rows} = $i - 1;
  683. $i = 1;
  684. foreach $ref (@{ $form->{deductionbase} }) {
  685. $form->{"base_$i"} = "$ref->{description}--$ref->{id}" if $ref->{id};
  686. $form->{"maximum_$i"} = $ref->{maximum};
  687. $i++;
  688. }
  689. $form->{base_rows} = $i - 1;
  690. $i = 1;
  691. foreach $ref (@{ $form->{deductionafter} }) {
  692. $form->{"after_$i"} = "$ref->{description}--$ref->{id}" if $ref->{id};
  693. $i++;
  694. }
  695. $form->{after_rows} = $i - 1;
  696. $form->{employeepays} = 1;
  697. $selectaccount = "<option>\n";
  698. for (@{ $form->{ap_accounts} }) { $selectaccount .= "<option>$_->{accno}--$_->{description}\n" }
  699. $form->{ap_accno} = qq|$form->{ap_accno}--$form->{ap_description}|;
  700. $form->{selectap} = $selectaccount;
  701. $selectaccount = "<option>\n";
  702. for (@{ $form->{expense_accounts} }) { $selectaccount .= "<option>$_->{accno}--$_->{description}\n" }
  703. $form->{expense_accno} = qq|$form->{expense_accno}--$form->{expense_description}|;
  704. $form->{selectexpense} = $selectaccount;
  705. for (1 .. $form->{rate_rows}) { $form->{"rate_$_"} *= 100 }
  706. $form->{selectbase} = "<option>\n";
  707. for (@{ $form->{all_deduction} }) { $form->{selectbase} .= qq|<option value="$_->{description}--$_->{id}">$_->{description}\n| }
  708. &deduction_header;
  709. &deduction_footer;
  710. }
  711. sub deduction_header {
  712. $selectap = $form->{selectap};
  713. $selectap =~ s/option>\Q$form->{ap_accno}\E/option selected>$form->{ap_accno}/;
  714. $selectexpense = $form->{selectexpense};
  715. $selectexpense =~ s/option>\Q$form->{expense_accno}\E/option selected>$form->{expense_accno}/;
  716. $form->{rate_rows}++;
  717. $form->{base_rows}++;
  718. $form->{after_rows}++;
  719. $form->{selectbase} = $form->unescape($form->{selectbase});
  720. for $i (1 .. $form->{base_rows}) {
  721. $form->{"selectbase_$i"} = $form->{selectbase};
  722. if ($form->{"base_$i"}) {
  723. $form->{"selectbase_$i"} =~ s/(<option value="\Q$form->{"base_$i"}\E")/$1 selected/;
  724. }
  725. }
  726. for $i (1 .. $form->{after_rows}) {
  727. $form->{"selectafter_$i"} = $form->{selectbase};
  728. if ($form->{"after_$i"}) {
  729. $form->{"selectafter_$i"} =~ s/(<option value="\Q$form->{"after_$i"}\E")/$1 selected/;
  730. }
  731. }
  732. $form->header;
  733. print qq|
  734. <body>
  735. <form method=post action=$form->{script}>
  736. <input type=hidden name=title value="$form->{title}">
  737. <input type=hidden name=selectap value="$form->{selectap}">
  738. <input type=hidden name=selectexpense value="$form->{selectexpense}">
  739. <input type=hidden name=selectbase value="|.$form->escape($form->{selectbase},1).qq|">
  740. <input type=hidden name=rate_rows value=$form->{rate_rows}>
  741. <input type=hidden name=base_rows value=$form->{base_rows}>
  742. <input type=hidden name=after_rows value=$form->{after_rows}>
  743. <table width=100%>
  744. <tr>
  745. <th class=listtop>$form->{title}</th>
  746. </tr>
  747. <tr height="5"></tr>
  748. <tr>
  749. <td>
  750. <table>
  751. <tr>
  752. <th align=right nowrap>|.$locale->text('Description').qq|</th>
  753. <td><input name=description size=35 value="$form->{description}"></td>
  754. </tr>
  755. <tr>
  756. <th align=right nowrap>|.$locale->text('AP').qq|</th>
  757. <td><select name=ap_accno>$selectap</select></td>
  758. <th align=right nowrap>|.$locale->text('Employee pays').qq| x</th>
  759. <td><input name=employeepays size=4 value=|.$form->format_amount(\%myconfig, $form->{employeepays}).qq|></td>
  760. </tr>
  761. <tr>
  762. <th align=right nowrap>|.$locale->text('Expense').qq|</th>
  763. <td><select name=expense_accno>$selectexpense</select></td>
  764. <th align=right nowrap>|.$locale->text('Employer pays').qq| x</th>
  765. <td><input name=employerpays size=4 value=|.$form->format_amount(\%myconfig, $form->{employerpays}).qq|></td>
  766. </tr>
  767. <tr>
  768. <td></td>
  769. <td></td>
  770. <th align=right nowrap>|.$locale->text('Exempt age <').qq|</th>
  771. <td><input name=fromage size=4 value=|.$form->format_amount(\%myconfig, $form->{fromage}).qq|></td>
  772. <th align=right nowrap>&gt;</th>
  773. <td><input name=toage size=4 value=|.$form->format_amount(\%myconfig, $form->{toage}).qq|>
  774. </tr>
  775. <tr>
  776. <td></td>
  777. <td>
  778. <table>
  779. <tr class=listheading>
  780. <th class=listheading>|.$locale->text('Rate').qq| %</th>
  781. <th class=listheading>|.$locale->text('Amount').qq|</th>
  782. <th class=listheading>|.$locale->text('Above').qq|</th>
  783. <th class=listheading>|.$locale->text('Below').qq|</th>
  784. </tr>
  785. |;
  786. for $i (1 .. $form->{rate_rows}) {
  787. print qq|
  788. <tr>
  789. <td><input name="rate_$i" size=10 value=|.$form->format_amount(\%myconfig, $form->{"rate_$i"}).qq|></td>
  790. <td><input name="amount_$i" size=10 value=|.$form->format_amount(\%myconfig, $form->{"amount_$i"}, 2).qq|></td>
  791. <td><input name="above_$i" size=10 value=|.$form->format_amount(\%myconfig, $form->{"above_$i"}, 2).qq|></td>
  792. <td><input name="below_$i" size=10 value=|.$form->format_amount(\%myconfig, $form->{"below_$i"}, 2).qq|></td>
  793. </tr>
  794. |;
  795. }
  796. print qq|
  797. </table>
  798. </td>
  799. </tr>
  800. </table>
  801. </td>
  802. </tr>
  803. |;
  804. print qq|
  805. <tr>
  806. <td>
  807. <table>
  808. |;
  809. $basedon = $locale->text('Based on');
  810. $maximum = $locale->text('Maximum');
  811. for $i (1 .. $form->{base_rows}) {
  812. print qq|
  813. <tr>
  814. <th>$basedon</th>
  815. <td><select name="base_$i">$form->{"selectbase_$i"}</select></td>
  816. <th>$maximum</th>
  817. <td><input name="maximum_$i" value=|.$form->format_amount(\%myconfig, $form->{"maximum_$i"}, 2).qq|></td>
  818. </tr>
  819. |;
  820. $basedon = "";
  821. $maximum = "";
  822. }
  823. $deductafter = $locale->text('Deduct after');
  824. for $i (1 .. $form->{after_rows}) {
  825. print qq|
  826. <tr>
  827. <th>$deductafter</th>
  828. <td><select name="after_$i">$form->{"selectafter_$i"}</select></td>
  829. </tr>
  830. |;
  831. $deductafter = "";
  832. }
  833. print qq|
  834. </table>
  835. </td>
  836. </tr>
  837. <tr>
  838. <td><hr size=3 noshade></td>
  839. </tr>
  840. </table>
  841. |;
  842. }
  843. sub deduction_footer {
  844. print qq|
  845. <input name=id type=hidden value=$form->{id}>
  846. <input type=hidden name=db value=$form->{db}>
  847. <input type=hidden name=path value=$form->{path}>
  848. <input type=hidden name=login value=$form->{login}>
  849. <input type=hidden name=sessionid value=$form->{sessionid}>
  850. <input type=hidden name=callback value="$form->{callback}">
  851. <br>
  852. <input class=submit type=submit name=action value="|.$locale->text("Update").qq|">
  853. <input class=submit type=submit name=action value="|.$locale->text("Save").qq|">
  854. |;
  855. if ($form->{id}) {
  856. print qq|<input class=submit type=submit name=action value="|.$locale->text('Save as new').qq|">\n|;
  857. if ($form->{status} eq 'orphaned') {
  858. print qq|<input class=submit type=submit name=action value="|.$locale->text('Delete').qq|">\n|;
  859. }
  860. }
  861. if ($form->{menubar}) {
  862. require "$form->{path}/menu.pl";
  863. &menubar;
  864. }
  865. print qq|
  866. </form>
  867. </body>
  868. </html>
  869. |;
  870. }
  871. sub update { &{ "update_$form->{db}" }; }
  872. sub save { &{ "save_$form->{db}" } };
  873. sub update_deduction {
  874. # if rate or amount is blank remove row
  875. @flds = qw(rate amount above below);
  876. $count = 0;
  877. @a = ();
  878. for $i (1 .. $form->{rate_rows}) {
  879. for (@flds) { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) }
  880. if ($form->{"rate_$i"} || $form->{"amount_$i"}) {
  881. push @a, {};
  882. $j = $#a;
  883. for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
  884. $count++;
  885. }
  886. }
  887. $form->redo_rows(\@flds, \@a, $count, $form->{rate_rows});
  888. $form->{rate_rows} = $count;
  889. @flds = qw(base maximum);
  890. $count = 0;
  891. @a = ();
  892. for $i (1 .. $form->{"base_rows"}) {
  893. $form->{"maximum_$i"} = $form->parse_amount(\%myconfig, $form->{"maximum_$i"});
  894. if ($form->{"base_$i"}) {
  895. push @a, {};
  896. $j = $#a;
  897. for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
  898. $count++;
  899. }
  900. }
  901. $form->redo_rows(\@flds, \@a, $count, $form->{"base_rows"});
  902. $form->{"base_rows"} = $count;
  903. @flds = qw(after);
  904. $count = 0;
  905. @a = ();
  906. for $i (1 .. $form->{"after_rows"}) {
  907. if ($form->{"after_$i"}) {
  908. push @a, {};
  909. $j = $#a;
  910. for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
  911. $count++;
  912. }
  913. }
  914. $form->redo_rows(\@flds, \@a, $count, $form->{"after_rows"});
  915. $form->{"after_rows"} = $count;
  916. &deduction_header;
  917. &deduction_footer;
  918. }
  919. sub update_employee {
  920. # if rate or amount is blank remove row
  921. @flds = qw(before after);
  922. $count = 0;
  923. @a = ();
  924. for $i (1 .. $form->{deduction_rows}) {
  925. for (@flds) { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) }
  926. if ($form->{"deduction_$i"}) {
  927. push @a, {};
  928. $j = $#a;
  929. for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
  930. $count++;
  931. }
  932. }
  933. $form->redo_rows(\@flds, \@a, $count, $form->{deduction_rows});
  934. $form->{deduction_rows} = $count;
  935. &employee_header;
  936. &employee_footer;
  937. }
  938. sub save_as_new {
  939. $form->{id} = 0;
  940. delete $form->{employeelogin};
  941. &save;
  942. }
  943. sub save_deduction {
  944. $form->isblank("description", $locale->text("Description missing!"));
  945. unless ($form->{"rate_1"} || $form->{"amount_1"}) {
  946. $form->isblank("rate_1", $locale->text("Rate missing!")) unless $form->{"amount_1"};
  947. $form->isblank("amount_1", $locale->text("Amount missing!"));
  948. }
  949. HR->save_deduction(\%myconfig, \%$form);
  950. $form->redirect($locale->text('Deduction saved!'));
  951. }
  952. sub delete_deduction {
  953. HR->delete_deduction(\%myconfig, \%$form);
  954. $form->redirect($locale->text('Deduction deleted!'));
  955. }