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/functions2.lib.php';
28require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
29require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
30
31// Load translation files required by page
32$langs->loadLangs(array("users", "companies", "admin", "website"));
33
34// Security check
35$id = GETPOSTINT('id');
36$ref = GETPOST('ref', 'alpha');
37$action = GETPOST('action', 'aZ09');
38$dol_openinpopup = GETPOST('dol_openinpopup', 'aZ09');
39
40if (empty($id) && empty($ref)) {
41 $id = $user->id;
42}
43
44$object = new User($db);
45if ($id > 0 || !empty($ref)) {
46 $result = $object->fetch($id, $ref, '', 1);
47 $object->loadRights();
48}
49
50// Security check
51$socid = 0;
52if ($user->socid > 0) {
53 $socid = $user->socid;
54}
55$feature2 = (($socid && $user->hasRight('user', 'self', 'creer')) ? '' : 'user');
56
57$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
58
59// If user is not the user that read and has no permission to read other users, we stop
60if (($object->id != $user->id) && !$user->hasRight('user', 'user', 'lire')) {
62}
63
64$permissiontoedit = ((($object->id == $user->id) && $user->hasRight('user', 'self', 'creer')) || $user->hasRight('user', 'user', 'creer'));
65
66
67/*
68 * Actions
69 */
70
71if ($action == 'update' && $permissiontoedit) {
72 $tmparray = array();
73 $tmparray['USER_PUBLIC_HIDE_PHOTO'] = (GETPOST('USER_PUBLIC_HIDE_PHOTO') ? 1 : 0);
74 $tmparray['USER_PUBLIC_HIDE_JOBPOSITION'] = (GETPOST('USER_PUBLIC_HIDE_JOBPOSITION') ? 1 : 0);
75 $tmparray['USER_PUBLIC_HIDE_EMAIL'] = (GETPOST('USER_PUBLIC_HIDE_EMAIL') ? 1 : 0);
76 $tmparray['USER_PUBLIC_HIDE_OFFICE_PHONE'] = (GETPOST('USER_PUBLIC_HIDE_OFFICE_PHONE') ? 1 : 0);
77 $tmparray['USER_PUBLIC_HIDE_OFFICE_FAX'] = (GETPOST('USER_PUBLIC_HIDE_OFFICE_FAX') ? 1 : 0);
78 $tmparray['USER_PUBLIC_HIDE_USER_MOBILE'] = (GETPOST('USER_PUBLIC_HIDE_USER_MOBILE') ? 1 : 0);
79 $tmparray['USER_PUBLIC_HIDE_SOCIALNETWORKS'] = (GETPOST('USER_PUBLIC_HIDE_SOCIALNETWORKS') ? 1 : 0);
80 $tmparray['USER_PUBLIC_SHOW_BIRTH'] = (GETPOST('USER_PUBLIC_SHOW_BIRTH') ? 1 : 0);
81 $tmparray['USER_PUBLIC_SHOW_ADDRESS'] = (GETPOST('USER_PUBLIC_SHOW_ADDRESS') ? 1 : 0);
82 $tmparray['USER_PUBLIC_HIDE_COMPANY'] = (GETPOST('USER_PUBLIC_HIDE_COMPANY') ? 1 : 0);
83 $tmparray['USER_PUBLIC_MORE'] = (GETPOST('USER_PUBLIC_MORE') ? GETPOST('USER_PUBLIC_MORE') : '');
84
85 dol_set_user_param($db, $conf, $object, $tmparray);
86}
87
88if ($action == 'setUSER_ENABLE_PUBLIC' && $permissiontoedit) {
89 if (GETPOST('value')) {
90 $tmparray = array('USER_ENABLE_PUBLIC' => 1);
91 } else {
92 $tmparray = array('USER_ENABLE_PUBLIC' => 0);
93 }
94 dol_set_user_param($db, $conf, $object, $tmparray);
95}
96
97
98/*
99 * View
100 */
101
102$form = new Form($db);
103
104$person_name = !empty($object->firstname) ? $object->lastname.", ".$object->firstname : $object->lastname;
105$title = $person_name." - ".$langs->trans('Info');
106$help_url = '';
107llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-user page-virtualcard');
108
109$head = user_prepare_head($object);
110
111$title = $langs->trans("User");
112//print dol_get_fiche_head($head, 'info', $title, -1, 'user');
113
114
115$linkback = '';
116
117if ($user->hasRight('user', 'user', 'lire') || $user->admin) {
118 $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
119}
120
121$morehtmlref = '<a href="'.DOL_URL_ROOT.'/user/vcard.php?id='.$object->id.'&output=file&file='.urlencode(dol_sanitizeFileName($object->getFullName($langs).'.vcf')).'" class="refid" rel="noopener">';
122$morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
123$morehtmlref .= '</a>';
124
125$urltovirtualcard = '/user/virtualcard.php?id='.((int) $object->id);
126$morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->transnoentitiesnoconv("PublicVirtualCardUrl").' - '.$object->getFullName($langs), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', 'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard, '', 'nohover');
127
128
129print '<div class="fichecenter">';
130
131print '<br>';
132
133$param = '&id='.((int) $object->id);
134$param .= '&dol_openinpopup=1';
135
136$enabledisablehtml = $langs->trans("EnablePublicVirtualCard").' ';
137if (!getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) {
138 // Button off, click to enable
139 $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setUSER_ENABLE_PUBLIC&token='.newToken().'&value=1'.$param.'">';
140 $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
141 $enabledisablehtml .= '</a>';
142
143 $enabledisablehtml .= '<br><br><span class="opacitymedium">'.$langs->trans("UserPublicPageDesc").'</span><br><br>';
144} else {
145 // Button on, click to disable
146 $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setUSER_ENABLE_PUBLIC&token='.newToken().'&value=0'.$param.'">';
147 $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
148 $enabledisablehtml .= '</a>';
149}
150print $enabledisablehtml;
151print '<input type="hidden" id="USER_ENABLE_PUBLIC" name="USER_ENABLE_PUBLIC" value="'.(!getDolGlobalString('USER_ENABLE_PUBLIC') ? 0 : 1).'">';
152
153print '<br><br>';
154
155print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
156
157if (getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) {
158 print '<input type="hidden" name="action" value="update">';
159 print '<input type="hidden" name="id" value="'.$object->id.'">';
160 print '<input type="hidden" name="token" value="'.newToken().'">';
161
162 //print $langs->trans('FollowingLinksArePublic').'<br>';
163 print img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans('PublicVirtualCardUrl').'</span><br>';
164
165 $fullexternaleurltovirtualcard = $object->getOnlineVirtualCardUrl('', 'external');
166 $fullinternalurltovirtualcard = $object->getOnlineVirtualCardUrl('', 'internal');
167
168 print '<div class="urllink">';
169 print '<input type="text" id="publicurluser" class="quatrevingtpercentminusx" value="'.$fullexternaleurltovirtualcard.'">';
170 print '<a target="_blank" rel="noopener noreferrer" href="'.$fullexternaleurltovirtualcard.'">'.img_picto('', 'globe', 'class="paddingleft marginrightonly paddingright"').$langs->trans("GoTo").'...</a>';
171 print '</div>';
172 print ajax_autoselect('publicurluser');
173
174 print '<br>';
175 print '<br>';
176
177 // Show/Hide options
178 print '<div class="centpercent margintoponly marginbottomonly">';
179 print img_picto('', 'setup', 'class="pictofixedwidth"').'<a id="lnk" href="#">'.$langs->trans("ShowAdvancedOptions").'...</a>';
180 print '</div>';
181
182 print '<script type="text/javascript">
183 jQuery(document).ready(function() {
184 jQuery("#lnk").click(function(event) {
185 event.preventDefault();
186 console.log("We click on link to show virtual card options");
187 hideoptions(this);
188 });
189 });
190
191 function hideoptions(domelem) {
192 const div = document.getElementById("div_container_sub_exportoptions");
193
194 if (div.style.display === "none") {
195 div.style.display = "block";
196 domelem.innerText="'.dol_escape_js($langs->transnoentitiesnoconv("HideAdvancedoptions")).'";
197 } else {
198 div.style.display = "none";
199 domelem.innerText="'.dol_escape_js($langs->transnoentitiesnoconv("ShowAdvancedOptions")).'...";
200 }
201 }
202 </script>';
203
204 // Start div hide/Show
205 print '<div id="div_container_sub_exportoptions" style="display: none;">';
206
207 print '<div class="div-table-responsive-no-min">';
208 print '<table class="noborder centpercent">';
209
210 print '<tr class="liste_titre">';
211 print '<td>'.$langs->trans("Options").'</td>';
212 print '<td>'.$langs->trans("Value").'</td>';
213 print "</tr>\n";
214
215 // User photo
216 print '<tr class="oddeven" id="tredit"><td>';
217 print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Photo"));
218 print '</td><td>';
219 print $form->selectyesno("USER_PUBLIC_HIDE_PHOTO", (getDolUserInt('USER_PUBLIC_HIDE_PHOTO', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_PHOTO', 0, $object) : 0), 1);
220 print "</td></tr>\n";
221
222 // Job position
223 print '<tr class="oddeven" id="tredit"><td>';
224 print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("PostOrFunction"));
225 print '</td><td>';
226 print $form->selectyesno("USER_PUBLIC_HIDE_JOBPOSITION", (getDolUserInt('USER_PUBLIC_HIDE_JOBPOSITION', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_JOBPOSITION', 0, $object) : 0), 1);
227 print "</td></tr>\n";
228
229 // Email
230 print '<tr class="oddeven" id="tredit"><td>';
231 print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Email"));
232 print '</td><td>';
233 print $form->selectyesno("USER_PUBLIC_HIDE_EMAIL", (getDolUserInt('USER_PUBLIC_HIDE_EMAIL', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_EMAIL', 0, $object) : 0), 1);
234 print "</td></tr>\n";
235
236 // Office phone
237 print '<tr class="oddeven" id="tredit"><td>';
238 print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("PhonePro"));
239 print '</td><td>';
240 print $form->selectyesno("USER_PUBLIC_HIDE_OFFICE_PHONE", (getDolUserInt('USER_PUBLIC_HIDE_OFFICE_PHONE', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_OFFICE_PHONE', 0, $object) : 0), 1);
241 print "</td></tr>\n";
242
243 // Office fax
244 print '<tr class="oddeven" id="tredit"><td>';
245 print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Fax"));
246 print '</td><td>';
247 print $form->selectyesno("USER_PUBLIC_HIDE_OFFICE_FAX", (getDolUserInt('USER_PUBLIC_HIDE_OFFICE_FAX', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_OFFICE_FAX', 0, $object) : 0), 1);
248 print "</td></tr>\n";
249
250 // User mobile
251 print '<tr class="oddeven" id="tredit"><td>';
252 print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("PhoneMobile"));
253 print '</td><td>';
254 print $form->selectyesno("USER_PUBLIC_HIDE_USER_MOBILE", (getDolUserInt('USER_PUBLIC_HIDE_USER_MOBILE', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_USER_MOBILE', 0, $object) : 0), 1);
255 print "</td></tr>\n";
256
257 // Social networks
258 print '<tr class="oddeven" id="tredit"><td>';
259 print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("SocialNetworksInformation"));
260 print '</td><td>';
261 print $form->selectyesno("USER_PUBLIC_HIDE_SOCIALNETWORKS", (getDolUserInt('USER_PUBLIC_HIDE_SOCIALNETWORKS', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_SOCIALNETWORKS', 0, $object) : 0), 1);
262 print "</td></tr>\n";
263
264 // Birth date
265 print '<tr class="oddeven" id="tredit"><td>';
266 print $langs->trans("ShowOnVCard", $langs->transnoentitiesnoconv("Birthdate"));
267 print '</td><td>';
268 print $form->selectyesno("USER_PUBLIC_SHOW_BIRTH", (getDolUserInt('USER_PUBLIC_SHOW_BIRTH', 0, $object) ? getDolUserInt('USER_PUBLIC_SHOW_BIRTH', 0, $object) : 0), 1);
269 print "</td></tr>\n";
270
271 // Address
272 print '<tr class="oddeven" id="tredit"><td>';
273 print $langs->trans("ShowOnVCard", $langs->transnoentitiesnoconv("Address"));
274 print '</td><td>';
275 print $form->selectyesno("USER_PUBLIC_SHOW_ADDRESS", (getDolUserInt('USER_PUBLIC_SHOW_ADDRESS', 0, $object) ? getDolUserInt('USER_PUBLIC_SHOW_ADDRESS', 0, $object) : 0), 1);
276 print "</td></tr>\n";
277
278 // Company name
279 print '<tr class="oddeven" id="tramount"><td>';
280 print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("CompanySection"));
281 print '</td><td>';
282 print $form->selectyesno("USER_PUBLIC_HIDE_COMPANY", (getDolUserInt('USER_PUBLIC_HIDE_COMPANY', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_COMPANY', 0, $object) : 0), 1);
283 print "</td></tr>\n";
284
285 // More
286 print '<tr class="oddeven" id="tredit"><td>';
287 print $langs->trans("Text");
288 print '</td><td>';
289 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
290 $extendededitor = 0; // We force no WYSIWYG editor
291 $doleditor = new DolEditor('USER_PUBLIC_MORE', getDolUserString('USER_PUBLIC_MORE', '', $object), '', 160, 'dolibarr_notes', '', false, false, $extendededitor, ROWS_5, '90%');
292 $doleditor->Create();
293 print "</td></tr>\n";
294
295 print '</table>';
296 print '</div>';
297
298 print '<div class="center">';
299 print $form->buttonsSaveCancel("Save", '', array(), 0, '', $dol_openinpopup);
300 print '</div>';
301
302 print '<br>';
303
304 print '</div>'; // End hide/show
305
306 print '<br>';
307
308 // Preview
309 print '<div class="center">';
310 print '<span class="opacitymedium">'.$langs->trans("Preview").'</span><br>';
311 print '<div class="virtualcard-div">';
312 print '<a target="_blank" rel="noopener noreferrer cursorpointer" href="'.$fullexternaleurltovirtualcard.'">'."\n";
313 print '<iframe id="virtualcard-iframe" title="" class="center" src="'.$fullinternalurltovirtualcard.'&mode=preview">';
314 print '</iframe>';
315 print '</a>';
316 print '</div>';
317 print '</div>';
318
319 print '<br>';
320}
321
322
323print '</form>';
324
325print '</div>';
326
327
328// End of page
329llxFooter();
330$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.
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $backtopagejsfields='', $accesskey='')
Return HTML code to output a button to open a dialog popup box.
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_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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.
user_prepare_head(User $object)
Prepare array with list of tabs.