forked from web2project/web2project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
updatecontact.php
259 lines (246 loc) · 9.97 KB
/
updatecontact.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
<?php
require_once 'base.php';
require_once W2P_BASE_DIR . '/includes/config.php';
require_once W2P_BASE_DIR . '/includes/main_functions.php';
require_once W2P_BASE_DIR . '/includes/db_adodb.php';
$AppUI = new w2p_Core_CAppUI();
$updatekey = w2PgetParam($_GET, 'updatekey', 0);
$contact_id = CContact::getContactByUpdatekey($updatekey);
$company_id = intval(w2PgetParam($_REQUEST, 'company_id', 0));
$company_name = w2PgetParam($_REQUEST, 'company_name', null);
// check permissions for this record
if (!$contact_id) {
echo ($AppUI->_('You are not authorized to use this page. If you should be authorized please contact') . ' ' . $w2Pconfig['company_name'] . ' ' . $AppUI->_('to give you another valid link, thank you.'));
exit;
}
// load the record data
$msg = '';
$row = new CContact();
if (!$row->load($contact_id) && $contact_id > 0) {
$AppUI->setMsg('Contact');
$AppUI->setMsg('invalidID', UI_MSG_ERROR, true);
$AppUI->redirect();
} else {
//TODO: replace with the proper canEdit()
if ($row->contact_private && $row->contact_owner != $AppUI->user_id && $row->contact_owner && $contact_id != 0) {
// check only owner can edit
$AppUI->redirect(ACCESS_DENIED);
}
}
$df = $AppUI->getPref('SHDATEFORMAT');
$df .= ' ' . $AppUI->getPref('TIMEFORMAT');
// setup the title block
$ttl = $contact_id > 0 ? 'Edit Contact' : 'Add Contact';
$company_detail = $row->getCompanyDetails();
$dept_detail = $row->getDepartmentDetails();
if ($contact_id == 0 && $company_id > 0) {
$company_detail['company_id'] = $company_id;
$company_detail['company_name'] = $company_name;
echo $company_name;
}
$uistyle = 'web2project';
$outsider = $row->contact_display_name;
require W2P_BASE_DIR . '/style/' . $uistyle . '/overrides.php';
require W2P_BASE_DIR . '/style/' . $uistyle . '/header.php';
if (is_callable('styleRenderBoxTop')) {
echo styleRenderBoxTop();
}
?>
<script language="javascript">
function submitIt() {
var form = document.changecontact;
if (form.contact_last_name.value.length < 1) {
alert( "<?php echo $AppUI->_('contactsValidName', UI_OUTPUT_JS); ?>" );
form.contact_last_name.focus();
} else {
form.submit();
}
}
function orderByName( x ){
var form = document.changecontact;
if (x == 'name') {
form.contact_order_by.value = form.contact_last_name.value + ", " + form.contact_first_name.value;
} else {
form.contact_order_by.value = form.contact_company_name.value;
}
}
</script>
<form name="changecontact" action="do_updatecontact.php" method="post" accept-charset="utf-8">
<input type="hidden" name="contact_project" value="0" />
<input type="hidden" name="contact_unique_update" value="<?php echo uniqid(''); ?>" />
<input type="hidden" name="updatekey" value="<?php echo $updatekey; ?>" />
<input type="hidden" name="contact_id" value="<?php echo $contact_id; ?>" />
<input type="hidden" name="contact_owner" value="<?php echo $row->contact_owner ? $row->contact_owner : $AppUI->user_id; ?>" />
<input type="hidden" name="contact_company" value="<?php echo $row->contact_company ? $row->contact_company : 0; ?>" />
<input type="hidden" name="contact_department" value="<?php echo $row->contact_department ? $row->contact_department : 0; ?>" />
<table border="0" cellpadding="4" cellspacing="0" width="100%" class="std">
<tr>
<td colspan="2">
<table border="0" cellpadding="1" cellspacing="1">
<tr>
<td nowrap="nowrap">
<strong><?php echo $AppUI->_('Please Edit Your Contact Information Below:'); ?></strong>
</td>
<td>
<input type="hidden" class="text" size="25" name="contact_first_name" value="<?php echo $row->contact_first_name; ?>" maxlength="50" />
</td>
</tr>
<tr>
<td>
<input type="hidden" class="text" size="25" name="contact_last_name" value="<?php echo $row->contact_last_name; ?>" maxlength="50" <?php if ($contact_id == 0) { ?> onblur="orderByName('name')"<?php } ?> />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" width="50%">
<table border="0" cellpadding="1" cellspacing="1" class="details" width="100%">
<tr>
<td align="right" width="100"><?php echo $AppUI->_('Job Title'); ?>:</td>
<td nowrap="nowrap">
<input type="text" class="text" name="contact_job" value="<?php echo $row->contact_job; ?>" maxlength="100" size="25" />
</td>
</tr>
<tr>
<td align="right"><?php echo $AppUI->_('Title'); ?>:</td>
<td><input type="text" class="text" name="contact_title" value="<?php echo $row->contact_title; ?>" maxlength="50" size="25" /></td>
</tr>
<tr>
<td align="right"><?php echo $AppUI->_('Type'); ?>:</td>
<td><input type="text" class="text" name="contact_type" value="<?php echo $row->contact_type; ?>" maxlength="50" size="25" /></td>
</tr>
<tr>
<td align="right" width="100"><?php echo $AppUI->_('Address'); ?>1:</td>
<td><input type="text" class="text" name="contact_address1" value="<?php echo $row->contact_address1; ?>" maxlength="60" size="25" /></td>
</tr>
<tr>
<td align="right"><?php echo $AppUI->_('Address'); ?>2:</td>
<td><input type="text" class="text" name="contact_address2" value="<?php echo $row->contact_address2; ?>" maxlength="60" size="25" /></td>
</tr>
<tr>
<td align="right"><?php echo $AppUI->_('City'); ?>:</td>
<td><input type="text" class="text" name="contact_city" value="<?php echo $row->contact_city; ?>" maxlength="30" size="25" /></td>
</tr>
<tr>
<td align="right"><?php echo $AppUI->_('State'); ?>:</td>
<td><input type="text" class="text" name="contact_state" value="<?php echo $row->contact_state; ?>" maxlength="30" size="25" /></td>
</tr>
<tr>
<td align="right"><?php echo $AppUI->_('Postcode') . ' / ' . $AppUI->_('Zip'); ?>:</td>
<td><input type="text" class="text" name="contact_zip" value="<?php echo $row->contact_zip; ?>" maxlength="11" size="25" /></td>
</tr>
<tr>
<td align="right"><?php echo $AppUI->_('Country'); ?>:</td>
<td>
<?php
$countries = array('' => $AppUI->_('(Select a Country)')) + w2PgetSysVal('GlobalCountries');
echo arraySelect($countries, 'contact_country', 'size="1" class="text"', $row->contact_country ? $row->contact_country : 0);
?>
</td>
</tr>
<tr>
<td align="right" width="100"><?php echo $AppUI->_('Work Phone'); ?>:</td>
<td>
<input type="text" class="text" name="contact_phone" value="<?php echo $row->contact_phone; ?>" maxlength="30" size="25" />
</td>
</tr>
<tr>
<td align="right"><?php echo $AppUI->_('Home Phone'); ?>:</td>
<td>
<input type="text" class="text" name="contact_phone2" value="<?php echo $row->contact_phone2; ?>" maxlength="30" size="25" />
</td>
</tr>
<tr>
<td align="right"><?php echo $AppUI->_('Fax'); ?>:</td>
<td>
<input type="text" class="text" name="contact_fax" value="<?php echo $row->contact_fax; ?>" maxlength="30" size="25" />
</td>
</tr>
<tr>
<td align="right"><?php echo $AppUI->_('Mobile Phone'); ?>:</td>
<td>
<input type="text" class="text" name="contact_mobile" value="<?php echo $row->contact_mobile; ?>" maxlength="30" size="25" />
</td>
</tr>
<tr>
<td align="right" width="100"><?php echo $AppUI->_('Email'); ?>:</td>
<td nowrap="nowrap">
<input type="text" class="text" name="contact_email" value="<?php echo $row->contact_email; ?>" maxlength="255" size="25" />
</td>
</tr>
<tr>
<td align="right"><?php echo $AppUI->_('Email'); ?>2:</td>
<td>
<input type="text" class="text" name="contact_email2" value="<?php echo $row->contact_email2; ?>" maxlength="255" size="25" />
</td>
</tr>
<tr>
<td align="right"><?php echo $AppUI->_('Home Page'); ?>2:</td>
<td>
<input type="text" class="text" name="contact_url" value="<?php echo $row->contact_url; ?>" maxlength="255" size="25" />
</td>
</tr>
<tr>
<td align="right">Jabber:</td>
<td>
<input type="text" class="text" name="contact_jabber" value="<?php echo $row->contact_jabber; ?>" maxlength="255" size="25" />
</td>
</tr>
<tr>
<td align="right">ICQ:</td>
<td>
<input type="text" class="text" name="contact_icq" value="<?php echo $row->contact_icq; ?>" maxlength="20" size="25" />
</td>
</tr>
<tr>
<td align="right">AOL:</td>
<td>
<input type="text" class="text" name="contact_aol" value="<?php echo $row->contact_aol; ?>" maxlength="20" size="25" />
</td>
</tr>
<tr>
<td align="right">MSN:</td>
<td>
<input type="text" class="text" name="contact_msn" value="<?php echo $row->contact_msn; ?>" maxlength="255" size="25" />
</td>
</tr>
<tr>
<td align="right">Yahoo:</td>
<td>
<input type="text" class="text" name="contact_yahoo" value="<?php echo $row->contact_yahoo; ?>" maxlength="255" size="25" />
</td>
</tr>
<tr>
<td align="right"><?php echo $AppUI->_('Birthday'); ?>:</td>
<td nowrap="nowrap">
<input type="text" class="text" name="contact_birthday" value="<?php echo substr($row->contact_birthday, 0, 10); ?>" maxlength="10" size="25" />(<?php echo $AppUI->_('yyyy-mm-dd'); ?>)
</td>
</tr>
<tr>
<td align="right" colspan="3">
<?php
$custom_fields = new w2p_Core_CustomFields('contacts', 'addedit', $row->contact_id, "edit", 1);
$custom_fields->printHTML();
?>
</td>
</tr>
</table>
</td>
<td valign="top" width="50%">
<strong><?php echo $AppUI->_('Contact Notes'); ?></strong><br />
<textarea class="textarea" name="contact_notes" rows="20" cols="40"><?php echo $row->contact_notes; ?></textarea>
</td>
</tr>
<tr>
<td colspan="2"></td>
<td align="right">
<input type="button" value="<?php echo $AppUI->_('submit'); ?>" class="button" onclick="submitIt()" />
</td>
</tr>
</table>
</form>
<?php
if (is_callable('styleRenderBoxTop')) {
echo styleRenderBoxBottom();
}