dolibarr  19.0.0-dev
virtualcard.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2004-2007 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
26 require '../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
29 require_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 = GETPOST('id', 'int');
36 $ref = GETPOST('ref', 'alpha');
37 $action = GETPOST('action', 'aZ09');
38 $dol_openinpopup = GETPOST('dol_openinpopup', 'aZ09');
39 
40 if (empty($id) && empty($ref)) {
41  $id = $user->id;
42 }
43 
44 $object = new User($db);
45 if ($id > 0 || !empty($ref)) {
46  $result = $object->fetch($id, $ref, '', 1);
47  $object->getrights();
48 }
49 
50 // Security check
51 $socid = 0;
52 if ($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
60 if (($object->id != $user->id) && empty($user->rights->user->user->lire)) {
62 }
63 
64 /*
65  * Actions
66  */
67 
68 if ($action == 'update') {
69  $tmparray = array();
70  $tmparray['USER_PUBLIC_HIDE_PHOTO'] = (GETPOST('USER_PUBLIC_HIDE_PHOTO') ? 1 : 0);
71  $tmparray['USER_PUBLIC_HIDE_JOBPOSITION'] = (GETPOST('USER_PUBLIC_HIDE_JOBPOSITION') ? 1 : 0);
72  $tmparray['USER_PUBLIC_HIDE_EMAIL'] = (GETPOST('USER_PUBLIC_HIDE_EMAIL') ? 1 : 0);
73  $tmparray['USER_PUBLIC_HIDE_OFFICE_PHONE'] = (GETPOST('USER_PUBLIC_HIDE_OFFICE_PHONE') ? 1 : 0);
74  $tmparray['USER_PUBLIC_HIDE_OFFICE_FAX'] = (GETPOST('USER_PUBLIC_HIDE_OFFICE_FAX') ? 1 : 0);
75  $tmparray['USER_PUBLIC_HIDE_USER_MOBILE'] = (GETPOST('USER_PUBLIC_HIDE_USER_MOBILE') ? 1 : 0);
76  $tmparray['USER_PUBLIC_HIDE_BIRTH'] = (GETPOST('USER_PUBLIC_HIDE_BIRTH') ? 1 : 0);
77  $tmparray['USER_PUBLIC_HIDE_SOCIALNETWORKS'] = (GETPOST('USER_PUBLIC_HIDE_SOCIALNETWORKS') ? 1 : 0);
78  $tmparray['USER_PUBLIC_HIDE_ADDRESS'] = (GETPOST('USER_PUBLIC_HIDE_ADDRESS') ? 1 : 0);
79  $tmparray['USER_PUBLIC_HIDE_COMPANY'] = (GETPOST('USER_PUBLIC_HIDE_COMPANY') ? 1 : 0);
80  $tmparray['USER_PUBLIC_MORE'] = (GETPOST('USER_PUBLIC_MORE') ? GETPOST('USER_PUBLIC_MORE') : '');
81 
82  dol_set_user_param($db, $conf, $object, $tmparray);
83 }
84 
85 if ($action == 'setUSER_ENABLE_PUBLIC') {
86  if (GETPOST('value')) {
87  $tmparray = array('USER_ENABLE_PUBLIC' => 1);
88  } else {
89  $tmparray = array('USER_ENABLE_PUBLIC' => 0);
90  }
91  dol_set_user_param($db, $conf, $object, $tmparray);
92 }
93 
94 
95 /*
96  * View
97  */
98 
99 $form = new Form($db);
100 
101 $person_name = !empty($object->firstname) ? $object->lastname.", ".$object->firstname : $object->lastname;
102 $title = $person_name." - ".$langs->trans('Info');
103 $help_url = '';
104 llxHeader('', $title, $help_url);
105 
106 $head = user_prepare_head($object);
107 
108 $title = $langs->trans("User");
109 //print dol_get_fiche_head($head, 'info', $title, -1, 'user');
110 
111 
112 $linkback = '';
113 
114 if ($user->rights->user->user->lire || $user->admin) {
115  $linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
116 }
117 
118 $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">';
119 $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
120 $morehtmlref .= '</a>';
121 
122 $urltovirtualcard = '/user/virtualcard.php?id='.((int) $object->id);
123 $morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->trans("PublicVirtualCardUrl").' - '.$object->getFullName($langs), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', 'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard, '', 'nohover');
124 
125 //dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin, 'rowid', 'ref', $morehtmlref);
126 
127 
128 print '<div class="fichecenter">';
129 
130 print '<br>';
131 
132 if (!getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) {
133  print '<span class="opacitymedium">'.$langs->trans("UserPublicPageDesc").'</span><br><br>';
134 }
135 
136 $param = '&id='.((int) $object->id);
137 $param .= '&dol_openinpopup=1';
138 
139 $enabledisablehtml = $langs->trans("EnablePublicVirtualCard").' ';
140 if (!getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) {
141  // Button off, click to enable
142  $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setUSER_ENABLE_PUBLIC&token='.newToken().'&value=1'.$param.'">';
143  $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
144  $enabledisablehtml .= '</a>';
145 } else {
146  // Button on, click to disable
147  $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setUSER_ENABLE_PUBLIC&token='.newToken().'&value=0'.$param.'">';
148  $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
149  $enabledisablehtml .= '</a>';
150 }
151 print $enabledisablehtml;
152 print '<input type="hidden" id="USER_ENABLE_PUBLIC" name="USER_ENABLE_PUBLIC" value="'.(empty($conf->global->USER_ENABLE_PUBLIC) ? 0 : 1).'">';
153 
154 print '<br><br>';
155 
156 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
157 
158 if (getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) {
159  print '<input type="hidden" name="action" value="update">';
160  print '<input type="hidden" name="id" value="'.$object->id.'">';
161  print '<input type="hidden" name="token" value="'.newToken().'">';
162 
163 
164  print '<br>';
165 
166 
167  //print $langs->trans('FollowingLinksArePublic').'<br>';
168  print img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans('PublicVirtualCardUrl').'</span><br>';
169 
170  $fullexternaleurltovirtualcard = $object->getOnlineVirtualCardUrl('', 'external');
171  $fullinternalurltovirtualcard = $object->getOnlineVirtualCardUrl('', 'internal');
172 
173  print '<div class="urllink">';
174  print '<input type="text" id="publicurluser" class="quatrevingtpercentminusx" value="'.$fullexternaleurltovirtualcard.'">';
175  print '<a target="_blank" rel="noopener noreferrer" href="'.$fullexternaleurltovirtualcard.'">'.img_picto('', 'globe', 'class="paddingleft marginrightonly paddingright"').$langs->trans("GoTo").'...</a>';
176  print '</div>';
177  print ajax_autoselect('publicurluser');
178 
179  print '<br>';
180  print '<br>';
181 
182  // Show/Hide options
183  print '<div class="centpercent margintoponly marginbottomonly">';
184  print img_picto('', 'setup', 'class="pictofixedwidth"').'<a id="lnk" href="#">'.$langs->trans("ShowAdvancedOptions").'...</a>';
185  print '</div>';
186 
187  print '<script type="text/javascript">
188  jQuery(document).ready(function() {
189  jQuery("#lnk").click(function() {
190  console.log("We click on link");
191  hideoptions(this);
192  });
193  });
194 
195  function hideoptions(domelem) {
196  const div = document.getElementById("div_container_sub_exportoptions");
197 
198  if (div.style.display === "none") {
199  div.style.display = "block";
200  domelem.innerText="'.dol_escape_js($langs->transnoentitiesnoconv("HideAdvancedoptions")).'";
201  } else {
202  div.style.display = "none";
203  domelem.innerText="'.dol_escape_js($langs->transnoentitiesnoconv("ShowAdvancedOptions")).'...";
204  }
205  }
206  </script>';
207 
208  // Start div hide/Show
209  print '<div id="div_container_sub_exportoptions" style="display: none;">';
210 
211  print '<div class="div-table-responsive-no-min">';
212  print '<table class="noborder centpercent">';
213 
214  print '<tr class="liste_titre">';
215  print '<td>'.$langs->trans("Options").'</td>';
216  print '<td>'.$langs->trans("Value").'</td>';
217  print "</tr>\n";
218 
219  // User photo
220  print '<tr class="oddeven" id="tredit"><td>';
221  print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Photo"));
222  print '</td><td>';
223  print $form->selectyesno("USER_PUBLIC_HIDE_PHOTO", (getDolUserInt('USER_PUBLIC_HIDE_PHOTO', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_PHOTO', 0, $object) : 0), 1);
224  print "</td></tr>\n";
225 
226  // Job position
227  print '<tr class="oddeven" id="tredit"><td>';
228  print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("PostOrFunction"));
229  print '</td><td>';
230  print $form->selectyesno("USER_PUBLIC_HIDE_JOBPOSITION", (getDolUserInt('USER_PUBLIC_HIDE_JOBPOSITION', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_JOBPOSITION', 0, $object) : 0), 1);
231  print "</td></tr>\n";
232 
233  // Email
234  print '<tr class="oddeven" id="tredit"><td>';
235  print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Email"));
236  print '</td><td>';
237  print $form->selectyesno("USER_PUBLIC_HIDE_EMAIL", (getDolUserInt('USER_PUBLIC_HIDE_EMAIL', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_EMAIL', 0, $object) : 0), 1);
238  print "</td></tr>\n";
239 
240  // Office phone
241  print '<tr class="oddeven" id="tredit"><td>';
242  print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("PhonePro"));
243  print '</td><td>';
244  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);
245  print "</td></tr>\n";
246 
247  // Office fax
248  print '<tr class="oddeven" id="tredit"><td>';
249  print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Fax"));
250  print '</td><td>';
251  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);
252  print "</td></tr>\n";
253 
254  // User mobile
255  print '<tr class="oddeven" id="tredit"><td>';
256  print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("PhoneMobile"));
257  print '</td><td>';
258  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);
259  print "</td></tr>\n";
260 
261  // User mobile
262  print '<tr class="oddeven" id="tredit"><td>';
263  print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Birthdate"));
264  print '</td><td>';
265  print $form->selectyesno("USER_PUBLIC_HIDE_BIRTH", (getDolUserInt('USER_PUBLIC_HIDE_BIRTH', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_BIRTH', 0, $object) : 0), 1);
266  print "</td></tr>\n";
267 
268  // Social networks
269  print '<tr class="oddeven" id="tredit"><td>';
270  print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("SocialNetworksInformation"));
271  print '</td><td>';
272  print $form->selectyesno("USER_PUBLIC_HIDE_SOCIALNETWORKS", (getDolUserInt('USER_PUBLIC_HIDE_SOCIALNETWORKS', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_SOCIALNETWORKS', 0, $object) : 0), 1);
273  print "</td></tr>\n";
274 
275  // Address
276  print '<tr class="oddeven" id="tredit"><td>';
277  print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Address"));
278  print '</td><td>';
279  print $form->selectyesno("USER_PUBLIC_HIDE_ADDRESS", (getDolUserInt('USER_PUBLIC_HIDE_ADDRESS', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_ADDRESS', 0, $object) : 0), 1);
280  print "</td></tr>\n";
281 
282  // Company name
283  print '<tr class="oddeven" id="tramount"><td>';
284  print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("CompanySection"));
285  print '</td><td>';
286  print $form->selectyesno("USER_PUBLIC_HIDE_COMPANY", (getDolUserInt('USER_PUBLIC_HIDE_COMPANY', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_COMPANY', 0, $object) : 0), 1);
287  print "</td></tr>\n";
288 
289  // More
290  print '<tr class="oddeven" id="tredit"><td>';
291  print $langs->trans("Text");
292  print '</td><td>';
293  require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
294  $extendededitor = 0; // We force no WYSIWYG editor
295  $doleditor = new DolEditor('USER_PUBLIC_MORE', getDolUserString('USER_PUBLIC_MORE', '', $object), '', 160, 'dolibarr_notes', '', false, false, $extendededitor, ROWS_5, '90%');
296  $doleditor->Create();
297  print "</td></tr>\n";
298 
299  print '</table>';
300  print '</div>';
301 
302  print '<div class="center">';
303  print $form->buttonsSaveCancel("Save", '', array(), 0, '', $dol_openinpopup);
304  print '</div>';
305 
306  print '<br>';
307 
308  print '</div>'; // End hide/show
309 
310  print '<br>';
311 
312  // Preview
313  print '<div class="center">';
314  print '<span class="opacitymedium">'.$langs->trans("Preview").'</span><br>';
315  print '<div class="virtualcard-div">';
316  print '<a target="_blank" rel="noopener noreferrer cursorpointer" href="'.$fullexternaleurltovirtualcard.'">'."\n";
317  print '<iframe id="virtualcard-iframe" title="" class="center" src="'.$fullinternalurltovirtualcard.'&mode=preview">';
318  print '</iframe>';
319  print '</a>';
320  print '</div>';
321  print '</div>';
322 
323  print '<br>';
324 }
325 
326 
327 print '</form>';
328 
329 print '</div>';
330 
331 
332 // End of page
333 llxFooter();
334 $db->close();
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:118
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
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.
Definition: user.class.php:48
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
dol_set_user_param($db, $conf, &$user, $tab)
Save personnal parameter.
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
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.