dolibarr 21.0.0-alpha
virtualcard.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004-2023 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2005-2015 Regis Houssin <regis.houssin@inodbox.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
25// Load Dolibarr environment
26require '../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
28require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
31
32// Load translation files required by page
33$langs->loadLangs(array("users", "companies", "admin", "website"));
34
35// Security check
36$id = GETPOSTINT('id');
37$ref = GETPOST('ref', 'alpha');
38$action = GETPOST('action', 'aZ09');
39$dol_openinpopup = GETPOST('dol_openinpopup', 'aZ09');
40
41if (empty($id) && empty($ref)) {
42 $id = $user->id;
43}
44
45$expand = $_COOKIE['virtualcard_expand'];
46
47$object = new User($db);
48if ($id > 0 || !empty($ref)) {
49 $result = $object->fetch($id, $ref, '', 1);
50 $object->loadRights();
51}
52
53// Security check
54$socid = 0;
55if ($user->socid > 0) {
56 $socid = $user->socid;
57}
58$feature2 = (($socid && $user->hasRight('user', 'self', 'creer')) ? '' : 'user');
59
60$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
61
62// If user is not the user that read and has no permission to read other users, we stop
63if (($object->id != $user->id) && !$user->hasRight('user', 'user', 'lire')) {
65}
66
67$permissiontoedit = ((($object->id == $user->id) && $user->hasRight('user', 'self', 'creer')) || $user->hasRight('user', 'user', 'creer'));
68
69
70/*
71 * Actions
72 */
73
74if ($action == 'update' && $permissiontoedit) {
75 $tmparray = array();
76 $tmparray['USER_PUBLIC_MORE'] = GETPOST('USER_PUBLIC_MORE', 'alphanohtml');
77
78 dol_set_user_param($db, $conf, $object, array('USER_PUBLIC_MORE' => $tmparray['USER_PUBLIC_MORE']));
79}
80
81if ($action == 'setUSER_ENABLE_PUBLIC' && $permissiontoedit) {
82 if (GETPOST('value')) {
83 $tmparray = array('USER_ENABLE_PUBLIC' => 1);
84 } else {
85 $tmparray = array('USER_ENABLE_PUBLIC' => 0);
86 }
87 dol_set_user_param($db, $conf, $object, $tmparray);
88}
89
90
91/*
92 * View
93 */
94
95$form = new Form($db);
96
97$person_name = !empty($object->firstname) ? $object->lastname.", ".$object->firstname : $object->lastname;
98$title = $person_name." - ".$langs->trans('Info');
99$help_url = '';
100
101llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-user page-virtualcard');
102
103
104$title = $langs->trans("User");
105//print dol_get_fiche_head($head, 'info', $title, -1, 'user');
106
107
108print '<div class="fichecenter">';
109
110print '<br>';
111
112$param = '&id='.((int) $object->id);
113if (GETPOSTISSET('dol_openinpopup')) {
114 $param .= '&dol_openinpopup='.urlencode(GETPOST('dol_openinpopup', 'aZ09'));
115}
116
117$enabledisablehtml = $langs->trans("EnablePublicVirtualCard").' ';
118if (!getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) {
119 // Button off, click to enable
120 $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setUSER_ENABLE_PUBLIC&token='.newToken().'&value=1'.$param.'">';
121 $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
122 $enabledisablehtml .= '</a>';
123
124 $enabledisablehtml .= '<br><br><span class="opacitymedium">'.$langs->trans("UserPublicPageDesc").'</span><br><br>';
125} else {
126 // Button on, click to disable
127 $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setUSER_ENABLE_PUBLIC&token='.newToken().'&value=0'.$param.'">';
128 $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
129 $enabledisablehtml .= '</a>';
130}
131print $enabledisablehtml;
132print '<input type="hidden" id="USER_ENABLE_PUBLIC" name="USER_ENABLE_PUBLIC" value="'.(getDolGlobalString('USER_ENABLE_PUBLIC') ? 1 : 0).'">';
133
134print '<br><br>';
135
136print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
137
138if (getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) {
139 print '<input type="hidden" name="action" value="update">';
140 print '<input type="hidden" name="id" value="'.$object->id.'">';
141 print '<input type="hidden" name="token" value="'.newToken().'">';
142
143 //print $langs->trans('FollowingLinksArePublic').'<br>';
144 print img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans('PublicVirtualCardUrl').'</span><br>';
145
146 $fullexternaleurltovirtualcard = $object->getOnlineVirtualCardUrl('', 'external');
147 $fullinternalurltovirtualcard = $object->getOnlineVirtualCardUrl('', 'internal');
148
149 $showUserSocialNetworks = !getDolUserString('USER_PUBLIC_HIDE_SOCIALNETWORKS', '', $object);
150 $showSocieteSocialNetworks = !getDolUserString('USER_PUBLIC_HIDE_SOCIALNETWORKS_BUSINESS', '', $object);
151
152 print '<div class="urllink">';
153 print '<input type="text" id="publicurluser" class="quatrevingtpercentminusx" value="'.$fullexternaleurltovirtualcard.'">';
154 print '<a target="_blank" rel="noopener noreferrer" href="'.$fullexternaleurltovirtualcard.'">'.img_picto('', 'globe', 'class="paddingleft marginrightonly paddingright"').$langs->trans("GoTo").'...</a>';
155 print '</div>';
156 print ajax_autoselect('publicurluser');
157
158 print '<br>';
159 print '<br>';
160
161 // Show/Hide options
162 print '<div class="centpercent margintoponly marginbottomonly">';
163 print img_picto('', 'setup', 'class="pictofixedwidth"').'<a id="lnk" href="#">'.$langs->trans("ShowAdvancedOptions").'...</a>';
164 print '</div>';
165
166 print '<script type="text/javascript">
167 jQuery(document).ready(function() {
168 jQuery("#lnk").click(function(event) {
169 event.preventDefault();
170 console.log("We click on link to show virtual card options");
171 hideoptions(this);
172 });
173 });
174
175 function hideoptions(domelem) {
176 const div = document.getElementById("div_container_sub_exportoptions");
177
178 if (div.style.display === "none") {
179 div.style.display = "block";
180 domelem.innerText="'.dol_escape_js($langs->transnoentitiesnoconv("HideAdvancedoptions")).'";
181 var date = new Date();
182 date.setTime(date.getTime() + (1 * 24 * 60 * 60 * 1000));
183 document.cookie = "virtualcard_expand=1; expires=" + date.toUTCString() + "; path=/";
184 } else {
185 div.style.display = "none";
186 domelem.innerText="'.dol_escape_js($langs->transnoentitiesnoconv("ShowAdvancedOptions")).'...";
187 var date = new Date();
188 date.setTime(date.getTime() - (1 * 24 * 60 * 60 * 1000));
189 document.cookie = "virtualcard_expand=0; expires=" + date.toUTCString() + "; path=/";
190 }
191 }
192 </script>';
193
194 // Start div hide/Show
195 print '<div id="div_container_sub_exportoptions" style="'.($expand ? '' : 'display: none;').'">';
196
197 print '<div class="div-table-responsive-no-min">';
198 print '<table class="noborder centpercent">';
199
200 print '<tr class="liste_titre">';
201 print '<td>'.$langs->trans("User").'</td>';
202 print '<td></td>';
203 print "</tr>\n";
204
205 // User photo
206 print '<tr class="oddeven" id="tredit"><td>';
207 print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Photo"));
208 print '</td><td>';
209 print ajax_constantonoff("USER_PUBLIC_HIDE_PHOTO", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object->id);
210 print "</td></tr>\n";
211
212 // Job position
213 print '<tr class="oddeven" id="tredit"><td>';
214 print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("PostOrFunction"));
215 print '</td><td>';
216 print ajax_constantonoff("USER_PUBLIC_HIDE_JOBPOSITION", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object->id);
217 print "</td></tr>\n";
218
219 // Email
220 print '<tr class="oddeven" id="tredit"><td>';
221 print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Email"));
222 print '</td><td>';
223 print ajax_constantonoff("USER_PUBLIC_HIDE_EMAIL", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object->id);
224 print "</td></tr>\n";
225
226 // Office phone
227 print '<tr class="oddeven" id="tredit"><td>';
228 print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("PhonePro"));
229 print '</td><td>';
230 print ajax_constantonoff("USER_PUBLIC_HIDE_OFFICE_PHONE", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object->id);
231 print "</td></tr>\n";
232
233 // Office fax
234 print '<tr class="oddeven" id="tredit"><td>';
235 print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Fax"));
236 print '</td><td>';
237 print ajax_constantonoff("USER_PUBLIC_HIDE_OFFICE_FAX", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object->id);
238 print "</td></tr>\n";
239
240 // User mobile
241 print '<tr class="oddeven" id="tredit"><td>';
242 print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("PhoneMobile"));
243 print '</td><td>';
244 print ajax_constantonoff("USER_PUBLIC_HIDE_USER_MOBILE", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object->id);
245 print "</td></tr>\n";
246
247 // Social networks
248 print '<tr class="oddeven" id="tredit"><td>';
249 print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("SocialNetworksInformation"));
250 print '</td><td>';
251 print ajax_constantonoff("USER_PUBLIC_HIDE_SOCIALNETWORKS", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object->id);
252 print "</td></tr>\n";
253
254 // Show list of socialnetworks for user
255 if ($showUserSocialNetworks) {
256 $socialnetworks = $object->socialnetworks;
257
258 if (!empty($socialnetworks)) {
259 foreach ($socialnetworks as $key => $networkVal) {
260 print '<tr class="oddeven">';
261 print '<td> &nbsp; &nbsp; '.$langs->trans("Hide").' '.dol_escape_htmltag($key).'</td><td>';
262 print ajax_constantonoff('USER_SOCIALNETWORK_'.strtoupper($key), array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object->id);
263 print '</td>';
264 print "</tr>";
265 }
266 }
267 }
268
269 // Birth date
270 print '<tr class="oddeven" id="tredit"><td>';
271 print $langs->trans("ShowOnVCard", $langs->transnoentitiesnoconv("Birthdate"));
272 print '</td><td>';
273 print ajax_constantonoff("USER_PUBLIC_SHOW_BIRTH", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object->id);
274 print "</td></tr>\n";
275
276 // Address
277 print '<tr class="oddeven" id="tredit"><td>';
278 print $langs->trans("ShowOnVCard", $langs->transnoentitiesnoconv("Address"));
279 print '</td><td>';
280 print ajax_constantonoff("USER_PUBLIC_SHOW_ADDRESS", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object->id);
281 print "</td></tr>\n";
282
283 print '<tr class="liste_titre">';
284 print '<td>'.$langs->trans("Company").'</td>';
285 print '<td></td>';
286 print "</tr>\n";
287
288 // Company section
289 print '<tr class="oddeven" id="tramount"><td>';
290 print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("CompanySection"));
291 print '</td><td>';
292 print ajax_constantonoff("USER_PUBLIC_HIDE_COMPANY", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object->id);
293 print "</td></tr>\n";
294
295 if (!getDolUserString('USER_PUBLIC_HIDE_COMPANY', '', $object)) {
296 // Social networks
297 print '<tr class="oddeven" id="tredit"><td>';
298 print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("SocialNetworksInformation"));
299 print '</td><td>';
300 print ajax_constantonoff("USER_PUBLIC_HIDE_SOCIALNETWORKS_BUSINESS", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object->id);
301 print "</td></tr>\n";
302
303 // show list of social networks for company
304 if ($showSocieteSocialNetworks) {
305 $listofnetworks = $mysoc->socialnetworks;
306
307 if (!empty($listofnetworks)) {
308 foreach ($listofnetworks as $key => $networkVal) {
309 print '<tr class="oddeven">';
310 print '<td> &nbsp; &nbsp; '.$langs->trans("Hide").' '.dol_escape_htmltag($key).'</td><td>';
311 print ajax_constantonoff('SOCIETE_PUBLIC_SOCIALNETWORKS_'.strtoupper($key), array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object->id);
312 print '</td>';
313 print "</tr>";
314 }
315 }
316 }
317 }
318
319 print '<tr class="liste_titre">';
320 print '<td>'.$langs->trans("Other").'</td>';
321 print '<td></td>';
322 print "</tr>\n";
323
324 // More
325 print '<tr class="oddeven" id="tredit"><td>';
326 print $langs->trans("Text");
327 print '</td><td>';
328 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
329 $extendededitor = 0; // We force no WYSIWYG editor
330 $doleditor = new DolEditor('USER_PUBLIC_MORE', getDolUserString('USER_PUBLIC_MORE', '', $object), '', 160, 'dolibarr_notes', '', false, false, $extendededitor, ROWS_5, '90%');
331 $doleditor->Create();
332 print "</td></tr>\n";
333
334 print '</table>';
335 print '</div>';
336
337 print '<div class="center">';
338 print $form->buttonsSaveCancel("Save", '', array(), 0, '', $dol_openinpopup);
339 print '</div>';
340
341 print '<br>';
342
343 print '</div>'; // End hide/show
344
345 print '<br>';
346
347 // Preview
348 print '<div class="center">';
349 print '<span class="opacitymedium">'.$langs->trans("Preview").'</span><br>';
350 print '<div class="virtualcard-div">';
351 print '<a target="_blank" rel="noopener noreferrer cursorpointer" href="'.$fullexternaleurltovirtualcard.'">'."\n";
352 print '<iframe id="virtualcard-iframe" title="" class="center" src="'.$fullinternalurltovirtualcard.'&mode=preview">';
353 print '</iframe>';
354 print '</a>';
355 print '</div>';
356 print '</div>';
357
358 print '<br>';
359}
360
361
362print '</form>';
363
364print '</div>';
365
366
367// End of page
368llxFooter();
369$db->close();
$id
Definition account.php:39
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:70
Class to manage a WYSIWYG editor.
Class to manage generation of HTML components Only common components must be here.
Class to manage Dolibarr users.
llxFooter()
Footer empty.
Definition document.php:107
dol_set_user_param($db, $conf, &$user, $tab)
Save personal parameter.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
getDolUserInt($key, $default=0, $tmpuser=null)
Return Dolibarr user constant int value.
getDolUserString($key, $default='', $tmpuser=null)
Return Dolibarr user constant string value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.