1
|
<?php
|
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
|
require_once "core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_request.php";
|
33
|
require_once "modules".DIRECTORY_SEPARATOR."entities"
|
34
|
.DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."EntityControler.php";
|
35
|
require_once "apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR
|
36
|
."class".DIRECTORY_SEPARATOR."class_lists.php";
|
37
|
require_once 'modules/notes/notes_tables.php';
|
38
|
require_once "modules" . DIRECTORY_SEPARATOR . "notes" . DIRECTORY_SEPARATOR
|
39
|
. "class" . DIRECTORY_SEPARATOR . "class_modules_tools.php";
|
40
|
|
41
|
$core_tools = new core_tools();
|
42
|
$request = new request();
|
43
|
$db = new Database();
|
44
|
$sec = new security();
|
45
|
$ent = new EntityControler();
|
46
|
$notesTools = new notes();
|
47
|
$list = new lists();
|
48
|
|
49
|
$destination = '';
|
50
|
|
51
|
function _parse($text) {
|
52
|
|
53
|
$text = str_replace("\r\n", "\n", $text);
|
54
|
$text = str_replace("\r", "\n", $text);
|
55
|
|
56
|
|
57
|
$text = str_replace("\n", "\\n ", $text);
|
58
|
return $text;
|
59
|
}
|
60
|
|
61
|
$core_tools->load_lang();
|
62
|
|
63
|
$status = 0;
|
64
|
$error = $content = $js = $parameters = '';
|
65
|
|
66
|
$labels_array = array();
|
67
|
|
68
|
if (isset($_REQUEST['mode']) && !empty($_REQUEST['mode'])) {
|
69
|
$mode = $_REQUEST['mode'];
|
70
|
} else {
|
71
|
$error = _ERROR_IN_NOTES_FORM_GENERATION;
|
72
|
$status = 1;
|
73
|
}
|
74
|
|
75
|
|
76
|
$identifier = '';
|
77
|
if (isset($_REQUEST['identifier']) && ! empty($_REQUEST['identifier'])) {
|
78
|
$identifier = trim($_REQUEST['identifier']);
|
79
|
}
|
80
|
|
81
|
|
82
|
if (isset($_REQUEST['coll_id']) && ! empty($_REQUEST['coll_id'])) {
|
83
|
$collId = trim($_REQUEST['coll_id']);
|
84
|
$parameters .= '&coll_id='.$_REQUEST['coll_id'];
|
85
|
$view = $sec->retrieve_view_from_coll_id($collId);
|
86
|
$table = $sec->retrieve_table_from_coll($collId);
|
87
|
|
88
|
$stmt = $db->query(
|
89
|
"SELECT destination FROM " . $table . " WHERE res_id = ?", array($identifier)
|
90
|
);
|
91
|
$resultDest = $stmt->fetchObject();
|
92
|
$destination = $resultDest->destination;
|
93
|
}
|
94
|
|
95
|
|
96
|
if (isset($_REQUEST['size']) && !empty($_REQUEST['size'])) $parameters .= '&size='.$_REQUEST['size'];
|
97
|
if (isset($_REQUEST['order']) && !empty($_REQUEST['order'])) {
|
98
|
$parameters .= '&order='.$_REQUEST['order'];
|
99
|
if (isset($_REQUEST['order_field']) && !empty($_REQUEST['order_field'])) $parameters .= '&order_field='.$_REQUEST['order_field'];
|
100
|
}
|
101
|
if (isset($_REQUEST['what']) && !empty($_REQUEST['what'])) $parameters .= '&what='.$_REQUEST['what'];
|
102
|
if (isset($_REQUEST['template']) && !empty($_REQUEST['template'])) $parameters .= '&template='.$_REQUEST['template'];
|
103
|
if (isset($_REQUEST['start']) && !empty($_REQUEST['start'])) $parameters .= '&start='.$_REQUEST['start'];
|
104
|
|
105
|
|
106
|
$list_origin = $origin = '';
|
107
|
if (isset($_REQUEST['origin']) && !empty($_REQUEST['origin'])) {
|
108
|
|
109
|
$origin = $_REQUEST['origin'];
|
110
|
|
111
|
if ($_REQUEST['origin'] == "document") {
|
112
|
|
113
|
$list_origin = "loadList('".$_SESSION['config']['businessappurl']
|
114
|
."index.php?display=true&module=notes&page=notes&identifier="
|
115
|
.$identifier."&origin=document".$parameters."', 'divList', true);";
|
116
|
} elseif ($_REQUEST['origin'] == "folder") {
|
117
|
|
118
|
|
119
|
$collId = 'folders';
|
120
|
$table = $_SESSION['tablename']['fold_folders'];
|
121
|
$list_origin = "loadList('".$_SESSION['config']['businessappurl']
|
122
|
."index.php?display=true&module=notes&page=notes&identifier="
|
123
|
.$identifier."&origin=folder".$parameters."', 'divList', true);";
|
124
|
}
|
125
|
}
|
126
|
|
127
|
|
128
|
$path_to_script = $_SESSION['config']['businessappurl']
|
129
|
."index.php?display=true&module=notes&page=notes_ajax_content&identifier="
|
130
|
.$identifier."&origin=".$origin.$parameters;
|
131
|
|
132
|
require 'modules/templates/class/templates_controler.php';
|
133
|
$templatesControler = new templates_controler();
|
134
|
$templates = array();
|
135
|
if ($destination <> '') {
|
136
|
$templates = $templatesControler->getAllTemplatesForProcess($destination);
|
137
|
} else {
|
138
|
$templates = $templatesControler->getAllTemplatesForSelect();
|
139
|
}
|
140
|
switch ($mode) {
|
141
|
case 'add':
|
142
|
if (empty($identifier)) {
|
143
|
$error = $request->wash_html(_IDENTIFIER.' '._IS_EMPTY.'!','NONE');
|
144
|
$status = 1;
|
145
|
} else {
|
146
|
$entitiesList = array();
|
147
|
$entitiesList = $ent->getAllEntities();
|
148
|
$content .= '<div class="block">';
|
149
|
$content .= '<form name="formNotes" id="formNotes" method="post" action="#">';
|
150
|
$content .= '<input type="hidden" value="'.$identifier.'" name="identifier" id="identifier">';
|
151
|
$content .= '<h2>'._ADD_NOTE.'</h2>';
|
152
|
$content .= '<label for="templateNotes">' . _NOTE_TEMPLATE .' : </label>';
|
153
|
$content .= '<select name="templateNotes" id="templateNotes" style="width:250px" '
|
154
|
. 'onchange="addTemplateToNote($(\'templateNotes\').value, \''
|
155
|
. $_SESSION['config']['businessappurl'] . 'index.php?display=true'
|
156
|
. '&module=templates&page=templates_ajax_content_for_notes\');">';
|
157
|
$content .= '<option value="">' . _SELECT_NOTE_TEMPLATE . '</option>';
|
158
|
for ($i=0;$i<count($templates);$i++) {
|
159
|
if ($templates[$i]['TYPE'] == 'TXT' && ($templates[$i]['TARGET'] == 'notes' || $templates[$i]['TARGET'] == '')) {
|
160
|
$content .= '<option value="';
|
161
|
$content .= $templates[$i]['ID'];
|
162
|
$content .= '">';
|
163
|
$content .= $templates[$i]['LABEL'];
|
164
|
}
|
165
|
$content .= '</option>';
|
166
|
}
|
167
|
$content .= '</select><br />';
|
168
|
$content .= '<textarea style="width:500px" cols="70" rows="10" name="notes" id="notes" ></textarea>';
|
169
|
$content .= '<h3 class="sstit" style="color: red">'._THIS_NOTE_IS_VISIBLE_BY.'</h3>';
|
170
|
$content .= '<table align="center" width="100%" id="template_entities">';
|
171
|
$content .= '<tr><td width="20%" align="center">';
|
172
|
$content .= '<select name="entitieslist[]" id="entitieslist" size="7" style="width: 206px" ';
|
173
|
$content .= 'ondblclick=\'moveclick($(entitieslist), $(entities_chosen));\' multiple="multiple">';
|
174
|
$entitiesForRestriction = null;
|
175
|
if ($core_tools->test_service('notes_restriction', 'notes', false)) {
|
176
|
if (!empty($_SESSION['user']['entities'])) {
|
177
|
foreach ($_SESSION['user']['entities'] as $tmpEntity) {
|
178
|
|
179
|
$entitiesForRestriction[] = $tmpEntity['ENTITY_ID'];
|
180
|
|
181
|
}
|
182
|
}
|
183
|
$entitiesForRestriction[] = $destination;
|
184
|
}
|
185
|
for ($i=0;$i<count($entitiesList);$i++) {
|
186
|
if ($entitiesForRestriction && in_array($entitiesList[$i]->entity_id, $entitiesForRestriction)) {
|
187
|
$state_entity = true;
|
188
|
} else {
|
189
|
$state_entity = false;
|
190
|
}
|
191
|
|
192
|
if ($state_entity == false) {
|
193
|
$content .= '<option value="'
|
194
|
.$entitiesList[$i]->entity_id.'" alt="'
|
195
|
.$entitiesList[$i]->short_label.'" title="'
|
196
|
.$entitiesList[$i]->short_label.'">'
|
197
|
.$entitiesList[$i]->short_label.'</option>';
|
198
|
}
|
199
|
}
|
200
|
$content .= '</select><br/> </td>';
|
201
|
$content .= '<td width="20%" align="center">';
|
202
|
$content .= '<input type="button" class="button" value="'._ADD.' >>" onclick=\'Move($(entitieslist), $(entities_chosen));\' />';
|
203
|
$content .= '<br /><br />';
|
204
|
$content .= '<input type="button" class="button" value="<< '._REMOVE.'" onclick=\'Move($(entities_chosen), $(entitieslist));\' />';
|
205
|
$content .= '</td>';
|
206
|
$content .= '<td width="30%" align="center">';
|
207
|
$content .= '<select name="entities_chosen[]" id="entities_chosen" size="7" style="width: 206px" ';
|
208
|
$content .= 'ondblclick=\'moveclick($(entities_chosen), $(entitieslist));\' multiple="multiple">';
|
209
|
for ($i=0;$i<count($entitiesList);$i++) {
|
210
|
$state_entity = false;
|
211
|
if ($state_entity == true || ($entitiesForRestriction && in_array($entitiesList[$i]->entity_id, $entitiesForRestriction))) {
|
212
|
$content .= '<option value="'
|
213
|
.$entitiesList[$i]->entity_id.'" alt="'
|
214
|
.$entitiesList[$i]->short_label.'" title="'
|
215
|
.$entitiesList[$i]->short_label.'" selected="selected">'
|
216
|
.$entitiesList[$i]->short_label.'</option>';
|
217
|
}
|
218
|
}
|
219
|
$content .= '</select></td>';
|
220
|
$content .= '</tr></table>';
|
221
|
|
222
|
$content .='<hr />';
|
223
|
$content .='<div align="center">';
|
224
|
$content .=' <input type="button" name="valid" value=" '._VALIDATE
|
225
|
.' " id="valid" class="button" onclick="'
|
226
|
.'selectall($(\'entities_chosen\'));validNotesForm(\''
|
227
|
.$path_to_script.'&mode=added\', \'formNotes\');" /> ';
|
228
|
$content .='<input type="button" name="cancel" id="cancel" class="button" value="'
|
229
|
._CANCEL.'" onclick="destroyModal(\'form_notes\');"/>';
|
230
|
$content .='</div">';
|
231
|
$content .= '</form>';
|
232
|
$content .= '</div>';
|
233
|
}
|
234
|
break;
|
235
|
case 'added':
|
236
|
if (strlen(trim($_REQUEST['notes'])) > 0) {
|
237
|
|
238
|
if (empty($identifier)) {
|
239
|
$error = $request->wash_html(_IDENTIFIER.' '._IS_EMPTY.'!','NONE');
|
240
|
$status = 1;
|
241
|
} else {
|
242
|
|
243
|
|
244
|
$notes = $_REQUEST['notes'];
|
245
|
|
246
|
$userId = $_SESSION['user']['UserId'];
|
247
|
|
248
|
$db->query(
|
249
|
"INSERT INTO " . NOTES_TABLE . "(identifier, note_text, date_note, "
|
250
|
. "user_id, coll_id, tablename) VALUES (?, ?, CURRENT_TIMESTAMP, ?, ?, ?)",
|
251
|
array($identifier, $notes, $userId, $collId, $table)
|
252
|
);
|
253
|
|
254
|
|
255
|
$id = $db->lastInsertId('notes_seq');
|
256
|
|
257
|
|
258
|
if (!empty($id) && isset($_REQUEST['entities_chosen']) && !empty($_REQUEST['entities_chosen']))
|
259
|
{
|
260
|
for ($i=0; $i<count($_REQUEST['entities_chosen']); $i++)
|
261
|
{
|
262
|
$db->query(
|
263
|
"INSERT INTO " . NOTE_ENTITIES_TABLE . "(note_id, item_id) VALUES"
|
264
|
. " (?, ?)",
|
265
|
array($id, $_REQUEST['entities_chosen'][$i])
|
266
|
);
|
267
|
}
|
268
|
}
|
269
|
|
270
|
|
271
|
if ($_SESSION['history']['noteadd']) {
|
272
|
$hist = new history();
|
273
|
|
274
|
if (isset($_REQUEST['origin']) && $_REQUEST['origin'] == "folder") {
|
275
|
if (!empty($id) && isset($_REQUEST['entities_chosen']) && !empty($_REQUEST['entities_chosen'])){
|
276
|
|
277
|
$hist->add(
|
278
|
$table, $identifier, "UP", 'folderup', _ADDITION_NOTE_PRIVATE . _ON_FOLDER_NUM
|
279
|
. $identifier . ' (' . $id . ')',
|
280
|
$_SESSION['config']['databasetype'], 'notes'
|
281
|
);
|
282
|
}else{
|
283
|
$hist->add(
|
284
|
$table, $identifier, "UP", 'folderup', _ADDITION_NOTE . _ON_FOLDER_NUM
|
285
|
. $identifier . ' (' . $id . ') : "' . $request->cut_string($notes, 254) .'"',
|
286
|
$_SESSION['config']['databasetype'], 'notes'
|
287
|
);
|
288
|
}
|
289
|
} else if (isset($_REQUEST['origin']) && $_REQUEST['origin'] == "document") {
|
290
|
if (!empty($id) && isset($_REQUEST['entities_chosen']) && !empty($_REQUEST['entities_chosen'])){
|
291
|
|
292
|
$allEntity = '';
|
293
|
foreach ($_REQUEST['entities_chosen'] as $value){
|
294
|
|
295
|
$allEntity .= $value." | ";
|
296
|
|
297
|
}
|
298
|
$hist->add(
|
299
|
$table, $identifier, "UP", 'folderup', _ADDITION_NOTE_PRIVATE . _ON_DOC_NUM
|
300
|
. $identifier . ' (' . $id . ')'._VISIBLEBY.' '.$allEntity,
|
301
|
$_SESSION['config']['databasetype'], 'notes'
|
302
|
);
|
303
|
}else{
|
304
|
$hist->add(
|
305
|
$view, $identifier, "UP", 'resup', _ADDITION_NOTE . _ON_DOC_NUM
|
306
|
. $identifier . ' (' . $id . ') : "' . $request->cut_string($notes, 254) .'"',
|
307
|
$_SESSION['config']['databasetype'], 'notes'
|
308
|
);
|
309
|
}
|
310
|
}
|
311
|
|
312
|
$hist->add(
|
313
|
NOTES_TABLE, $id, "ADD", 'noteadd', _NOTES_ADDED . ' (' . $id . ')',
|
314
|
$_SESSION['config']['databasetype'], 'notes'
|
315
|
);
|
316
|
}
|
317
|
|
318
|
|
319
|
$js = $list_origin."window.top.$('main_info').innerHTML = '"._NOTES_ADDED."';window.top.$('main_info').style.display = 'table-cell';setTimeout(function(){ window.top.$('main_info').style.display = 'none'; }, 10000);";
|
320
|
|
321
|
|
322
|
$toolbarBagde_script = $_SESSION['config']['businessappurl'] . 'index.php?display=true&module=notes&page=load_toolbar_notes&origin=parent&resId='.$identifier.'&collId='.$collId;
|
323
|
$js .='loadToolbarBadge(\'notes_tab\',\''.$toolbarBagde_script.'\');';
|
324
|
}
|
325
|
} else {
|
326
|
$error = $request->wash_html(_NOTES.' '._IS_EMPTY.'!','NONE');
|
327
|
$status = 1;
|
328
|
}
|
329
|
break;
|
330
|
case 'up':
|
331
|
if (isset($_REQUEST['id']) && !empty($_REQUEST['id'])) {
|
332
|
|
333
|
$id = $_REQUEST['id'];
|
334
|
|
335
|
$arrayPDO = array();
|
336
|
if (! empty($collId)) {
|
337
|
$where = " and coll_id = :collId";
|
338
|
$arrayPDO = array_merge($arrayPDO, array(":collId" => $collId));
|
339
|
} else {
|
340
|
$where = " and tablename = :table";
|
341
|
$arrayPDO = array_merge($arrayPDO, array(":table" => $table));
|
342
|
}
|
343
|
$arrayPDO = array_merge($arrayPDO, array(":Id" => $id));
|
344
|
$stmt = $db->query(
|
345
|
"SELECT n.identifier, n.date_note, n.user_id, n.note_text, u.lastname, "
|
346
|
. "u.firstname FROM " . NOTES_TABLE . " n inner join ". USERS_TABLE
|
347
|
. " u on n.user_id = u.user_id WHERE n.id = :Id " . $where, $arrayPDO
|
348
|
);
|
349
|
|
350
|
if($stmt->rowCount() > 0) {
|
351
|
|
352
|
$line = $stmt->fetchObject();
|
353
|
|
354
|
$user = $request->show_string($line->lastname . " " . $line->firstname);
|
355
|
$notes = $line->note_text;
|
356
|
$userId = $line->user_id;
|
357
|
$date = $line->date_note;
|
358
|
$identifier = $line->identifier;
|
359
|
|
360
|
$notesEntities = array();
|
361
|
$entitiesList = array();
|
362
|
$notesEntities = $notesTools->getNotesEntities($id);
|
363
|
$entitiesList = $ent->getAllEntities();
|
364
|
|
365
|
$content .= '<div class="block">';
|
366
|
$content .= '<form name="formNotes" id="formNotes" method="post" action="#">';
|
367
|
$content .= '<input type="hidden" value="'.$identifier.'" name="identifier" id="identifier">';
|
368
|
$content .= '<input type="hidden" value="'.$id.'" name="id" id="id">';
|
369
|
$content .= '<h2 class="sstit">'._NOTES . " " . _OF . " " . $user . " (" . $date . ")".'</h2>';
|
370
|
$content .= '<label for="templateNotes">' . _NOTE_TEMPLATE .' : </label>';
|
371
|
$content .= '<select name="templateNotes" id="templateNotes" style="width:250px" '
|
372
|
. 'onchange="addTemplateToNote($(\'templateNotes\').value, \''
|
373
|
. $_SESSION['config']['businessappurl'] . 'index.php?display=true'
|
374
|
. '&module=templates&page=templates_ajax_content_for_notes\');">';
|
375
|
$content .= '<option value="">' . _SELECT_NOTE_TEMPLATE . '</option>';
|
376
|
for ($i=0;$i<count($templates);$i++) {
|
377
|
if ($templates[$i]['TYPE'] == 'TXT' && ($templates[$i]['TARGET'] == 'notes' || $templates[$i]['TARGET'] == '')) {
|
378
|
$content .= '<option value="';
|
379
|
$content .= $templates[$i]['ID'];
|
380
|
$content .= '">';
|
381
|
$content .= $templates[$i]['LABEL'];
|
382
|
}
|
383
|
$content .= '</option>';
|
384
|
}
|
385
|
$content .= '</select><br />';
|
386
|
$content .= '<textarea style="width:500px" cols="70" rows="10" name="notes" id="notes">'.functions::xssafe($notes).'</textarea>';
|
387
|
$content .= '<h3 class="sstit" style="color: red">'._THIS_NOTE_IS_VISIBLE_BY.'</h3>';
|
388
|
$content .= '<table align="center" width="100%" id="template_entities">';
|
389
|
$content .= '<tr><td width="20%" align="center">';
|
390
|
$content .= '<select name="entitieslist[]" id="entitieslist" size="7" style="width: 206px" ';
|
391
|
$content .= 'ondblclick=\'moveclick($(entitieslist), $(entities_chosen));\' multiple="multiple">';
|
392
|
for ($i=0;$i<count($entitiesList);$i++) {
|
393
|
if (!in_array($entitiesList[$i], $notesEntities)) {
|
394
|
$content .= '<option value="'
|
395
|
.$entitiesList[$i]->entity_id.'" alt="'
|
396
|
.$entitiesList[$i]->short_label.'" title="'
|
397
|
.$entitiesList[$i]->short_label.'">'
|
398
|
.$entitiesList[$i]->short_label.'</option>';
|
399
|
}
|
400
|
}
|
401
|
$content .= '</select><br/> </td>';
|
402
|
$content .= '<td width="20%" align="center">';
|
403
|
$content .= '<input type="button" class="button" value="'._ADD.' >>" onclick=\'Move($(entitieslist), $(entities_chosen));\' />';
|
404
|
$content .= '<br /><br />';
|
405
|
$content .= '<input type="button" class="button" value="<< '._REMOVE.'" onclick=\'Move($(entities_chosen), $(entitieslist));\' />';
|
406
|
$content .= '</td>';
|
407
|
$content .= '<td width="30%" align="center">';
|
408
|
$content .= '<select name="entities_chosen[]" id="entities_chosen" size="7" style="width: 206px" ';
|
409
|
$content .= 'ondblclick=\'moveclick($(entities_chosen), $(entitieslist));\' multiple="multiple">';
|
410
|
for ($i=0;$i<count($notesEntities);$i++) {
|
411
|
$content .= '<option value="'
|
412
|
.$notesEntities[$i]->entity_id.'" alt="'
|
413
|
.$notesEntities[$i]->short_label.'" title="'
|
414
|
.$notesEntities[$i]->short_label.'" selected="selected">'
|
415
|
.$notesEntities[$i]->short_label.'</option>';
|
416
|
}
|
417
|
$content .= '</select></td>';
|
418
|
$content .= '</tr></table>';
|
419
|
|
420
|
$content .='<hr />';
|
421
|
$content .='<div align="center">';
|
422
|
$content .=' <input type="button" name="valid" value=" '._VALIDATE
|
423
|
.' " id="valid" class="button" onclick="'
|
424
|
.'selectall($(\'entities_chosen\'));validNotesForm(\''
|
425
|
.$path_to_script.'&mode=updated\', \'formNotes\');" /> ';
|
426
|
$content .=' <input type="button" name="valid" value=" '._DELETE
|
427
|
.' " id="valid" class="button" onclick="if(confirm(\''._REALLY_DELETE.': '
|
428
|
.$request->cut_string(str_replace(array("'", "\n","\"","\r"),array("\'", " ", """, " "), $notes), 250).' ?\')) validNotesForm(\''
|
429
|
.$path_to_script.'&mode=del\', \'formNotes\');" /> ';
|
430
|
$content .='<input type="button" name="cancel" id="cancel" class="button" value="'
|
431
|
._CANCEL.'" onclick="destroyModal(\'form_notes\');"/>';
|
432
|
$content .='</div">';
|
433
|
$content .= '</form>';
|
434
|
$content .= '</div>';
|
435
|
} else {
|
436
|
$error = $request->wash_html($id.': '._NOTE_DONT_EXIST.'!','NONE');
|
437
|
$status = 1;
|
438
|
}
|
439
|
|
440
|
} else {
|
441
|
$error = $request->wash_html(_ID.' '._IS_EMPTY.'!','NONE');
|
442
|
$status = 1;
|
443
|
}
|
444
|
break;
|
445
|
case 'updated':
|
446
|
if (strlen(trim($_REQUEST['notes'])) > 0) {
|
447
|
|
448
|
if (empty($_REQUEST['id'])) {
|
449
|
$error = $request->wash_html(_ID.' '._IS_EMPTY.'!','NONE');
|
450
|
$status = 1;
|
451
|
} else {
|
452
|
$id = $_REQUEST['id'];
|
453
|
|
454
|
if (empty($identifier)) {
|
455
|
$error = $request->wash_html(_IDENTIFIER.' '._IS_EMPTY.'!','NONE');
|
456
|
$status = 1;
|
457
|
} else {
|
458
|
|
459
|
$notes = $_REQUEST['notes'];
|
460
|
|
461
|
$db->query(
|
462
|
"UPDATE ".NOTES_TABLE." SET note_text = ?, date_note = CURRENT_TIMESTAMP WHERE id = ?",
|
463
|
array($notes, $id)
|
464
|
);
|
465
|
|
466
|
|
467
|
$db->query(
|
468
|
"DELETE FROM " . NOTE_ENTITIES_TABLE . " WHERE note_id = ?", array($id)
|
469
|
);
|
470
|
if (isset($_REQUEST['entities_chosen']) && !empty($_REQUEST['entities_chosen'])) {
|
471
|
|
472
|
for ($i=0; $i<count($_REQUEST['entities_chosen']); $i++)
|
473
|
{
|
474
|
$db->query(
|
475
|
"INSERT INTO " . NOTE_ENTITIES_TABLE . "(note_id, item_id) VALUES"
|
476
|
. " (?, ?)",
|
477
|
array($id, $_REQUEST['entities_chosen'][$i])
|
478
|
);
|
479
|
}
|
480
|
}
|
481
|
|
482
|
|
483
|
if ($_SESSION['history']['noteup']) {
|
484
|
$hist = new history();
|
485
|
if (isset($_REQUEST['origin']) && $_REQUEST['origin'] == "folder") {
|
486
|
$hist->add(
|
487
|
$table, $identifier, "UP", 'folderup', _NOTE_UPDATED . _ON_FOLDER_NUM
|
488
|
. $identifier . ' (' . $id . ') : "' . $request->cut_string($notes, 254) .'"',
|
489
|
$_SESSION['config']['databasetype'], 'notes'
|
490
|
);
|
491
|
} else if (isset($_REQUEST['origin']) && $_REQUEST['origin'] == "document") {
|
492
|
$hist->add(
|
493
|
$view, $identifier, "UP", 'resup', _NOTE_UPDATED . _ON_DOC_NUM
|
494
|
. $identifier . ' (' . $id . ') ',
|
495
|
$_SESSION['config']['databasetype'], 'notes'
|
496
|
);
|
497
|
}
|
498
|
|
499
|
$hist->add(
|
500
|
NOTES_TABLE, $id, "UP", 'noteup', _NOTE_UPDATED . ' (' . $id . ')',
|
501
|
$_SESSION['config']['databasetype'], 'notes'
|
502
|
);
|
503
|
}
|
504
|
|
505
|
|
506
|
$js = $list_origin."window.top.$('main_info').innerHTML = '"._NOTE_UPDATED."';window.top.$('main_info').style.display = 'table-cell';setTimeout(function(){ window.top.$('main_info').style.display = 'none'; }, 10000);";
|
507
|
}
|
508
|
}
|
509
|
} else {
|
510
|
$error = $request->wash_html(_NOTES.' '._IS_EMPTY.'!','NONE');
|
511
|
$status = 1;
|
512
|
}
|
513
|
break;
|
514
|
case 'del':
|
515
|
|
516
|
if (empty($_REQUEST['id'])) {
|
517
|
$error = $request->wash_html(_ID.' '._IS_EMPTY.'!','NONE');
|
518
|
$status = 1;
|
519
|
} else {
|
520
|
$id = $_REQUEST['id'];
|
521
|
|
522
|
$db->query("DELETE FROM " . NOTE_ENTITIES_TABLE . " WHERE note_id = ?", array($id));
|
523
|
$db->query("DELETE FROM " . NOTES_TABLE . " WHERE id = ?", array($id));
|
524
|
|
525
|
if ($_SESSION['history']['notedel']) {
|
526
|
$hist = new history();
|
527
|
$hist->add(
|
528
|
NOTES_TABLE, $id, "DEL", 'notedel', _NOTES_DELETED . ' (' . $id . ')',
|
529
|
$_SESSION['config']['databasetype'], 'notes'
|
530
|
);
|
531
|
if (isset($_REQUEST['origin']) && $_REQUEST['origin'] == "folder") {
|
532
|
$hist->add(
|
533
|
$table, $identifier, "UP", 'folderup', _NOTES_DELETED . _ON_FOLDER_NUM
|
534
|
. $identifier . ' (' . $id . ')',
|
535
|
$_SESSION['config']['databasetype'], 'notes'
|
536
|
);
|
537
|
} else if (isset($_REQUEST['origin']) && $_REQUEST['origin'] == "document") {
|
538
|
$hist->add(
|
539
|
$view, $identifier, "UP", 'resup', _NOTES_DELETED . _ON_DOC_NUM
|
540
|
. $identifier . ' (' . $id . ')',
|
541
|
$_SESSION['config']['databasetype'], 'notes'
|
542
|
);
|
543
|
}
|
544
|
}
|
545
|
|
546
|
|
547
|
$js = $list_origin."window.top.$('main_info').innerHTML = '"._NOTES_DELETED."';window.top.$('main_info').style.display = 'table-cell';setTimeout(function(){ window.top.$('main_info').style.display = 'none'; }, 10000);";
|
548
|
|
549
|
|
550
|
$toolbarBagde_script = $_SESSION['config']['businessappurl'] . 'index.php?display=true&module=notes&page=load_toolbar_notes&origin=parent&resId='.$identifier.'&collId='.$collId;
|
551
|
$js .='loadToolbarBadge(\'notes_tab\',\''.$toolbarBagde_script.'\');';
|
552
|
}
|
553
|
break;
|
554
|
}
|
555
|
|
556
|
echo "{status : " . $status . ", content : '" . addslashes(_parse($content)) . "', error : '" . addslashes($error) . "', exec_js : '".addslashes($js)."'}";
|
557
|
exit ();
|
558
|
?>
|
559
|
|