This commit was generated by cvs2svn to compensate for changes in r4407,
[freeside.git] / sql-ledger / bin / mozilla / pe.pl
1 #=====================================================================
2 # SQL-Ledger Accounting
3 # Copyright (c) 2002
4 #
5 #  Author: Dieter Simader
6 #   Email: dsimader@sql-ledger.org
7 #     Web: http://www.sql-ledger.org
8 #
9 #
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.
14 #
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 #======================================================================
23 #
24 # project administration
25 # partsgroup administration
26 # translation maintainance
27 #
28 #======================================================================
29
30
31 use SL::PE;
32
33 1;
34 # end of main
35
36
37
38 sub add {
39   
40   $form->{title} = "Add";
41
42   # construct callback
43   $form->{callback} = "$form->{script}?action=add&type=$form->{type}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback};
44
45   &{ "$form->{type}_header" };
46   &{ "$form->{type}_footer" };
47   
48 }
49
50
51 sub edit {
52   
53   $form->{title} = "Edit";
54
55   &{ "PE::get_$form->{type}" }("", \%myconfig, \%$form);
56   &{ "$form->{type}_header" };
57   &{ "$form->{type}_footer" };
58   
59 }
60
61
62 sub search {
63
64   if ($form->{type} eq 'project') {
65     $report = "project_report";
66     $sort = 'projectnumber';
67     $form->{title} = $locale->text('Projects');
68
69     $number = qq|
70         <tr>
71           <th align=right width=1%>|.$locale->text('Number').qq|</th>
72           <td><input name=projectnumber size=20></td>
73         </tr>
74         <tr>
75           <th align=right>|.$locale->text('Description').qq|</th>
76           <td><input name=description size=60></td>
77         </tr>
78 |;
79
80   }
81   if ($form->{type} eq 'partsgroup') {
82     $report = "partsgroup_report";
83     $sort = 'partsgroup';
84     $form->{title} = $locale->text('Groups');
85     
86     $number = qq|
87         <tr>
88           <th align=right width=1%>|.$locale->text('Group').qq|</th>
89           <td><input name=partsgroup size=20></td>
90         </tr>
91 |;
92
93   }
94   if ($form->{type} eq 'pricegroup') {
95     $report = "pricegroup_report";
96     $sort = 'pricegroup';
97     $form->{title} = $locale->text('Pricegroups');
98     
99     $number = qq|
100         <tr>
101           <th align=right width=1%>|.$locale->text('Pricegroup').qq|</th>
102           <td><input name=pricegroup size=20></td>
103         </tr>
104 |;
105
106   }
107
108
109   $form->header;
110
111   print qq|
112 <body>
113
114 <form method=post action=$form->{script}>
115
116 <input type=hidden name=sort value=$sort>
117 <input type=hidden name=type value=$form->{type}>
118
119 <table width=100%>
120   <tr>
121     <th class=listtop>$form->{title}</th>
122   </tr>
123   <tr height="5"></tr>
124   <tr>
125     <td>
126       <table width=100%>
127         $number
128         <tr>
129           <td></td>
130           <td><input name=status class=radio type=radio value=all checked>&nbsp;|.$locale->text('All').qq|
131           <input name=status class=radio type=radio value=orphaned>&nbsp;|.$locale->text('Orphaned').qq|</td>
132         </tr>
133       </table>
134     </td>
135   </tr>
136   <tr>
137     <td><hr size=3 noshade></td>
138   </tr>
139 </table>
140
141 <input type=hidden name=nextsub value=$report>
142
143 <input type=hidden name=path value=$form->{path}>
144 <input type=hidden name=login value=$form->{login}>
145 <input type=hidden name=sessionid value=$form->{sessionid}>
146
147 <br>
148 <input class=submit type=submit name=action value="|.$locale->text('Continue').qq|">
149 </form>
150
151 </body>
152 </html>
153 |;
154
155 }
156
157
158
159 sub project_report {
160
161   map { $form->{$_} = $form->unescape($form->{$_}) } (projectnumber, description);
162   PE->projects(\%myconfig, \%$form);
163
164   $href = "$form->{script}?action=project_report&direction=$form->{direction}&oldsort=$form->{oldsort}&type=$form->{type}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&status=$form->{status}";
165
166   $form->sort_order();
167   
168   $callback = "$form->{script}?action=project_report&direction=$form->{direction}&oldsort=$form->{oldsort}&type=$form->{type}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&status=$form->{status}";
169   
170   if ($form->{status} eq 'all') {
171     $option = $locale->text('All');
172   }
173   if ($form->{status} eq 'orphaned') {
174     $option .= $locale->text('Orphaned');
175   }
176   if ($form->{projectnumber}) {
177     $href .= "&projectnumber=".$form->escape($form->{projectnumber});
178     $callback .= "&projectnumber=$form->{projectnumber}";
179     $option .= "\n<br>".$locale->text('Project')." : $form->{projectnumber}";
180   }
181   if ($form->{description}) {
182     $href .= "&description=".$form->escape($form->{description});
183     $callback .= "&description=$form->{description}";
184     $option .= "\n<br>".$locale->text('Description')." : $form->{description}";
185   }
186     
187
188   @column_index = $form->sort_columns(qw(projectnumber description));
189
190   $column_header{projectnumber} = qq|<th><a class=listheading href=$href&sort=projectnumber>|.$locale->text('Number').qq|</a></th>|;
191   $column_header{description} = qq|<th><a class=listheading href=$href&sort=description>|.$locale->text('Description').qq|</a></th>|;
192
193   $form->{title} = $locale->text('Projects');
194
195   $form->header;
196  
197   print qq|
198 <body>
199
200 <table width=100%>
201   <tr>
202     <th class=listtop>$form->{title}</th>
203   </tr>
204   <tr height="5"></tr>
205   <tr>
206     <td>$option</td>
207   </tr>
208   <tr>
209     <td>
210       <table width=100%>
211         <tr class=listheading>
212 |;
213
214   map { print "$column_header{$_}\n" } @column_index;
215   
216   print qq|
217         </tr>
218 |;
219
220   # escape callback
221   $form->{callback} = $callback .= "&sort=$form->{sort}";
222
223   # escape callback for href
224   $callback = $form->escape($callback);
225   
226   foreach $ref (@{ $form->{project_list} }) {
227     
228     $i++; $i %= 2;
229     
230     print qq|
231         <tr valign=top class=listrow$i>
232 |;
233     
234     $column_data{projectnumber} = qq|<td><a href=$form->{script}?action=edit&type=$form->{type}&status=$form->{status}&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{projectnumber}</td>|;
235     $column_data{description} = qq|<td>$ref->{description}&nbsp;</td>|;
236     
237     map { print "$column_data{$_}\n" } @column_index;
238     
239     print "
240         </tr>
241 ";
242   }
243   
244   $i = 1;
245   if ($myconfig{acs} !~ /Projects--Projects/) {
246     $button{'Projects--Add Project'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Add Project').qq|"> |;
247     $button{'Projects--Add Project'}{order} = $i++;
248
249     foreach $item (split /;/, $myconfig{acs}) {
250       delete $button{$item};
251     }
252   }
253  
254   print qq|
255       </table>
256     </td>
257   </tr>
258   <tr>
259     <td><hr size=3 noshade></td>
260   </tr>
261 </table>
262
263 <br>
264 <form method=post action=$form->{script}>
265
266 <input name=callback type=hidden value="$form->{callback}">
267
268 <input type=hidden name=type value=$form->{type}>
269
270 <input type=hidden name=path value=$form->{path}>
271 <input type=hidden name=login value=$form->{login}>
272 <input type=hidden name=sessionid value=$form->{sessionid}>
273 |;
274
275   foreach $item (sort { $a->{order} <=> $b->{order} } %button) {
276     print $item->{code};
277   }
278   
279   if ($form->{menubar}) {
280     require "$form->{path}/menu.pl";
281     &menubar;
282   }
283
284   print qq|
285   </form>
286   
287 </body>
288 </html>
289 |;
290
291 }
292
293
294 sub project_header {
295
296   $form->{title} = $locale->text("$form->{title} Project");
297   
298 # $locale->text('Add Project')
299 # $locale->text('Edit Project')
300
301   $form->{description} = $form->quote($form->{description});
302
303   if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
304     $description = qq|<textarea name="description" rows=$rows cols=60 style="width: 100%" wrap=soft>$form->{description}</textarea>|;
305   } else {
306     $description = qq|<input name=description size=60 value="$form->{description}">|;
307   }
308   
309   $form->header;
310
311   print qq|
312 <body>
313
314 <form method=post action=$form->{script}>
315
316 <input type=hidden name=id value=$form->{id}>
317 <input type=hidden name=type value=project>
318
319 <table width=100%>
320   <tr>
321     <th class=listtop>$form->{title}</th>
322   </tr>
323   <tr height="5"></tr>
324   <tr>
325     <td>
326       <table>
327         <tr>
328           <th align=right>|.$locale->text('Number').qq|</th>
329           <td><input name=projectnumber size=20 value="$form->{projectnumber}"></td>
330         </tr>
331         <tr>
332           <th align=right>|.$locale->text('Description').qq|</th>
333           <td>$description</td>
334         </tr>
335       </table>
336     </td>
337   </tr>
338   <tr>
339     <td colspan=2><hr size=3 noshade></td>
340   </tr>
341 </table>
342 |;
343
344 }
345
346
347 sub project_footer {
348
349   print qq|
350
351 <input name=callback type=hidden value="$form->{callback}">
352
353 <input type=hidden name=path value=$form->{path}>
354 <input type=hidden name=login value=$form->{login}>
355 <input type=hidden name=sessionid value=$form->{sessionid}>
356 <br>
357 |;
358
359   if ($myconfig{acs} !~ /Projects--Add Project/) {
360     print qq|
361 <input type=submit class=submit name=action value="|.$locale->text('Save').qq|">
362 |;
363
364     if ($form->{id} && $form->{orphaned}) {
365       print qq|
366 <input type=submit class=submit name=action value="|.$locale->text('Delete').qq|">|;
367     }
368   }
369
370   if ($form->{menubar}) {
371     require "$form->{path}/menu.pl";
372     &menubar;
373   }
374
375   print qq|
376 </form>
377
378 </body>
379 </html>
380 |;
381
382 }
383
384
385 sub save {
386
387   if ($form->{type} eq 'project') {
388     $form->isblank("projectnumber", $locale->text('Project Number missing!'));
389     PE->save_project(\%myconfig, \%$form);
390     $form->redirect($locale->text('Project saved!'));
391   }
392   if ($form->{type} eq 'partsgroup') {
393     $form->isblank("partsgroup", $locale->text('Group missing!'));
394     PE->save_partsgroup(\%myconfig, \%$form);
395     $form->redirect($locale->text('Group saved!'));
396   }
397   if ($form->{type} eq 'pricegroup') {
398     $form->isblank("pricegroup", $locale->text('Pricegroup missing!'));
399     PE->save_pricegroup(\%myconfig, \%$form);
400     $form->redirect($locale->text('Pricegroup saved!'));
401   }
402   if ($form->{translation}) {
403     PE->save_translation(\%myconfig, \%$form);
404     $form->redirect($locale->text('Translations saved!'));
405   }
406
407 }
408
409
410 sub delete {
411
412   if ($form->{translation}) {
413     PE->delete_translation(\%myconfig, \%$form);
414     $form->redirect($locale->text('Translation deleted!'));
415
416   } else {
417   
418     PE->delete_tuple(\%myconfig, \%$form);
419     
420     if ($form->{type} eq 'project') { 
421       $form->redirect($locale->text('Project deleted!'));
422     }
423     if ($form->{type} eq 'partsgroup') {
424       $form->redirect($locale->text('Group deleted!'));
425     }
426     if ($form->{type} eq 'pricegroup') {
427       $form->redirect($locale->text('Pricegroup deleted!'));
428     }
429   }
430
431 }
432
433
434 sub continue { &{ $form->{nextsub} } };
435
436
437 sub partsgroup_report {
438
439   map { $form->{$_} = $form->unescape($form->{$_}) } (partsgroup);
440   PE->partsgroups(\%myconfig, \%$form);
441
442   $href = "$form->{script}?action=partsgroup_report&direction=$form->{direction}&oldsort=$form->{oldsort}&type=$form->{type}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&status=$form->{status}";
443   
444   $form->sort_order();
445
446   $callback = "$form->{script}?action=partsgroup_report&direction=$form->{direction}&oldsort=$form->{oldsort}&type=$form->{type}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&status=$form->{status}";
447   
448   if ($form->{status} eq 'all') {
449     $option = $locale->text('All');
450   }
451   if ($form->{status} eq 'orphaned') {
452     $option .= $locale->text('Orphaned');
453   }
454   if ($form->{partsgroup}) {
455     $callback .= "&partsgroup=$form->{partsgroup}";
456     $option .= "\n<br>".$locale->text('Group')." : $form->{partsgroup}";
457   }
458    
459
460   @column_index = $form->sort_columns(qw(partsgroup));
461
462   $column_header{partsgroup} = qq|<th><a class=listheading href=$href&sort=partsgroup width=90%>|.$locale->text('Group').qq|</a></th>|;
463
464   $form->{title} = $locale->text('Groups');
465
466   $form->header;
467  
468   print qq|
469 <body>
470
471 <table width=100%>
472   <tr>
473     <th class=listtop>$form->{title}</th>
474   </tr>
475   <tr height="5"></tr>
476   <tr>
477     <td>$option</td>
478   </tr>
479   <tr>
480     <td>
481       <table width=100%>
482         <tr class=listheading>
483 |;
484
485   map { print "$column_header{$_}\n" } @column_index;
486   
487   print qq|
488         </tr>
489 |;
490
491   # escape callback
492   $form->{callback} = $callback;
493
494   # escape callback for href
495   $callback = $form->escape($callback);
496   
497   foreach $ref (@{ $form->{item_list} }) {
498     
499     $i++; $i %= 2;
500     
501     print qq|
502         <tr valign=top class=listrow$i>
503 |;
504     
505     $column_data{partsgroup} = qq|<td><a href=$form->{script}?action=edit&type=$form->{type}&status=$form->{status}&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{partsgroup}</td>|;
506     map { print "$column_data{$_}\n" } @column_index;
507     
508     print "
509         </tr>
510 ";
511   }
512
513   $i = 1;
514   if ($myconfig{acs} !~ /Goods \& Services--Goods \& Services/) {
515     $button{'Goods & Services--Add Group'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Add Group').qq|"> |;
516     $button{'Goods & Services--Add Group'}{order} = $i++;
517
518     foreach $item (split /;/, $myconfig{acs}) {
519       delete $button{$item};
520     }
521   }
522   
523   print qq|
524       </table>
525     </td>
526   </tr>
527   <tr>
528     <td><hr size=3 noshade></td>
529   </tr>
530 </table>
531
532 <br>
533 <form method=post action=$form->{script}>
534
535 <input name=callback type=hidden value="$form->{callback}">
536
537 <input type=hidden name=type value=$form->{type}>
538
539 <input type=hidden name=path value=$form->{path}>
540 <input type=hidden name=login value=$form->{login}>
541 <input type=hidden name=sessionid value=$form->{sessionid}>
542 |;
543
544   foreach $item (sort { $a->{order} <=> $b->{order} } %button) {
545     print $item->{code};
546   }
547
548   if ($form->{menubar}) {
549     require "$form->{path}/menu.pl";
550     &menubar;
551   }
552
553   print qq|
554   </form>
555
556 </body>
557 </html>
558 |;
559
560 }
561
562
563 sub partsgroup_header {
564
565   $form->{title} = $locale->text("$form->{title} Group");
566   
567 # $locale->text('Edit Group')
568
569   $form->{partsgroup} = $form->quote($form->{partsgroup});
570
571   
572   $form->header;
573
574   print qq|
575 <body>
576
577 <form method=post action=$form->{script}>
578
579 <input type=hidden name=id value=$form->{id}>
580 <input type=hidden name=type value=$form->{type}>
581
582 <table width=100%>
583   <tr>
584     <th class=listtop>$form->{title}</th>
585   </tr>
586   <tr height="5"></tr>
587   <tr>
588     <td>
589       <table width=100%>
590         <tr>
591           <th align=right>|.$locale->text('Group').qq|</th>
592
593           <td><input name=partsgroup size=30 value="$form->{partsgroup}"></td>
594         </tr>
595       </table>
596     </td>
597   </tr>
598   <tr>
599     <td colspan=2><hr size=3 noshade></td>
600   </tr>
601 </table>
602 |;
603
604 }
605
606
607 sub partsgroup_footer {
608
609   print qq|
610
611 <input name=callback type=hidden value="$form->{callback}">
612
613 <input type=hidden name=path value=$form->{path}>
614 <input type=hidden name=login value=$form->{login}>
615 <input type=hidden name=sessionid value=$form->{sessionid}>
616 <br>
617 |;
618
619   if ($myconfig{acs} !~ /Goods \& Services--Add Group/) {
620     print qq|
621 <input type=submit class=submit name=action value="|.$locale->text('Save').qq|">
622 |;
623
624     if ($form->{id} && $form->{orphaned}) {
625       print qq|
626 <input type=submit class=submit name=action value="|.$locale->text('Delete').qq|">|;
627     }
628   }
629
630   if ($form->{menubar}) {
631     require "$form->{path}/menu.pl";
632     &menubar;
633   }
634
635   print qq|
636 </form>
637
638 </body>
639 </html>
640 |;
641
642 }
643
644
645 sub pricegroup_report {
646
647   map { $form->{$_} = $form->unescape($form->{$_}) } (pricegroup);
648   PE->pricegroups(\%myconfig, \%$form);
649
650   $href = "$form->{script}?action=pricegroup_report&direction=$form->{direction}&oldsort=$form->{oldsort}&type=$form->{type}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&status=$form->{status}";
651   
652   $form->sort_order();
653
654   $callback = "$form->{script}?action=pricegroup_report&direction=$form->{direction}&oldsort=$form->{oldsort}&type=$form->{type}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&status=$form->{status}";
655   
656   if ($form->{status} eq 'all') {
657     $option = $locale->text('All');
658   }
659   if ($form->{status} eq 'orphaned') {
660     $option .= $locale->text('Orphaned');
661   }
662   if ($form->{pricegroup}) {
663     $callback .= "&pricegroup=$form->{pricegroup}";
664     $option .= "\n<br>".$locale->text('Pricegroup')." : $form->{pricegroup}";
665   }
666    
667
668   @column_index = $form->sort_columns(qw(pricegroup));
669
670   $column_header{pricegroup} = qq|<th><a class=listheading href=$href&sort=pricegroup width=90%>|.$locale->text('Pricegroup').qq|</th>|;
671
672   $form->{title} = $locale->text('Pricegroups');
673
674   $form->header;
675  
676   print qq|
677 <body>
678
679 <table width=100%>
680   <tr>
681     <th class=listtop>$form->{title}</th>
682   </tr>
683   <tr height="5"></tr>
684   <tr>
685     <td>$option</td>
686   </tr>
687   <tr>
688     <td>
689       <table width=100%>
690         <tr class=listheading>
691 |;
692
693   map { print "$column_header{$_}\n" } @column_index;
694   
695   print qq|
696         </tr>
697 |;
698
699   # escape callback
700   $form->{callback} = $callback;
701
702   # escape callback for href
703   $callback = $form->escape($callback);
704   
705   foreach $ref (@{ $form->{item_list} }) {
706     
707     $i++; $i %= 2;
708     
709     print qq|
710         <tr valign=top class=listrow$i>
711 |;
712     
713     $column_data{pricegroup} = qq|<td><a href=$form->{script}?action=edit&type=$form->{type}&status=$form->{status}&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{pricegroup}</td>|;
714     map { print "$column_data{$_}\n" } @column_index;
715     
716     print "
717         </tr>
718 ";
719   }
720
721   $i = 1;
722   if ($myconfig{acs} !~ /Goods \& Services--Goods \& Services/) {
723     $button{'Goods & Services--Add Pricegroup'}{code} = qq|<input class=submit type=submit name=action value="|.$locale->text('Add Pricegroup').qq|"> |;
724     $button{'Goods & Services--Add Pricegroup'}{order} = $i++;
725
726     foreach $item (split /;/, $myconfig{acs}) {
727       delete $button{$item};
728     }
729   }
730   
731   print qq|
732       </table>
733     </td>
734   </tr>
735   <tr>
736     <td><hr size=3 noshade></td>
737   </tr>
738 </table>
739
740 <br>
741 <form method=post action=$form->{script}>
742
743 <input name=callback type=hidden value="$form->{callback}">
744
745 <input type=hidden name=type value=$form->{type}>
746
747 <input type=hidden name=path value=$form->{path}>
748 <input type=hidden name=login value=$form->{login}>
749 <input type=hidden name=sessionid value=$form->{sessionid}>
750 |;
751
752   foreach $item (sort { $a->{order} <=> $b->{order} } %button) {
753     print $item->{code};
754   }
755
756   if ($form->{menubar}) {
757     require "$form->{path}/menu.pl";
758     &menubar;
759   }
760
761   print qq|
762   </form>
763
764 </body>
765 </html>
766 |;
767
768 }
769
770
771 sub pricegroup_header {
772
773   $form->{title} = $locale->text("$form->{title} Pricegroup");
774   
775 # $locale->text('Edit Pricegroup')
776
777   $form->{pricegroup} = $form->quote($form->{pricegroup});
778
779   
780   $form->header;
781
782   print qq|
783 <body>
784
785 <form method=post action=$form->{script}>
786
787 <input type=hidden name=id value=$form->{id}>
788 <input type=hidden name=type value=$form->{type}>
789
790 <table width=100%>
791   <tr>
792     <th class=listtop>$form->{title}</th>
793   </tr>
794   <tr height="5"></tr>
795   <tr>
796     <td>
797       <table width=100%>
798         <tr>
799           <th align=right>|.$locale->text('Pricegroup').qq|</th>
800
801           <td><input name=pricegroup size=30 value="$form->{pricegroup}"></td>
802         </tr>
803       </table>
804     </td>
805   </tr>
806   <tr>
807     <td colspan=2><hr size=3 noshade></td>
808   </tr>
809 </table>
810 |;
811
812 }
813
814
815 sub pricegroup_footer {
816
817   print qq|
818
819 <input name=callback type=hidden value="$form->{callback}">
820
821 <input type=hidden name=path value=$form->{path}>
822 <input type=hidden name=login value=$form->{login}>
823 <input type=hidden name=sessionid value=$form->{sessionid}>
824 <br>
825 |;
826
827   if ($myconfig{acs} !~ /Goods \& Services--Add Pricegroup/) {
828     print qq|
829 <input type=submit class=submit name=action value="|.$locale->text('Save').qq|">
830 |;
831
832     if ($form->{id} && $form->{orphaned}) {
833       print qq|
834 <input type=submit class=submit name=action value="|.$locale->text('Delete').qq|">|;
835     }
836   }
837
838   if ($form->{menubar}) {
839     require "$form->{path}/menu.pl";
840     &menubar;
841   }
842
843   print qq|
844 </form>
845
846 </body>
847 </html>
848 |;
849
850 }
851
852
853 sub translation {
854
855   if ($form->{translation} eq 'description') {
856     $form->{title} = $locale->text('Description Translations');
857     $sort = qq|<input type=hidden name=sort value=partnumber>|;
858     $form->{number} = "partnumber";
859     $number = qq|
860         <tr>
861           <th align=right nowrap>|.$locale->text('Number').qq|</th>
862           <td><input name=partnumber size=20></td>
863         </tr>
864 |;
865   }
866
867   if ($form->{translation} eq 'partsgroup') {
868     $form->{title} = $locale->text('Group Translations');
869     $sort = qq|<input type=hidden name=sort value=partsgroup>|;
870   }
871   
872   if ($form->{translation} eq 'project') {
873     $form->{title} = $locale->text('Project Description Translations');
874     $form->{number} = "projectnumber";
875     $sort = qq|<input type=hidden name=sort value=projectnumber>|;
876     $number = qq|
877         <tr>
878           <th align=right nowrap>|.$locale->text('Project Number').qq|</th>
879           <td><input name=projectnumber size=20></td>
880         </tr>
881 |;
882   }
883
884
885   $form->header;
886   
887   print qq|
888 <body>
889
890 <form method=post action=$form->{script}>
891
892 <input type=hidden name=translation value=$form->{translation}>
893 <input type=hidden name=title value="$form->{title}">
894 <input type=hidden name=number value=$form->{number}>
895
896 <table width="100%">
897   <tr><th class=listtop>$form->{title}</th></tr>
898   <tr height="5"></tr>
899   <tr valign=top>
900     <td>
901       <table>
902         $number
903         <tr>
904           <th align=right nowrap>|.$locale->text('Description').qq|</th>
905           <td colspan=3><input name=description size=40></td>
906         </tr>
907       </table>
908     </td>
909   </tr>
910   <tr><td><hr size=3 noshade></td></tr>
911 </table>
912
913 <input type=hidden name=nextsub value=list_translations>
914 $sort
915
916 <input type=hidden name=path value=$form->{path}>
917 <input type=hidden name=login value=$form->{login}>
918 <input type=hidden name=sessionid value=$form->{sessionid}>
919
920 <br>
921 <input class=submit type=submit name=action value="|.$locale->text('Continue').qq|">
922 </form>
923
924 </body>
925 </html>
926 |;
927
928 }
929
930
931 sub list_translations {
932
933   $title = $form->escape($form->{title},1);
934   
935   $callback = "$form->{script}?action=list_translations&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&translation=$form->{translation}&number=$form->{number}&title=$title";
936
937   if ($form->{"$form->{number}"}) {
938     $callback .= qq|&$form->{number}=$form->{"$form->{number}"}|;
939     $option .= $locale->text('Number').qq| : $form->{"$form->{number}"}<br>|;
940   }
941   if ($form->{description}) {
942     $callback .= "&description=$form->{description}";
943     $description = $form->{description};
944     $description =~ s/\r/<br>/g;
945     $option .= $locale->text('Description').qq| : $form->{description}<br>|;
946   }
947
948   if ($form->{translation} eq 'partsgroup') {
949     @column_index = qw(description language translation);
950     $form->{sort} = "";
951   } else {
952     @column_index = $form->sort_columns("$form->{number}", "description", "language", "translation");
953   }
954
955   &{ "PE::$form->{translation}_translations" }("", \%myconfig, \%$form);
956
957   $callback .= "&direction=$form->{direction}&oldsort=$form->{oldsort}";
958   
959   $href = $callback;
960   
961   $form->sort_order();
962   
963   $callback =~ s/(direction=).*\&{1}/$1$form->{direction}\&/;
964
965   $column_header{"$form->{number}"} = qq|<th nowrap><a class=listheading href=$href&sort=$form->{number}>|.$locale->text('Number').qq|</a></th>|;
966   $column_header{description} = qq|<th nowrap width=40%><a class=listheading href=$href&sort=description>|.$locale->text('Description').qq|</a></th>|;
967   $column_header{language} = qq|<th nowrap class=listheading>|.$locale->text('Language').qq|</a></th>|;
968   $column_header{translation} = qq|<th nowrap width=40% class=listheading>|.$locale->text('Translation').qq|</a></th>|;
969
970   $form->header;
971
972   print qq|
973 <body>
974
975 <table width=100%>
976   <tr>
977     <th class=listtop>$form->{title}</th>
978   </tr>
979   <tr height="5"></tr>
980
981   <tr><td>$option</td></tr>
982
983   <tr>
984     <td>
985       <table width=100%>
986         <tr class=listheading>
987 |;
988
989   map { print "\n$column_header{$_}" } @column_index;
990   
991   print qq|
992         </tr>
993   |;
994
995
996   # add order to callback
997   $form->{callback} = $callback .= "&sort=$form->{sort}";
998
999   # escape callback for href
1000   $callback = $form->escape($callback);
1001
1002   if (@{ $form->{translations} }) {
1003     $sameitem = $form->{translations}->[0]->{$form->{sort}};
1004   }
1005
1006   foreach $ref (@{ $form->{translations} }) {
1007   
1008     $ref->{description} =~ s/\r/<br>/g;
1009     
1010     map { $column_data{$_} = "<td>$ref->{$_}&nbsp;</td>" } @column_index;
1011     
1012     $column_data{description} = "<td><a href=$form->{script}?action=edit_translation&translation=$form->{translation}&number=$form->{number}&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{description}&nbsp;</a></td>";
1013     
1014     $i++; $i %= 2;
1015     print "<tr class=listrow$i>";
1016
1017     map { print "\n$column_data{$_}" } @column_index;
1018
1019     print qq|
1020     </tr>
1021 |;
1022
1023   }
1024   
1025   print qq|
1026       </table>
1027     </td>
1028   </tr>
1029   <tr><td><hr size=3 noshade></td></tr>
1030 </table>
1031
1032 |;
1033  
1034   print qq|
1035
1036 <br>
1037
1038 <form method=post action=$form->{script}>
1039
1040 <input name=callback type=hidden value="$form->{callback}">
1041
1042 <input type=hidden name=path value=$form->{path}>
1043 <input type=hidden name=login value=$form->{login}>
1044 <input type=hidden name=sessionid value=$form->{sessionid}>
1045 |;
1046
1047   if ($form->{menubar}) {
1048     require "$form->{path}/menu.pl";
1049     &menubar;
1050   }
1051
1052   print qq|
1053   </form>
1054
1055 </body>
1056 </html>
1057 |;
1058
1059 }
1060
1061
1062 sub edit_translation {
1063
1064   &{ "PE::$form->{translation}_translations" }("", \%myconfig, \%$form);
1065
1066   $form->error($locale->text('Languages not defined!')) unless $form->{all_language};
1067
1068   $form->{selectlanguage} = qq|<option>\n|;
1069   map { $form->{selectlanguage} .= qq|<option value="$_->{code}">$_->{description}\n| } @{ $form->{all_language} };
1070
1071   $form->{"$form->{number}"} = $form->{translations}->[0]->{"$form->{number}"};
1072   $form->{description} = $form->{translations}->[0]->{description};
1073   $form->{description} =~ s/\r/<br>/g;
1074
1075   shift @{ $form->{translations} };
1076
1077   $i = 1;
1078   foreach $row (@{ $form->{translations} }) {
1079     $form->{"language_code_$i"} = $row->{code};
1080     $form->{"translation_$i"} = $row->{translation};
1081     $i++;
1082   }
1083   $form->{translation_rows} = $i - 1;
1084     
1085   $form->{title} = $locale->text('Edit Description Translations');
1086   
1087   &translation_header;
1088   &translation_footer;
1089
1090 }
1091
1092
1093 sub translation_header {
1094
1095   $form->{translation_rows}++;
1096
1097   $form->{selectlanguage} = $form->unescape($form->{selectlanguage});
1098   for ($i = 1; $i <= $form->{translation_rows}; $i++) {
1099     $form->{"selectlanguage_$i"} = $form->{selectlanguage};
1100     if ($form->{"language_code_$i"}) {
1101       $form->{"selectlanguage_$i"} =~ s/(<option value="\Q$form->{"language_code_$i"}\E")/$1 selected/;
1102     }
1103   }
1104   
1105   $form->{selectlanguage} = $form->escape($form->{selectlanguage},1);
1106
1107   $form->header;
1108  
1109   print qq|
1110 <body>
1111
1112 <form method=post action=$form->{script}>
1113
1114 <input name=id type=hidden value=$form->{id}>
1115 <input name=trans_id type=hidden value=$form->{trans_id}>
1116
1117 <input type=hidden name=selectlanguage value="$form->{selectlanguage}">
1118 <input type=hidden name=translation_rows value=$form->{translation_rows}>
1119
1120 <input type=hidden name=number value=$form->{number}>
1121 <input type=hidden name=$form->{number} value="|.$form->quote($form->{"$form->{number}"}).qq|">
1122 <input type=hidden name=description value="|.$form->quote($form->{description}).qq|">
1123
1124 <input type=hidden name=translation value=$form->{translation}>
1125 <input type=hidden name=title value="$form->{title}">
1126
1127 <table width="100%">
1128   <tr><th class=listtop>$form->{title}</th></tr>
1129   <tr height="5"></tr>
1130   <tr valign=top>
1131     <td>
1132       <table width=100%>
1133         <tr>
1134           <td align=left>$form->{"$form->{number}"}</th>
1135           <td align=left>$form->{description}</th>
1136         </tr>
1137         <tr>
1138         <tr>
1139           <th class=listheading>|.$locale->text('Language').qq|</th>
1140           <th class=listheading>|.$locale->text('Translation').qq|</th>
1141         </tr>
1142 |;
1143
1144   for ($i = 1; $i <= $form->{translation_rows}; $i++) {
1145     
1146     if (($rows = $form->numtextrows($form->{"translation_$i"}, 40)) > 1) {
1147       $translation = qq|<textarea name="translation_$i" rows=$rows cols=40 wrap=soft>$form->{"translation_$i"}</textarea>|;
1148     } else {
1149       $translation = qq|<input name="translation_$i" size=40 value="$form->{"translation_$i"}">|;
1150     }
1151    
1152     print qq|
1153         <tr valign=top>
1154           <td><select name="language_code_$i">$form->{"selectlanguage_$i"}</select></td>
1155           <td>$translation</td>
1156         </tr>
1157 |;
1158   }
1159
1160   print qq|
1161       </table>
1162     </td>
1163   </tr>
1164   <tr>
1165     <td><hr size=3 noshade></td>
1166   </tr>
1167 </table>
1168 |;
1169
1170 }
1171
1172
1173 sub translation_footer {
1174
1175   print qq|
1176 <input type=hidden name=path value=$form->{path}>
1177 <input type=hidden name=login value=$form->{login}>
1178 <input type=hidden name=sessionid value=$form->{sessionid}>
1179
1180 <input type=hidden name=callback value="$form->{callback}">
1181
1182 <br>
1183
1184 <input class=submit type=submit name=action value="|.$locale->text('Update').qq|">
1185 <input class=submit type=submit name=action value="|.$locale->text('Save').qq|">
1186 |;
1187
1188   if ($form->{trans_id}) {
1189     print qq|
1190 <input class=submit type=submit name=action value="|.$locale->text('Delete').qq|">
1191 |;
1192   }
1193
1194   if ($form->{menubar}) {
1195     require "$form->{path}/menu.pl";
1196     &menubar;
1197   }
1198
1199   print qq|
1200
1201   </form>
1202
1203 </body>
1204 </html>
1205 |;
1206
1207 }
1208
1209
1210 sub update {
1211
1212   @flds = qw(language translation);
1213   $count = 0;
1214   @a = ();
1215   for $i (1 .. $form->{translation_rows}) {
1216     if ($form->{"language_code_$i"} ne "") {
1217       push @a, {};
1218       $j = $#a;
1219
1220       map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
1221       $count++;
1222     }
1223   }
1224   $form->redo_rows(\@flds, \@a, $count, $form->{translation_rows});
1225   $form->{translation_rows} = $count;
1226
1227   &translation_header;
1228   &translation_footer;
1229
1230 }
1231
1232     
1233 sub add_group { &add };
1234 sub add_project { &add };
1235 sub add_pricegroup { &add };
1236