Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 1b83184a

Von Sven Schöling vor etwa 13 Jahren hinzugefügt

  • ID 1b83184af8383acf47b568697b87bafd7c377780
  • Vorgänger d4fc9016
  • Nachfolger 1d64d7e5

pe -> templates

Unterschiede anzeigen:

bin/mozilla/pe.pl
42 42
# end of main
43 43

  
44 44
sub add {
45
  $main::lxdebug->enter_sub();
45
  $::lxdebug->enter_sub;
46
  $::auth->assert('config');
46 47

  
47
  $main::auth->assert('config');
48
  $::form->{title} = "Add";
49
  $::form->{callback} ||= "$::form->{script}?action=add&type=$::form->{type}";
48 50

  
49
  my $form     = $main::form;
51
  call_sub("form_$::form->{type}");
50 52

  
51
  $form->{title} = "Add";
52

  
53
  # construct callback
54
  $form->{callback} =
55
    "$form->{script}?action=add&type=$form->{type}"
56
    unless $form->{callback};
57

  
58
  call_sub("form_$form->{type}_header");
59
  call_sub("form_$form->{type}_footer");
60

  
61
  $main::lxdebug->leave_sub();
53
  $::lxdebug->leave_sub;
62 54
}
63 55

  
64 56
sub edit {
65
  $main::lxdebug->enter_sub();
57
  $::lxdebug->enter_sub;
58
  $::auth->assert('config');
66 59

  
67
  $main::auth->assert('config');
60
  $::form->{title} = "Edit";
68 61

  
69
  my $form     = $main::form;
70
  my %myconfig = %main::myconfig;
71

  
72
  # show history button
73
  $form->{javascript} = qq|<script type="text/javascript" src="js/show_history.js"></script>|;
74
  #/show hhistory button
75
  $form->{title} = "Edit";
76

  
77
  if ($form->{type} eq 'partsgroup') {
78
    PE->get_partsgroup(\%myconfig, \%$form);
62
  if ($::form->{type} eq 'partsgroup') {
63
    PE->get_partsgroup(\%::myconfig, $::form);
79 64
  }
80
  if ($form->{type} eq 'pricegroup') {
81
    PE->get_pricegroup(\%myconfig, \%$form);
65
  if ($::form->{type} eq 'pricegroup') {
66
    PE->get_pricegroup(\%::myconfig, $::form);
82 67
  }
83
  call_sub("form_$form->{type}_header");
84
  call_sub("form_$form->{type}_footer");
68
  call_sub("form_$::form->{type}");
85 69

  
86
  $main::lxdebug->leave_sub();
70
  $::lxdebug->leave_sub;
87 71
}
88 72

  
89 73
sub search {
90
  $main::lxdebug->enter_sub();
91

  
92
  $main::auth->assert('config');
93

  
94
  my $form     = $main::form;
95
  my $locale   = $main::locale;
96

  
97
  my ($report, $sort, $number);
98
  if ($form->{type} eq 'partsgroup') {
99
    $report        = "partsgroup_report";
100
    $sort          = 'partsgroup';
101
    $form->{title} = $locale->text('Groups');
102

  
103
    $number = qq|
104
  <tr>
105
    <th align=right width=1%>| . $locale->text('Group') . qq|</th>
106
    <td><input name=partsgroup size=20></td>
107
  </tr>
108
|;
109

  
110
  }
111

  
112
  # for pricesgroups
113
  if ($form->{type} eq 'pricegroup') {
114
    $report        = "pricegroup_report";
115
    $sort          = 'pricegroup';
116
    $form->{title} = $locale->text('Pricegroup');
74
  $::lxdebug->enter_sub;
75
  $::auth->assert('config');
117 76

  
118
    $number = qq|
119
  <tr>
120
    <th align=right width=1%>| . $locale->text('Pricegroup') . qq|</th>
121
    <td><input name=pricegroup size=20></td>
122
  </tr>
123
|;
77
  $::form->header;
78
  print $::form->parse_html_template('pe/search', {
79
    is_pricegroup => $::form->{type} eq 'pricegroup',
80
  });
124 81

  
125
  }
126

  
127
  $form->header;
128

  
129
  print qq|
130
<body>
131

  
132
<form method=post action=$form->{script}>
133

  
134
<input type=hidden name=sort value=$sort>
135
<input type=hidden name=type value=$form->{type}>
136

  
137
<table width=100%>
138
  <tr>
139
    <th class=listtop>$form->{title}</th>
140
  </tr>
141
  <tr height="5"></tr>
142
  <tr>
143
    <td>
144
      <table width=100%>
145
        $number
146
        <tr>
147
          <td></td>
148
          <td><input name=status class=radio type=radio value=all checked>&nbsp;| . $locale->text('All') . qq|
149
          <input name=status class=radio type=radio value=orphaned>&nbsp;| . $locale->text('Orphaned') . qq|</td>
150
        </tr>
151
      </table>
152
    </td>
153
  </tr>
154
  <tr>
155
    <td><hr size=3 noshade></td>
156
  </tr>
157
</table>
158

  
159
<input type=hidden name=nextsub value=$report>
160

  
161
<br>
162
<input class=submit type=submit name=action value="|
163
    . $locale->text('Continue') . qq|">
164
</form>
165

  
166
</body>
167
</html>
168
|;
169

  
170
  $main::lxdebug->leave_sub();
82
  $::lxdebug->leave_sub;
171 83
}
172 84

  
173 85
sub save {
174
  $main::lxdebug->enter_sub();
175

  
176
  $main::auth->assert('config');
86
  $::lxdebug->enter_sub;
87
  $::auth->assert('config');
177 88

  
178
  my $form     = $main::form;
179
  my %myconfig = %main::myconfig;
180
  my $locale   = $main::locale;
181

  
182
  if ($form->{type} eq 'partsgroup') {
183
    $form->isblank("partsgroup", $locale->text('Group missing!'));
184
    PE->save_partsgroup(\%myconfig, \%$form);
185
    $form->redirect($locale->text('Group saved!'));
89
  if ($::form->{type} eq 'partsgroup') {
90
    $::form->isblank("partsgroup", $::locale->text('Group missing!'));
91
    PE->save_partsgroup(\%::myconfig, $::form);
92
    $::form->redirect($::locale->text('Group saved!'));
186 93
  }
187 94

  
188 95
  # choice pricegroup and save
189
  if ($form->{type} eq 'pricegroup') {
190
    $form->isblank("pricegroup", $locale->text('Pricegroup missing!'));
191
    PE->save_pricegroup(\%myconfig, \%$form);
192
    $form->redirect($locale->text('Pricegroup saved!'));
96
  if ($::form->{type} eq 'pricegroup') {
97
    $::form->isblank("pricegroup", $::locale->text('Pricegroup missing!'));
98
    PE->save_pricegroup(\%::myconfig, $::form);
99
    $::form->redirect($::locale->text('Pricegroup saved!'));
193 100
  }
194 101
  # saving the history
195
  if(!exists $form->{addition} && $form->{id} ne "") {
196
    $form->{snumbers} = qq|projectnumber_| . $form->{projectnumber};
197
    $form->{addition} = "SAVED";
198
    $form->save_history;
102
  if(!exists $::form->{addition} && $::form->{id} ne "") {
103
    $::form->{snumbers} = qq|projectnumber_| . $::form->{projectnumber};
104
    $::form->{addition} = "SAVED";
105
    $::form->save_history;
199 106
  }
200 107
  # /saving the history
201 108

  
202
  $main::lxdebug->leave_sub();
109
  $::lxdebug->leave_sub;
203 110
}
204 111

  
205 112
sub delete {
206
  $main::lxdebug->enter_sub();
207

  
208
  $main::auth->assert('config');
209

  
210
  my $form     = $main::form;
211
  my %myconfig = %main::myconfig;
212
  my $locale   = $main::locale;
113
  $::lxdebug->enter_sub;
114
  $::auth->assert('config');
213 115

  
214
  PE->delete_tuple(\%myconfig, \%$form);
116
  PE->delete_tuple(\%::myconfig, $::form);
215 117

  
216
  if ($form->{type} eq 'partsgroup') {
217
    $form->redirect($locale->text('Group deleted!'));
118
  if ($::form->{type} eq 'partsgroup') {
119
    $::form->redirect($::locale->text('Group deleted!'));
218 120
  }
219
  if ($form->{type} eq 'pricegroup') {
220
    $form->redirect($locale->text('Pricegroup deleted!'));
121
  if ($::form->{type} eq 'pricegroup') {
122
    $::form->redirect($::locale->text('Pricegroup deleted!'));
221 123
  }
222 124
  # saving the history
223
  if(!exists $form->{addition}) {
224
    $form->{snumbers} = qq|projectnumber_| . $form->{projectnumber};
225
    $form->{addition} = "DELETED";
226
    $form->save_history;
125
  if(!exists $::form->{addition}) {
126
    $::form->{snumbers} = qq|projectnumber_| . $::form->{projectnumber};
127
    $::form->{addition} = "DELETED";
128
    $::form->save_history;
227 129
  }
228 130
  # /saving the history
229
  $main::lxdebug->leave_sub();
131
  $::lxdebug->leave_sub;
230 132
}
231 133

  
232
sub continue { call_sub($main::form->{"nextsub"}); }
134
sub continue { call_sub($::form->{nextsub}); }
233 135

  
234 136
sub partsgroup_report {
235
  $main::lxdebug->enter_sub();
137
  $::lxdebug->enter_sub;
138
  $::auth->assert('config');
236 139

  
237
  $main::auth->assert('config');
140
  $::form->{$_} = $::form->unescape($::form->{$_}) for qw(partsgroup);
141
  PE->partsgroups(\%::myconfig, $::form);
238 142

  
239
  my $form     = $main::form;
240
  my %myconfig = %main::myconfig;
241
  my $locale   = $main::locale;
143
  my $callback = build_std_url("action=partsgroup_report", qw(type status));
242 144

  
243
  map { $form->{$_} = $form->unescape($form->{$_}) } qw(partsgroup);
244
  PE->partsgroups(\%myconfig, \%$form);
145
  my $option = '';
146
  $option .= $::locale->text('All')      if $::form->{status} eq 'all';
147
  $option .= $::locale->text('Orphaned') if $::form->{status} eq 'orphaned';
245 148

  
246
  my $callback =
247
    "$form->{script}?action=partsgroup_report&type=$form->{type}&status=$form->{status}";
248

  
249
  my ($option);
250
  if ($form->{status} eq 'all') {
251
    $option = $locale->text('All');
252
  }
253
  if ($form->{status} eq 'orphaned') {
254
    $option .= $locale->text('Orphaned');
255
  }
256
  if ($form->{partsgroup}) {
257
    $callback .= "&partsgroup=$form->{partsgroup}";
258
    $option   .= "\n<br>" . $locale->text('Group') . " : $form->{partsgroup}";
149
  if ($::form->{partsgroup}) {
150
    $callback .= "&partsgroup=$::form->{partsgroup}";
151
    $option   .= ", " . $::locale->text('Group') . " : $::form->{partsgroup}";
259 152
  }
260 153

  
261
  my @column_index = $form->sort_columns(qw(partsgroup));
262
  my %column_header;
263
  $column_header{partsgroup} =
264
    qq|<th class=listheading width=90%>| . $locale->text('Group') . qq|</th>|;
265

  
266
  $form->{title} = $locale->text('Groups');
267

  
268
  $form->header;
269

  
270
  print qq|
271
<body>
272

  
273
<table width=100%>
274
  <tr>
275
    <th class=listtop>$form->{title}</th>
276
  </tr>
277
  <tr height="5"></tr>
278
  <tr>
279
    <td>$option</td>
280
  </tr>
281
  <tr>
282
    <td>
283
      <table width=100%>
284
        <tr class=listheading>
285
|;
286

  
287
  map { print "$column_header{$_}\n" } @column_index;
288

  
289
  print qq|
290
        </tr>
291
|;
292

  
293 154
  # escape callback
294
  $form->{callback} = $callback;
295

  
296
  # escape callback for href
297
  $callback = $form->escape($callback);
298

  
299
  my ($i, %column_data);
300
  foreach my $ref (@{ $form->{item_list} }) {
301

  
302
    $i++;
303
    $i %= 2;
304

  
305
    print qq|
306
        <tr valign=top class=listrow$i>
307
|;
308

  
309
    $column_data{partsgroup} =
310
      qq|<td><a href=$form->{script}?action=edit&type=$form->{type}&status=$form->{status}&id=$ref->{id}&callback=$callback>$ref->{partsgroup}</td>|;
311
    map { print "$column_data{$_}\n" } @column_index;
312

  
313
    print "
314
        </tr>
315
";
316
  }
317

  
318
  print qq|
319
      </table>
320
    </td>
321
  </tr>
322
  <tr>
323
    <td><hr size=3 noshade></td>
324
  </tr>
325
</table>
326

  
327
<br>
328
<form method=post action=$form->{script}>
329

  
330
<input name=callback type=hidden value="$form->{callback}">
331

  
332
<input type=hidden name=type value=$form->{type}>
333

  
334
<input class=submit type=submit name=action value="|
335
    . $locale->text('Add') . qq|">
155
  $::form->{callback} = $callback;
336 156

  
337
  </form>
157
  $::form->header;
158
  print $::form->parse_html_template('pe/partsgroup_report', {
159
    option   => $option,
160
    callback => $callback,
161
    editlink => build_std_url('action=edit', qw(type status callback)),
162
  });
338 163

  
339
</body>
340
</html>
341
|;
342

  
343
  $main::lxdebug->leave_sub();
164
  $::lxdebug->leave_sub;
344 165
}
345 166

  
346
sub form_partsgroup_header {
347
  $main::lxdebug->enter_sub();
348

  
349
  $main::auth->assert('config');
350

  
351
  my $form     = $main::form;
352
  my $locale   = $main::locale;
353

  
354
  $form->{title} = $locale->text("$form->{title} Group");
167
sub form_partsgroup {
168
  $::lxdebug->enter_sub;
169
  $::auth->assert('config');
355 170

  
356 171
  # $locale->text('Add Group')
357 172
  # $locale->text('Edit Group')
173
  $::form->{title} = $::locale->text("$::form->{title} Group");
358 174

  
359
  $form->{partsgroup} =~ s/\"/&quot;/g;
360

  
361
  $form->header;
362

  
363
  print qq|
364
<body>
365

  
366
<form method=post action=$form->{script}>
367

  
368
<input type=hidden name=id value=$form->{id}>
369
<input type=hidden name=type value=$form->{type}>
370

  
371
<table width=100%>
372
  <tr>
373
    <th class=listtop>$form->{title}</th>
374
  </tr>
375
  <tr height="5"></tr>
376
  <tr>
377
    <td>
378
      <table width=100%>
379
        <tr>
380
          <th align=right>| . $locale->text('Group') . qq|</th>
381
          <td><input name=partsgroup size=30 value="$form->{partsgroup}"></td>
382
        </tr>
383
      </table>
384
    </td>
385
  </tr>
386
  <tr>
387
    <td colspan=2><hr size=3 noshade></td>
388
  </tr>
389
</table>
390
|;
391

  
392
  $main::lxdebug->leave_sub();
393
}
175
  $::form->header;
176
  print $::form->parse_html_template('pe/partsgroup_form');
394 177

  
395
sub form_partsgroup_footer {
396
  $main::lxdebug->enter_sub();
397

  
398
  $main::auth->assert('config');
399

  
400
  my $form     = $main::form;
401
  my $locale   = $main::locale;
402

  
403
  print qq|
404

  
405
<input name=callback type=hidden value="$form->{callback}">
406

  
407
<br><input type=submit class=submit name=action value="|
408
    . $locale->text('Save') . qq|">
409
|;
410

  
411
  if ($form->{id} && $form->{orphaned}) {
412
    print qq|
413
<input type=submit class=submit name=action value="|
414
      . $locale->text('Delete') . qq|">|;
415
  }
416

  
417
# button for saving history
418
print qq|
419
    <input type=button onclick=set_history_window(|
420
    . $form->{id}
421
    . qq|); name=history id=history value=|
422
    . $locale->text('history')
423
    . qq|>|;
424
# /button for saving history
425
  print qq|
426
</form>
427

  
428
</body>
429
</html>
430
|;
431

  
432
  $main::lxdebug->leave_sub();
178
  $::lxdebug->leave_sub;
433 179
}
434 180

  
435
#################################
436
# get pricesgroups and build up html-code
437
#
438 181
sub pricegroup_report {
439
  $main::lxdebug->enter_sub();
182
  $::lxdebug->enter_sub;
183
  $::auth->assert('config');
440 184

  
441
  $main::auth->assert('config');
185
  $::form->{$_} = $::form->unescape($::form->{$_}) for qw(pricegroup);
186
  PE->pricegroups(\%::myconfig, $::form);
442 187

  
443
  my $form     = $main::form;
444
  my %myconfig = %main::myconfig;
445
  my $locale   = $main::locale;
188
  my $callback = build_std_url('action=pricegroup_report', qw(type status));
446 189

  
447
  map { $form->{$_} = $form->unescape($form->{$_}) } qw(pricegroup);
448
  PE->pricegroups(\%myconfig, \%$form);
190
  my $option = '';
191
  $option .= $::locale->text('All')      if $::form->{status} eq 'all';
192
  $option .= $::locale->text('Orphaned') if $::form->{status} eq 'orphaned';
449 193

  
450
  my $callback =
451
    "$form->{script}?action=pricegroup_report&type=$form->{type}&status=$form->{status}";
452

  
453
  my $option;
454
  if ($form->{status} eq 'all') {
455
    $option = $locale->text('All');
456
  }
457
  if ($form->{status} eq 'orphaned') {
458
    $option .= $locale->text('Orphaned');
194
  if ($::form->{pricegroup}) {
195
    $callback .= "&pricegroup=$::form->{pricegroup}";
196
    $option   .= ", " . $::locale->text('Pricegroup') . " : $::form->{pricegroup}";
459 197
  }
460
  if ($form->{pricegroup}) {
461
    $callback .= "&pricegroup=$form->{pricegroup}";
462
    $option   .=
463
      "\n<br>" . $locale->text('Pricegroup') . " : $form->{pricegroup}";
464
  }
465

  
466
  my @column_index = $form->sort_columns(qw(pricegroup));
467
  my %column_header;
468
  $column_header{pricegroup} =
469
      qq|<th class=listheading width=90%>|
470
    . $locale->text('Pricegroup')
471
    . qq|</th>|;
472

  
473
  $form->{title} = $locale->text('Pricegroup');
474

  
475
  $form->header;
476

  
477
  print qq|
478
<body>
479

  
480
<table width=100%>
481
  <tr>
482
    <th class=listtop>$form->{title}</th>
483
  </tr>
484
  <tr height="5"></tr>
485
  <tr>
486
    <td>$option</td>
487
  </tr>
488
  <tr>
489
    <td>
490
      <table width=100%>
491
        <tr class=listheading>
492
|;
493

  
494
  map { print "$column_header{$_}\n" } @column_index;
495

  
496
  print qq|
497
        </tr>
498
|;
499 198

  
500 199
  # escape callback
501
  $form->{callback} = $callback;
502

  
503
  # escape callback for href
504
  $callback = $form->escape($callback);
505

  
506
  my ($i, %column_data);
507
  foreach my $ref (@{ $form->{item_list} }) {
508

  
509
    $i++;
510
    $i %= 2;
200
  $::form->{callback} = $callback;
511 201

  
512
    print qq|
513
        <tr valign=top class=listrow$i>
514
|;
515
    $column_data{pricegroup} =
516
      qq|<td><a href=$form->{script}?action=edit&type=$form->{type}&status=$form->{status}&id=$ref->{id}&callback=$callback>$ref->{pricegroup}</td>|;
202
  $::form->header;
203
  print $::form->parse_html_template('pe/pricegroup_report', {
204
    option   => $option,
205
    callback => $callback,
206
    editlink => build_std_url('action=edit', qw(type status callback)),
207
  });
517 208

  
518
    map { print "$column_data{$_}\n" } @column_index;
519

  
520
    print "
521
        </tr>
522
";
523
  }
524

  
525
  print qq|
526
      </table>
527
    </td>
528
  </tr>
529
  <tr>
530
    <td><hr size=3 noshade></td>
531
  </tr>
532
</table>
533

  
534
<br>
535
<form method=post action=$form->{script}>
536

  
537
<input name=callback type=hidden value="$form->{callback}">
538

  
539
<input type=hidden name=type value=$form->{type}>
540

  
541
<input class=submit type=submit name=action value="|
542
    . $locale->text('Add') . qq|">
543

  
544
  </form>
545

  
546
</body>
547
</html>
548
|;
549

  
550
  $main::lxdebug->leave_sub();
209
  $::lxdebug->leave_sub;
551 210
}
552 211

  
553
#######################
554
#build up pricegroup_header
555
#
556
sub form_pricegroup_header {
557
  $main::lxdebug->enter_sub();
558

  
559
  $main::auth->assert('config');
560

  
561
  my $form     = $main::form;
562
  my $locale   = $main::locale;
212
sub form_pricegroup {
213
  $::lxdebug->enter_sub;
214
  $::auth->assert('config');
563 215

  
564 216
  # $locale->text('Add Pricegroup')
565 217
  # $locale->text('Edit Pricegroup')
218
  $::form->{title} = $::locale->text("$::form->{title} Pricegroup");
566 219

  
567
  $form->{title} = $locale->text("$form->{title} Pricegroup");
568

  
569
  $form->{pricegroup} =~ s/\"/&quot;/g;
570

  
571
  $form->header;
572

  
573
  print qq|
574
<body>
575

  
576
<form method=post action=$form->{script}>
577

  
578
<input type=hidden name=id value=$form->{id}>
579
<input type=hidden name=type value=$form->{type}>
580

  
581
<table width=100%>
582
  <tr>
583
    <th class=listtop>$form->{title}</th>
584
  </tr>
585
  <tr height="5"></tr>
586
  <tr>
587
    <td>
588
      <table width=100%>
589
        <tr>
590
          <th align=right>| . $locale->text('Preisgruppe') . qq|</th>
591
          <td><input name=pricegroup size=30 value="$form->{pricegroup}"></td>
592
        </tr>
593
      </table>
594
    </td>
595
  </tr>
596
  <tr>
597
    <td colspan=2><hr size=3 noshade></td>
598
  </tr>
599
</table>
600
|;
601

  
602
  $main::lxdebug->leave_sub();
603
}
604
######################
605
#build up pricegroup_footer
606
#
607
sub form_pricegroup_footer {
608
  $main::lxdebug->enter_sub();
609

  
610
  $main::auth->assert('config');
611

  
612
  my $form     = $main::form;
613
  my $locale   = $main::locale;
614

  
615
  print qq|
616

  
617
<input name=callback type=hidden value="$form->{callback}">
618

  
619
<br><input type=submit class=submit name=action value="|
620
    . $locale->text('Save') . qq|">
621
|;
622

  
623
  if ($form->{id} && $form->{orphaned}) {
624
    print qq|
625
<input type=submit class=submit name=action value="|
626
      . $locale->text('Delete') . qq|">|;
627
  }
220
  $::form->header;
221
  print $::form->parse_html_template('pe/pricegroup_form');
628 222

  
629
# button for saving history
630
print qq|
631
    <input type=button onclick=set_history_window(|
632
    . $form->{id}
633
    . qq|); name=history id=history value=|
634
    . $locale->text('history')
635
    . qq|>|;
636
# /button for saving history
637
  print qq|
638
</form>
639

  
640
</body>
641
</html>
642
|;
643

  
644
  $main::lxdebug->leave_sub();
223
  $::lxdebug->leave_sub;
645 224
}

Auch abrufbar als: Unified diff