-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
notes.php
215 lines (171 loc) · 8.03 KB
/
notes.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
<?php
/* Copyright (C) 2001-2003,2005 Rodolphe Quiedeville <[email protected]>
* Copyright (C) 2004-2013 Laurent Destailleur <[email protected]>
* Copyright (C) 2005-2012 Regis Houssin <[email protected]>
* Copyright (C) 2010 Juanjo Menent <[email protected]>
*
* 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 3 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, see <http:https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/cabinetmed/notes.php
* \brief Tab for notes on third party
* \ingroup societe
*/
// Load Dolibarr environment
$res=0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME
$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1;
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; }
if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php";
if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php";
// Try main.inc.php using relative path
if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php";
if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php";
if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php";
if (! $res) die("Include of main fails");
include_once DOL_DOCUMENT_ROOT."/core/lib/company.lib.php";
include_once "./class/patient.class.php";
include_once "./lib/cabinetmed.lib.php";
$langs->load("companies");
$langs->load("cabinetmed@cabinetmed");
$action = GETPOST('action', 'aZ09');
$langs->load("companies");
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('thirdpartycard','globalcard'));
// Security check
$socid = GETPOST('socid', 'int');
if ($user->socid) $socid=$user->socid;
$result = restrictedArea($user, 'societe', $socid, '&societe');
$object = new Patient($db);
if ($socid > 0) $object->fetch($socid);
/*
* Actions
*/
$parameters=array('id'=>$socid);
$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) {
if ($action == 'add' && ! GETPOST('cancel', 'alpha')) {
$error=0;
$db->begin();
$result=$object->update_note(dol_html_entity_decode(dol_htmlcleanlastbr(GETPOST('note_private', 'none')?GETPOST('note_private', 'none'):GETPOST('note', 'none')), ENT_QUOTES), '_private');
if ($result < 0) {
$error++;
$errors[]=$object->errors;
}
$alert_note = (GETPOST("alert_note") ? '1' : '0');
$result=addAlert($db, 'alert_note', $socid, $alert_note);
if ($result == '') {
$object->alert_note = $alert_note;
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null);
} else {
$error++;
setEventMessages($result, null, 'errors');
}
if (! $error) $db->commit();
else $db->rollback();
}
}
/*
* View
*/
if (getDolGlobalString('MAIN_DIRECTEDITMODE') && $user->hasRight('societe', 'creer')) {
$action='edit';
}
$form = new Form($db);
$help_url = '';
llxHeader('', $langs->trans("Patient").' - '.$langs->trans("Notes"), $help_url);
if ($socid > 0) {
/*
* Affichage onglets
*/
if (isModEnabled("notification")) $langs->load("mails");
$head = societe_prepare_head($object);
if ((float) DOL_VERSION < 7) dol_fiche_head($head, 'tabnotes', $langs->trans("Patient"), 0, 'patient@cabinetmed');
elseif ((float) DOL_VERSION < 15) dol_fiche_head($head, 'tabnotes', $langs->trans("Patient"), -1, 'patient@cabinetmed');
else dol_fiche_head($head, 'tabnotes', $langs->trans("Patient"), -1, 'user-injured');
print '<script type="text/javascript">
var changed=false;
jQuery(function() {
jQuery(window).bind(\'beforeunload\', function(){
/* alert(changed); */
console.log(changed);
if (changed) return \''.dol_escape_js($langs->transnoentitiesnoconv("WarningExitPageWithoutSaving")).'\';
});
jQuery(".flat").keydown(function (e) {
console.log("aa");
changed=true;
});
jQuery("#alert_note").change(function () {
console.log("bb");
changed=true;
});
jQuery(".ignorechange").click(function () {
changed=false;
});
});
</script>';
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
$linkback = '<a href="'.dol_buildpath('/cabinetmed/patients.php', 1).'">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom');
print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">';
if (! empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
}
if ($object->client) {
print '<tr><td class="titlefield">';
print $langs->trans('CustomerCode').'</td><td colspan="3">';
print $object->code_client;
if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
print '</td></tr>';
}
if ($object->fournisseur) {
print '<tr><td class="titlefield">';
print $langs->trans('SupplierCode').'</td><td colspan="3">';
print $object->code_fournisseur;
if ($object->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
print '</td></tr>';
}
print '<tr><td class="tdtop titlefield">'.$langs->trans("NotePrivate");
print '<br><input type="checkbox" id="alert_note" name="alert_note"'.((isset($_POST['alert_note'])?GETPOST('alert_note'):$object->alert_note)?' checked="checked"':'').'"> <label for="alert_note">'.$langs->trans("Alert").'</label>';
print '</td>';
print '<td class="tdtop">';
$note = GETPOSTISSET('note') ? GETPOST('note') : ($object->note_private?$object->note_private:$object->note);
if ($user->hasRight('societe', 'creer')) {
print '<input type="hidden" name="action" value="add" />';
print '<input type="hidden" name="socid" value="'.$object->id.'" />';
// Editeur wysiwyg
require_once DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php";
$doleditor=new DolEditor('note', $note, '', 360, 'dolibarr_notes', 'In', true, false, isModEnabled('fckeditor') && getDolGlobalInt('FCKEDITOR_ENABLE_SOCIETE') ? true : false, 20, '90%');
$doleditor->Create(0, '.on( \'key\', function(e) { console.log("changed"); changed=true; }) '); // Add on to detect changes with key pressed
print '<br>';
} else {
print dol_textishtml($note)?$note:dol_nl2br($note, 1, true);
}
print "</td></tr>";
print "</table>";
if ($user->hasRight('societe', 'creer')) {
print '<center><br>';
print '<input type="submit" class="button ignorechange" name="save" value="'.$langs->trans("Save").'">';
print '</center>';
}
print '</form>';
dol_fiche_end();
}
llxFooter();
$db->close();