Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 08844064

Von Moritz Bunkus vor mehr als 16 Jahren hinzugefügt

  • ID 0884406403ce36af3484924086527ba689807329
  • Vorgänger 596c6378
  • Nachfolger de41ce6f

Projektverwaltung in eine eigene Datei ausgelagert und auf die Verwendung von Template umgestellt.

Unterschiede anzeigen:

bin/mozilla/pe.pl
27 27
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 28
#======================================================================
29 29
#
30
# project administration
31
# partsgroup administration
30
# partsgroup, pricegroup administration
32 31
#
33 32
#======================================================================
34 33

  
......
68 67
  #/show hhistory button
69 68
  $form->{title} = "Edit";
70 69

  
71
  if ($form->{type} eq 'project') {
72
    PE->get_project(\%myconfig, \%$form);
73
  }
74 70
  if ($form->{type} eq 'partsgroup') {
75 71
    PE->get_partsgroup(\%myconfig, \%$form);
76 72
  }
......
88 84

  
89 85
  $auth->assert('config');
90 86

  
91
  if ($form->{type} eq 'project') {
92
    $report        = "project_report";
93
    $sort          = 'projectnumber';
94
    $form->{title} = $locale->text('Projects');
95

  
96
    $number = qq|
97
	<tr>
98
	  <th align=right width=1%>| . $locale->text('Number') . qq|</th>
99
	  <td>| . $cgi->textfield('-name' => 'projectnumber', '-size' => 20) . qq|</td>
100
	</tr>
101
	<tr>
102
	  <th align=right>| . $locale->text('Description') . qq|</th>
103
	  <td>| . $cgi->textfield('-name' => 'description', '-size' => 60) . qq|</td>
104
	</tr>
105
  <tr>
106
    <th>&nbsp;</th>
107
    <td>| .
108
    $cgi->radio_group('-name' => 'active', '-default' => 'active',
109
                      '-values' => ['active', 'inactive', 'both'],
110
                      '-labels' => { 'active' => ' ' . $locale->text("Active"),
111
                                     'inactive' => ' ' . $locale->text("Inactive"),
112
                                     'both' => ' ' . $locale->text("Both") })
113
    . qq|</td>
114
  </tr>
115
|;
116

  
117
  }
118 87
  if ($form->{type} eq 'partsgroup') {
119 88
    $report        = "partsgroup_report";
120 89
    $sort          = 'partsgroup';
......
192 161
  $lxdebug->leave_sub();
193 162
}
194 163

  
195
sub project_report {
196
  $lxdebug->enter_sub();
197

  
198
  $auth->assert('config');
199

  
200
  map { $form->{$_} = $form->unescape($form->{$_}) }
201
    (projectnumber, description);
202
  PE->projects(\%myconfig, \%$form);
203

  
204
  $callback =
205
    "$form->{script}?action=project_report&type=$form->{type}&status=$form->{status}&active=" .
206
    E($form->{active});
207
  $href = $callback;
208

  
209
  if ($form->{status} eq 'all') {
210
    $option = $locale->text('All');
211
  }
212
  if ($form->{status} eq 'orphaned') {
213
    $option .= $locale->text('Orphaned');
214
  }
215
  if ($form->{projectnumber}) {
216
    $href     .= "&projectnumber=" . $form->escape($form->{projectnumber});
217
    $callback .= "&projectnumber=$form->{projectnumber}";
218
    $option   .=
219
      "\n<br>" . $locale->text('Project') . " : $form->{projectnumber}";
220
  }
221
  if ($form->{description}) {
222
    $href     .= "&description=" . $form->escape($form->{description});
223
    $callback .= "&description=$form->{description}";
224
    $option   .=
225
      "\n<br>" . $locale->text('Description') . " : $form->{description}";
226
  }
227

  
228
  @column_index = qw(projectnumber description);
229

  
230
  push(@column_index, "active") if ("both" eq $form->{active});
231

  
232
  $column_header{projectnumber} =
233
      qq|<th><a class=listheading href=$href&sort=projectnumber>|
234
    . $locale->text('Number')
235
    . qq|</a></th>|;
236
  $column_header{description} =
237
      qq|<th><a class=listheading href=$href&sort=description>|
238
    . $locale->text('Description')
239
    . qq|</a></th>|;
240
  $column_header{active} =
241
      qq|<th class="listheading">| . $locale->text('Active') . qq|</th>|;
242

  
243
  $form->{title} = $locale->text('Projects');
244

  
245
  $form->header;
246

  
247
  print qq|
248
<body>
249

  
250
<table width=100%>
251
  <tr>
252
    <th class=listtop>$form->{title}</th>
253
  </tr>
254
  <tr height="5"></tr>
255
  <tr>
256
    <td>$option</td>
257
  </tr>
258
  <tr>
259
    <td>
260
      <table width=100%>
261
	<tr class=listheading>
262
|;
263

  
264
  map { print "$column_header{$_}\n" } @column_index;
265

  
266
  print qq|
267
        </tr>
268
|;
269

  
270
  # escape callback
271
  $form->{callback} = $callback .= "&sort=$form->{sort}";
272

  
273
  # escape callback for href
274
  $callback = $form->escape($callback);
275

  
276
  foreach $ref (@{ $form->{project_list} }) {
277

  
278
    $i++;
279
    $i %= 2;
280

  
281
    print qq|
282
        <tr valign=top class=listrow$i>
283
|;
284

  
285
    $column_data{projectnumber} =
286
      qq|<td><a href=$form->{script}?action=edit&type=$form->{type}&status=$form->{status}&id=$ref->{id}&callback=$callback>$ref->{projectnumber}</td>|;
287
    $column_data{description} = qq|<td>$ref->{description}&nbsp;</td>|;
288
    $column_data{active} =
289
      qq|<td>| .
290
      ($ref->{active} ? $locale->text("Yes") : $locale->text("No")) .
291
      qq|</td>|;
292

  
293
    map { print "$column_data{$_}\n" } @column_index;
294

  
295
    print "
296
        </tr>
297
";
298
  }
299

  
300
  print qq|
301
      </table>
302
    </td>
303
  </tr>
304
  <tr>
305
    <td><hr size=3 noshade></td>
306
  </tr>
307
</table>
308

  
309
<br>
310
<form method=post action=$form->{script}>
311

  
312
<input name=callback type=hidden value="$form->{callback}">
313

  
314
<input type=hidden name=type value=$form->{type}>
315

  
316
<input class=submit type=submit name=action value="|
317
    . $locale->text('Add') . qq|">
318

  
319
  </form>
320

  
321
</body>
322
</html>
323
|;
324

  
325
  $lxdebug->leave_sub();
326
}
327

  
328
sub form_project_header {
329
  $lxdebug->enter_sub();
330

  
331
  $auth->assert('config');
332

  
333
  $form->{title} = $locale->text("$form->{title} Project");
334

  
335
  # $locale->text('Add Project')
336
  # $locale->text('Edit Project')
337

  
338
  $form->{description} =~ s/\"/&quot;/g;
339

  
340
  my $projectnumber =
341
    $cgi->textfield('-name' => 'projectnumber', '-size' => 20,
342
                    '-default' => $form->{projectnumber});
343

  
344
  my $description;
345
  if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
346
    $description =
347
      $cgi->textarea('-name' => 'description', '-rows' => $rows, '-cols' => 60,
348
                     '-style' => 'width: 100%', '-wrap' => 'soft',
349
                     '-default' => $form->{description});
350
  } else {
351
    $description =
352
      $cgi->textfield('-name' => 'description', '-size' => 60,
353
                      '-default' => $form->{description});
354
  }
355

  
356
  my $active;
357
  if ($form->{id}) {
358
    $active =
359
      qq|
360
  <tr>
361
    <th>&nbsp;</th>
362
    <td>| .
363
      $cgi->radio_group('-name' => 'active',
364
                        '-values' => [1, 0],
365
                        '-default' => $form->{active} * 1,
366
                        '-labels' => { 1 => $locale->text("Active"),
367
                                       0 => $locale->text("Inactive") })
368
      . qq|</td>
369
  </tr>
370
|;
371
  }
372

  
373
  $form->header;
374

  
375
  print qq|
376
<body>
377

  
378
<form method=post action=$form->{script}>
379

  
380
<input type=hidden name=id value=$form->{id}>
381
<input type=hidden name=type value=project>
382

  
383
<table width=100%>
384
  <tr>
385
    <th class=listtop>$form->{title}</th>
386
  </tr>
387
  <tr height="5"></tr>
388
  <tr>
389
    <td>
390
      <table>
391
	<tr>
392
	  <th align=right>| . $locale->text('Number') . qq|</th>
393
	  <td>$projectnumber</td>
394
	</tr>
395
	<tr>
396
	  <th align=right>| . $locale->text('Description') . qq|</th>
397
	  <td>$description</td>
398
	</tr>
399
      $active
400
      </table>
401
    </td>
402
  </tr>
403
  <tr>
404
    <td colspan=2><hr size=3 noshade></td>
405
  </tr>
406
</table>
407
|;
408

  
409
  $lxdebug->leave_sub();
410
}
411

  
412
sub form_project_footer {
413
  $lxdebug->enter_sub();
414

  
415
  $auth->assert('config');
416

  
417
  print qq|
418

  
419
<input name=callback type=hidden value="$form->{callback}">
420

  
421
<br><input type=submit class=submit name=action value="|
422
    . $locale->text('Save') . qq|">
423
|;
424

  
425
  if ($form->{id} && $form->{orphaned}) {
426
    print qq|
427
<input type=submit class=submit name=action value="|
428
      . $locale->text('Delete') . qq|">|;
429
  }
430

  
431
  if ($form->{id}) {
432
    # button for saving history
433
    print qq|
434
      <input type=button onclick=set_history_window(|
435
      . $form->{id}
436
      . qq|); name=history id=history value=|
437
      . $locale->text('history')
438
      . qq|>|;
439
    # /button for saving history
440
  }
441

  
442
  print qq|
443
</form>
444

  
445
</body>
446
</html>
447
|;
448

  
449
  $lxdebug->leave_sub();
450
}
451

  
452 164
sub save {
453 165
  $lxdebug->enter_sub();
454 166

  
455 167
  $auth->assert('config');
456 168

  
457
  if ($form->{type} eq 'project') {
458
    $form->isblank("projectnumber", $locale->text('Project Number missing!'));
459
    PE->save_project(\%myconfig, \%$form);
460
    $form->redirect($locale->text('Project saved!'));
461
  }
462 169
  if ($form->{type} eq 'partsgroup') {
463 170
    $form->isblank("partsgroup", $locale->text('Group missing!'));
464 171
    PE->save_partsgroup(\%myconfig, \%$form);
......
489 196

  
490 197
  PE->delete_tuple(\%myconfig, \%$form);
491 198

  
492
  if ($form->{type} eq 'project') {
493
    $form->redirect($locale->text('Project deleted!'));
494
  }
495 199
  if ($form->{type} eq 'partsgroup') {
496 200
    $form->redirect($locale->text('Group deleted!'));
497 201
  }

Auch abrufbar als: Unified diff