dolibarr 25.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 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2026 MDW <mdeweerd@users.noreply.github.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27// Load Dolibarr environment
28require '../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
33
43// Load translation files required by page
44$langs->loadLangs(array("users", "companies", "admin", "website"));
45
46// Security check
47$id = GETPOSTINT('id');
48$ref = GETPOST('ref', 'alpha');
49$action = GETPOST('action', 'aZ09');
50$dol_openinpopup = GETPOST('dol_openinpopup', 'aZ09');
51
52if (empty($id) && empty($ref)) {
53 $id = $user->id;
54}
55
56$expand = empty($_COOKIE['virtualcard_expand']) ? '' : $_COOKIE['virtualcard_expand'];
57
58$object = new User($db);
59if ($id > 0 || !empty($ref)) {
60 $result = $object->fetch($id, $ref, '', 1);
61 $object->loadRights();
62}
63
64// Security check
65$socid = 0;
66if ($user->socid > 0) {
67 $socid = $user->socid;
68}
69$feature2 = (($socid && $user->hasRight('user', 'self', 'creer')) ? '' : 'user');
70
71$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
72
73// If user is not the user that read and has no permission to read other users, we stop
74if (($object->id != $user->id) && !$user->hasRight('user', 'user', 'lire')) {
76}
77
78$permissiontoedit = ((($object->id == $user->id) && $user->hasRight('user', 'self', 'creer')) || $user->hasRight('user', 'user', 'creer'));
79
80
81/*
82 * Actions
83 */
84
85if ($action == 'update' && $permissiontoedit) {
86 $tmparray = array();
87 $tmparray['USER_PUBLIC_MORE'] = GETPOST('USER_PUBLIC_MORE', 'alphanohtml');
88
89 dol_set_user_param($db, $conf, $object, array('USER_PUBLIC_MORE' => $tmparray['USER_PUBLIC_MORE']));
90}
91
92if ($action == 'setUSER_ENABLE_PUBLIC' && $permissiontoedit) {
93 if (GETPOST('value')) {
94 $tmparray = array('USER_ENABLE_PUBLIC' => 1);
95 } else {
96 $tmparray = array('USER_ENABLE_PUBLIC' => 0);
97 }
98 dol_set_user_param($db, $conf, $object, $tmparray);
99}
100
101
102/*
103 * View
104 */
105
106$form = new Form($db);
107
108$person_name = !empty($object->firstname) ? $object->lastname.", ".$object->firstname : $object->lastname;
109$title = $person_name." - ".$langs->trans('Info');
110$help_url = '';
111
112llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-user page-virtualcard');
113
114
115$title = $langs->trans("User");
116//print dol_get_fiche_head($head, 'info', $title, -1, 'user');
117
118
119print '<div class="fichecenter">';
120
121print '<br>';
122
123$param = '&id='.((int) $object->id);
124if (GETPOSTISSET('dol_openinpopup')) {
125 $param .= '&dol_openinpopup='.urlencode(GETPOST('dol_openinpopup', 'aZ09'));
126}
127
128$enabledisablehtml = $langs->trans("EnablePublicVirtualCard").' ';
129if (!getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) {
130 // Button off, click to enable
131 $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setUSER_ENABLE_PUBLIC&token='.newToken().'&value=1'.$param.'">';
132 $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
133 $enabledisablehtml .= '</a>';
134
135 $enabledisablehtml .= '<br><br><div class="opacitymedium justify">'.$langs->trans("UserPublicPageDesc").'</div>';
136} else {
137 // Button on, click to disable
138 $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setUSER_ENABLE_PUBLIC&token='.newToken().'&value=0'.$param.'">';
139 $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
140 $enabledisablehtml .= '</a>';
141}
142print $enabledisablehtml;
143print '<input type="hidden" id="USER_ENABLE_PUBLIC" name="USER_ENABLE_PUBLIC" value="'.(getDolUserInt('USER_ENABLE_PUBLIC') ? 1 : 0).'">';
144
145
146print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
147
148if (getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) {
149 print '<br><br>';
150
151 print '<input type="hidden" name="action" value="update">';
152 print '<input type="hidden" name="id" value="'.$object->id.'">';
153 print '<input type="hidden" name="token" value="'.newToken().'">';
154
155 //print $langs->trans('FollowingLinksArePublic').'<br>';
156 print img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans('PublicVirtualCardUrl').'</span><br>';
157
158 $fullexternaleurltovirtualcard = $object->getOnlineVirtualCardUrl('', 'external');
159 $fullinternalurltovirtualcard = $object->getOnlineVirtualCardUrl('', 'internal');
160
161 $showUserSocialNetworks = !getDolUserString('USER_PUBLIC_HIDE_SOCIALNETWORKS', '', $object);
162 $showSocieteSocialNetworks = !getDolUserString('USER_PUBLIC_HIDE_SOCIALNETWORKS_BUSINESS', '', $object);
163
164 print '<div class="urllink">';
165 print '<input type="text" id="publicurluser" class="quatrevingtpercentminusx" value="'.$fullexternaleurltovirtualcard.'">';
166 print '<a target="_blank" rel="noopener noreferrer" href="'.$fullexternaleurltovirtualcard.'">'.img_picto('', 'globe', 'class="paddingleft marginrightonly paddingright"').$langs->trans("GoTo").'...</a>';
167 print '</div>';
168 print ajax_autoselect('publicurluser');
169
170 print '<br>';
171 print '<br>';
172
173 // Show/Hide options
174 print '<div class="centpercent margintoponly marginbottomonly">';
175 print img_picto('', 'setup', 'class="pictofixedwidth"').'<a id="lnk" href="#">'.$langs->trans("ShowAdvancedOptions").'...</a>';
176 print '</div>';
177
178 print '<script type="text/javascript">
179 jQuery(document).ready(function() {
180 jQuery("#lnk").click(function(event) {
181 event.preventDefault();
182 console.log("We click on link to show virtual card options");
183 hideoptions(this);
184 });
185 });
186
187 function hideoptions(domelem) {
188 const div = document.getElementById("div_container_sub_exportoptions");
189
190 if (div.style.display === "none") {
191 div.style.display = "block";
192 domelem.innerText=\''.dol_escape_js($langs->transnoentitiesnoconv("HideAdvancedoptions")).'\';
193 var date = new Date();
194 date.setTime(date.getTime() + (1 * 24 * 60 * 60 * 1000));
195 document.cookie = "virtualcard_expand=1; expires=" + date.toUTCString() + "; path=/";
196 } else {
197 div.style.display = "none";
198 domelem.innerText=\''.dol_escape_js($langs->transnoentitiesnoconv("ShowAdvancedOptions")).'...\';
199 var date = new Date();
200 date.setTime(date.getTime() - (1 * 24 * 60 * 60 * 1000));
201 document.cookie = "virtualcard_expand=0; expires=" + date.toUTCString() + "; path=/";
202 }
203 }
204 </script>';
205
206 // Start div hide/Show
207 print '<div id="div_container_sub_exportoptions" style="'.($expand ? '' : 'display: none;').'">';
208
209 print '<div class="div-table-responsive-no-min">';
210 print '<table class="noborder centpercent">';
211
212 print '<tr class="liste_titre">';
213 print '<td>'.$langs->trans("User").'</td>';
214 print '<td></td>';
215 print "</tr>\n";
216
217 // User photo
218 print '<tr class="oddeven" id="tredit"><td>';
219 print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Photo"));
220 print '</td><td>';
221 print ajax_constantonoff("USER_PUBLIC_HIDE_PHOTO", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object);
222 print "</td></tr>\n";
223
224 // Job position
225 print '<tr class="oddeven" id="tredit"><td>';
226 print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("PostOrFunction"));
227 print '</td><td>';
228 print ajax_constantonoff("USER_PUBLIC_HIDE_JOBPOSITION", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object);
229 print "</td></tr>\n";
230
231 // Email
232 print '<tr class="oddeven" id="tredit"><td>';
233 print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Email"));
234 print '</td><td>';
235 print ajax_constantonoff("USER_PUBLIC_HIDE_EMAIL", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object);
236 print "</td></tr>\n";
237
238 // Office phone
239 print '<tr class="oddeven" id="tredit"><td>';
240 print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("PhonePro"));
241 print '</td><td>';
242 print ajax_constantonoff("USER_PUBLIC_HIDE_OFFICE_PHONE", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object);
243 print "</td></tr>\n";
244
245 // Office fax
246 print '<tr class="oddeven" id="tredit"><td>';
247 print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Fax"));
248 print '</td><td>';
249 print ajax_constantonoff("USER_PUBLIC_HIDE_OFFICE_FAX", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object);
250 print "</td></tr>\n";
251
252 // User mobile
253 print '<tr class="oddeven" id="tredit"><td>';
254 print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("PhoneMobile"));
255 print '</td><td>';
256 print ajax_constantonoff("USER_PUBLIC_HIDE_USER_MOBILE", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object);
257 print "</td></tr>\n";
258
259 // Social networks
260 print '<tr class="oddeven" id="tredit"><td>';
261 print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("SocialNetworksInformation"));
262 print '</td><td>';
263 print ajax_constantonoff("USER_PUBLIC_HIDE_SOCIALNETWORKS", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object);
264 print "</td></tr>\n";
265
266 // Show list of socialnetworks for user
267 if ($showUserSocialNetworks) {
268 $socialnetworks = $object->socialnetworks;
269 if (!empty($socialnetworks)) {
270 foreach ($socialnetworks as $key => $networkVal) {
271 print '<tr class="oddeven">';
272 print '<td> &nbsp; &nbsp; '.$langs->trans("Hide").' '.dol_escape_htmltag($key).'</td><td>';
273 print ajax_constantonoff('USER_PUBLIC_HIDE_SOCIALNETWORKS_'.strtoupper($key), array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object);
274 print '</td>';
275 print "</tr>";
276 }
277 }
278 }
279
280 // Birth date
281 print '<tr class="oddeven" id="tredit"><td>';
282 print $langs->trans("ShowOnVCard", $langs->transnoentitiesnoconv("DateOfBirth"));
283 print '</td><td>';
284 print ajax_constantonoff("USER_PUBLIC_SHOW_BIRTH", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object);
285 print "</td></tr>\n";
286
287 // Address
288 print '<tr class="oddeven" id="tredit"><td>';
289 print $langs->trans("ShowOnVCard", $langs->transnoentitiesnoconv("Address"));
290 print '</td><td>';
291 print ajax_constantonoff("USER_PUBLIC_SHOW_ADDRESS", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object);
292 print "</td></tr>\n";
293
294 print '<tr class="liste_titre">';
295 print '<td>'.$langs->trans("Company").'</td>';
296 print '<td></td>';
297 print "</tr>\n";
298
299 // Company section
300 print '<tr class="oddeven" id="tramount"><td>';
301 print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("CompanySection"));
302 print '</td><td>';
303 print ajax_constantonoff("USER_PUBLIC_HIDE_COMPANY", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object);
304 print "</td></tr>\n";
305
306 if (!getDolUserString('USER_PUBLIC_HIDE_COMPANY', '', $object)) {
307 // Email
308 print '<tr class="oddeven" id="tredit"><td>';
309 print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Email"));
310 print '</td><td>';
311 print ajax_constantonoff("SOCIETE_PUBLIC_HIDE_EMAIL", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object);
312 print "</td></tr>\n";
313
314 // URL
315 print '<tr class="oddeven" id="tredit"><td>';
316 print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("URL"));
317 print '</td><td>';
318 print ajax_constantonoff("SOCIETE_PUBLIC_HIDE_URL", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object);
319 print "</td></tr>\n";
320
321 // Office phone
322 print '<tr class="oddeven" id="tredit"><td>';
323 print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Phone"));
324 print '</td><td>';
325 print ajax_constantonoff("SOCIETE_PUBLIC_HIDE_OFFICE_PHONE", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object);
326 print "</td></tr>\n";
327
328 // Office fax
329 print '<tr class="oddeven" id="tredit"><td>';
330 print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Fax"));
331 print '</td><td>';
332 print ajax_constantonoff("SOCIETE_PUBLIC_HIDE_OFFICE_FAX", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object);
333 print "</td></tr>\n";
334
335 // Social networks
336 print '<tr class="oddeven" id="tredit"><td>';
337 print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("SocialNetworksInformation"));
338 print '</td><td>';
339 print ajax_constantonoff("USER_PUBLIC_HIDE_SOCIALNETWORKS_BUSINESS", array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object);
340 print "</td></tr>\n";
341
342 // Show list of social networks for company
343 if ($showSocieteSocialNetworks) {
344 $listofnetworks = $mysoc->socialnetworks;
345
346 if (!empty($listofnetworks)) {
347 foreach ($listofnetworks as $key => $networkVal) {
348 print '<tr class="oddeven">';
349 print '<td> &nbsp; &nbsp; '.$langs->trans("Hide").' '.dol_escape_htmltag($key).'</td><td>';
350 print ajax_constantonoff('SOCIETE_PUBLIC_HIDE_SOCIALNETWORKS_'.strtoupper($key), array(), null, 0, 0, 1, 2, 0, 0, '', '', 'reposition', $object);
351 print '</td>';
352 print "</tr>";
353 }
354 }
355 }
356 }
357
358 print '<tr class="liste_titre">';
359 print '<td>'.$langs->trans("Other").'</td>';
360 print '<td></td>';
361 print "</tr>\n";
362
363 // More
364 print '<tr class="oddeven" id="tredit"><td>';
365 print $langs->trans("Text");
366 print '</td><td>';
367 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
368 $extendededitor = 0; // We force no WYSIWYG editor
369 $doleditor = new DolEditor('USER_PUBLIC_MORE', getDolUserString('USER_PUBLIC_MORE', '', $object), '', 160, 'dolibarr_notes', '', false, false, $extendededitor, ROWS_5, '90%');
370 $doleditor->Create();
371 print "</td></tr>\n";
372
373 print '</table>';
374 print '</div>';
375
376 print '<div class="center">';
377 print $form->buttonsSaveCancel("Save", '', array(), 0, '', $dol_openinpopup);
378 print '</div>';
379
380 print '<br>';
381
382 print '</div>'; // End hide/show
383
384 print '<br>';
385
386 // Preview
387 print '<div class="center">';
388 print '<span class="opacitymedium">'.$langs->trans("Preview").'</span><br>';
389 print '<div class="virtualcard-div">';
390 print '<a target="_blank" rel="noopener noreferrer cursorpointer" href="'.$fullexternaleurltovirtualcard.'">'."\n";
391 print '<iframe id="virtualcard-iframe" title="" class="center" src="'.$fullinternalurltovirtualcard.'&mode=preview">';
392 print '</iframe>';
393 print '</a>';
394 print '</div>';
395 print '</div>';
396
397 print '<br>';
398}
399
400
401print '</form>';
402
403print '</div>';
404
405
406// End of page
407llxFooter();
408$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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:73
Class to manage a WYSIWYG editor.
Class to manage generation of HTML components Only common components must be here.
Class to manage Dolibarr users.
global $mysoc
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
dol_set_user_param($db, $conf, &$user, $tab, $entity=-1)
Save personal parameter.
getDolUserInt($key, $default=0, $tmpuser=null)
Return Dolibarr user constant int value.
getDolUserString($key, $default='', $tmpuser=null)
Return Dolibarr user constant string value.
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, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Definition html.lib.php:181
print $langs trans('Date')." left Ref Label right Qty right Price right TotalHT right TotalTTC right right right right right right right right right centpercent right TotalHT right n right VAT right n right TotalVAT right n No sujeto a RE IRPF right TotalLT1 right n right TotalLT2 right n right TotalTTC right n takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency right TotalTTC takeposcustomercurrency right takeposcustomercurrency n right Paid right PaymentTypeShortLIQ right SELECT p pos_change as p datep as date
Definition receipt.php:492
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
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.