forked from jbuchbinder/legalcase
/
upd_case.php
117 lines (90 loc) · 2.92 KB
/
upd_case.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
/*
This file is part of the Legal Case Management System (LCM).
(C) 2004-2005 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
$Id: upd_case.php,v 1.60 2006/08/22 21:11:48 mlutfy Exp $
*/
include('inc/inc.php');
include_lcm('inc_acc');
include_lcm('inc_filters');
include_lcm('inc_obj_case');
// Clear all previous errors
$_SESSION['errors'] = array();
// Get form data from POST fields
foreach($_POST as $key => $value)
$_SESSION['form_data'][$key] = $value;
//
// Clean (most of the) input
//
$id_case = _request('id_case', 0);
//
// Create client, if requested
//
if (_request('add_client')) {
include_lcm('inc_obj_client');
$client = new LcmClient();
$errs = $client->save();
if (count($errs)) {
$_SESSION['errors'] = array_merge($_SESSION['errors'], $errs);
} else {
$_SESSION['form_data']['attach_client'] = $client->getDataInt('id_client', '__ASSERT__');
}
}
//
// Create organisation, if requested
//
if (_request('add_org')) {
include_lcm('inc_obj_org');
$org = new LcmOrg();
$errs = $org->save();
if (count($errs)) {
$_SESSION['errors'] = array_merge($_SESSION['errors'], $errs);
} else {
$_SESSION['form_data']['attach_org'] = $org->getDataInt('id_org', '__ASSERT__');
}
}
//
// Create or update case data
//
$case = new LcmCase($id_case);
$errs = $case->save();
if (count($errs)) {
$_SESSION['errors'] = array_merge($_SESSION['errors'], $errs);
lcm_header("Location: ". $_SERVER['HTTP_REFERER']);
exit;
}
//
// Create follow-up data
//
if (_request('add_fu')) {
include_lcm('inc_obj_fu');
$fu = new LcmFollowup(0, $case->getDataInt('id_case'));
$errs = $fu->save();
if (count($errs)) {
$_SESSION['errors'] = array_merge($_SESSION['errors'], $errs);
lcm_header("Location: ". $_SERVER['HTTP_REFERER']);
exit;
}
}
$send_to = _request('ref_edit_case', "case_det.php?case=" . $case->getDataInt('id_case'));
// Send to add_client if any client/org to attach
if (_session('attach_client') || _session('attach_org')) {
lcm_header("Location: add_client.php?case=" . $case->getDataInt('id_case')
. (_session('attach_client') ? "&clients[]=" . _session('attach_client') : '')
. (_session('attach_org') ? "&orgs[]=" . _session('attach_org') : '')
. "&ref_sel_client=" . rawurlencode($send_to));
exit;
}
lcm_header("Location: " . $send_to);
?>