dolibarr  x.y.z
card.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
6  * Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro@open-dsi.fr>
7  * Copyright (C) 2018-2019 Thibault FOUCART <support@ptibogxiv.net>
8  * Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <https://www.gnu.org/licenses/>.
22  */
23 
30 // Load Dolibarr environment
31 require '../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/modules/dons/modules_don.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
39 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
40 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php';
41 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
42 if (isModEnabled('project')) {
43  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
44  require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
45 }
46 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
47 
48 $langs->loadLangs(array('bills', 'companies', 'donations', 'users'));
49 
50 $id = GETPOST('rowid') ?GETPOST('rowid', 'int') : GETPOST('id', 'int');
51 $ref = GETPOST('ref', 'alpha');
52 $action = GETPOST('action', 'aZ09');
53 $cancel = GETPOST('cancel', 'alpha');
54 $confirm = GETPOST('confirm', 'alpha');
55 
56 $amount = price2num(GETPOST('amount', 'alphanohtml'), 'MT');
57 $donation_date = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
58 $projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0);
59 $public_donation = (int) GETPOST("public", 'int');
60 
61 $object = new Don($db);
62 if ($id > 0 || $ref) {
63  $object->fetch($id, $ref);
64 }
65 
66 $extrafields = new ExtraFields($db);
67 
68 // fetch optionals attributes and labels
69 $extrafields->fetch_name_optionals_label($object->table_element);
70 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
71 
72 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
73 $hookmanager->initHooks(array('doncard', 'globalcard'));
74 
75 $upload_dir = $conf->don->dir_output;
76 
77 
78 // Security check
79 $result = restrictedArea($user, 'don', $object->id);
80 
81 $permissiontoadd = $user->rights->don->creer;
82 
83 
84 /*
85  * Actions
86  */
87 
88 $parameters = array();
89 
90 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some
91 if ($reshook < 0) {
92  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
93 }
94 
95 if (empty($reshook)) {
96  $backurlforlist = DOL_URL_ROOT.'/don/list.php';
97 
98  if (empty($backtopage) || ($cancel && empty($id))) {
99  if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
100  if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
101  $backtopage = $backurlforlist;
102  } else {
103  $backtopage = DOL_URL_ROOT.'/don/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
104  }
105  }
106  }
107 
108  if ($cancel) {
109  if (!empty($backtopageforcancel)) {
110  header("Location: ".$backtopageforcancel);
111  exit;
112  } elseif (!empty($backtopage)) {
113  header("Location: ".$backtopage);
114  exit;
115  }
116  $action = '';
117  }
118 
119  // Action reopen object
120  if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd) {
121  $object->fetch($id);
122 
123  $result = $object->reopen($user);
124  if ($result >= 0) {
125  // Define output language
126  if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
127  if (method_exists($object, 'generateDocument')) {
128  $outputlangs = $langs;
129  $newlang = '';
130  if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
131  $newlang = GETPOST('lang_id', 'aZ09');
132  }
133  if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
134  $newlang = $object->thirdparty->default_lang;
135  }
136  if (!empty($newlang)) {
137  $outputlangs = new Translate("", $conf);
138  $outputlangs->setDefaultLang($newlang);
139  }
140  $model = $object->model_pdf;
141  $ret = $object->fetch($id); // Reload to get new records
142 
143  $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
144  }
145  }
146 
147  header("Location: ".$_SERVER["PHP_SELF"].'?id='.$object->id);
148  exit;
149  } else {
150  setEventMessages($object->error, $object->errors, 'errors');
151  $action = 'create';
152  }
153  }
154 
155 
156  // Action update object
157  if ($action == 'update') {
158  if (!empty($cancel)) {
159  header("Location: ".$_SERVER['PHP_SELF']."?id=".urlencode($id));
160  exit;
161  }
162 
163  $error = 0;
164 
165  if (empty($donation_date)) {
166  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
167  $action = "create";
168  $error++;
169  }
170 
171  if (empty($amount)) {
172  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors');
173  $action = "create";
174  $error++;
175  }
176 
177  if (!$error) {
178  $object->fetch($id);
179 
180  $object->firstname = (string) GETPOST("firstname", 'alpha');
181  $object->lastname = (string) GETPOST("lastname", 'alpha');
182  $object->societe = (string) GETPOST("societe", 'alpha');
183  $object->address = (string) GETPOST("address", 'alpha');
184  $object->amount = price2num(GETPOST("amount", 'alpha'), '', 2);
185  $object->town = (string) GETPOST("town", 'alpha');
186  $object->zip = (string) GETPOST("zipcode", 'alpha');
187  $object->country_id = (int) GETPOST('country_id', 'int');
188  $object->email = (string) GETPOST("email", 'alpha');
189  $object->date = $donation_date;
190  $object->public = $public_donation;
191  $object->fk_project = (int) GETPOST("fk_project", 'int');
192  $object->modepaymentid = (int) GETPOST('modepayment', 'int');
193 
194  // Fill array 'array_options' with data from add form
195  $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
196  if ($ret < 0) {
197  $error++;
198  }
199 
200  if ($object->update($user) > 0) {
201  header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
202  exit;
203  } else {
204  setEventMessages($object->error, $object->errors, 'errors');
205  $action = "create";
206  }
207  }
208  }
209 
210 
211  // Action add/create object
212  if ($action == 'add') {
213  if (!empty($cancel)) {
214  header("Location: index.php");
215  exit;
216  }
217 
218  $error = 0;
219 
220  if (isModEnabled("societe") && !empty($conf->global->DONATION_USE_THIRDPARTIES) && !(GETPOST("socid", 'int') > 0)) {
221  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ThirdParty")), null, 'errors');
222  $action = "create";
223  $error++;
224  }
225  if (empty($donation_date)) {
226  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
227  $action = "create";
228  $error++;
229  }
230 
231  if (empty($amount)) {
232  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors');
233  $action = "create";
234  $error++;
235  }
236 
237  if (!$error) {
238  $object->socid = (int) GETPOST("socid", 'int');
239  $object->firstname = (string) GETPOST("firstname", 'alpha');
240  $object->lastname = (string) GETPOST("lastname", 'alpha');
241  $object->societe = (string) GETPOST("societe", 'alpha');
242  $object->address = (string) GETPOST("address", 'alpha');
243  $object->amount = price2num(GETPOST("amount", 'alpha'), '', 2);
244  $object->zip = (string) GETPOST("zipcode", 'alpha');
245  $object->town = (string) GETPOST("town", 'alpha');
246  $object->country_id = (int) GETPOST('country_id', 'int');
247  $object->email = (string) GETPOST('email', 'alpha');
248  $object->date = $donation_date;
249  $object->note_private = (string) GETPOST("note_private", 'restricthtml');
250  $object->note_public = (string) GETPOST("note_public", 'restricthtml');
251  $object->public = $public_donation;
252  $object->fk_project = (int) GETPOST("fk_project", 'int');
253  $object->modepaymentid = (int) GETPOST('modepayment', 'int');
254 
255  // Fill array 'array_options' with data from add form
256  $ret = $extrafields->setOptionalsFromPost(null, $object);
257  if ($ret < 0) {
258  $error++;
259  }
260 
261  $res = $object->create($user);
262  if ($res > 0) {
263  header("Location: ".$_SERVER['PHP_SELF'].'?id='.$res);
264  exit;
265  } else {
266  setEventMessages($object->error, $object->errors, 'errors');
267  $action = "create";
268  }
269  }
270  }
271 
272  // Action delete object
273  if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->don->supprimer) {
274  $object->fetch($id);
275  $result = $object->delete($user);
276  if ($result > 0) {
277  header("Location: index.php");
278  exit;
279  } else {
280  dol_syslog($object->error, LOG_DEBUG);
281  setEventMessages($object->error, $object->errors, 'errors');
282  }
283  }
284 
285  // Action validation
286  if ($action == 'valid_promesse') {
287  $object->fetch($id);
288  if ($object->valid_promesse($id, $user->id) >= 0) {
289  setEventMessages($langs->trans("DonationValidated", $object->ref), null);
290  $action = '';
291  } else {
292  setEventMessages($object->error, $object->errors, 'errors');
293  }
294  }
295 
296  // Action cancel
297  if ($action == 'set_cancel') {
298  $object->fetch($id);
299  if ($object->set_cancel($id) >= 0) {
300  $action = '';
301  } else {
302  setEventMessages($object->error, $object->errors, 'errors');
303  }
304  }
305 
306  // Action set paid
307  if ($action == 'set_paid') {
308  $object->fetch($id);
309  if ($object->setPaid($id, $modepayment) >= 0) {
310  $action = '';
311  } else {
312  setEventMessages($object->error, $object->errors, 'errors');
313  }
314  } elseif ($action == 'classin' && $user->rights->don->creer) {
315  $object->fetch($id);
316  $object->setProject($projectid);
317  }
318 
319 
320  // Actions to build doc
321  include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
322 
323 
324  // Remove file in doc form
325  /*if ($action == 'remove_file')
326  {
327  $object = new Don($db, 0, GETPOST('id', 'int'));
328  if ($object->fetch($id))
329  {
330  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
331 
332  $object->fetch_thirdparty();
333 
334  $langs->load("other");
335  $upload_dir = $conf->don->dir_output;
336  $file = $upload_dir . '/' . GETPOST('file');
337  $ret=dol_delete_file($file,0,0,0,$object);
338  if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
339  else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
340  $action='';
341  }
342  }
343  */
344 
345  /*
346  * Build doc
347  */
348  /*
349  if ($action == 'builddoc')
350  {
351  $object = new Don($db);
352  $result=$object->fetch($id);
353 
354  // Save last template used to generate document
355  if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
356 
357  // Define output language
358  $outputlangs = $langs;
359  $newlang='';
360  if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && !empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
361  if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) $newlang=$object->thirdparty->default_lang;
362  if (!empty($newlang))
363  {
364  $outputlangs = new Translate("",$conf);
365  $outputlangs->setDefaultLang($newlang);
366  }
367  $result=don_create($db, $object->id, '', $object->model_pdf, $outputlangs);
368  if ($result <= 0)
369  {
370  dol_print_error($db,$result);
371  exit;
372  }
373  }
374  */
375 }
376 
377 
378 /*
379  * View
380  */
381 
382 $title = $langs->trans("Donation");
383 
384 $help_url = 'EN:Module_Donations|FR:Module_Dons|ES:M&oacute;dulo_Donaciones|DE:Modul_Spenden';
385 
386 llxHeader('', $title, $help_url);
387 
388 $form = new Form($db);
389 $formfile = new FormFile($db);
390 $formcompany = new FormCompany($db);
391 if (isModEnabled('project')) {
392  $formproject = new FormProjets($db);
393 }
394 
395 if ($action == 'create') {
396  print load_fiche_titre($langs->trans("AddDonation"), '', 'object_donation');
397 
398  print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
399  print '<input type="hidden" name="token" value="'.newToken().'">';
400  print '<input type="hidden" name="action" value="add">';
401 
402  print dol_get_fiche_head('');
403 
404  print '<table class="border centpercent">';
405  print '<tbody>';
406 
407  // Ref
408  print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans('Ref').'</td><td>'.$langs->trans('Draft').'</td></tr>';
409 
410  // Company
411  if (isModEnabled("societe") && !empty($conf->global->DONATION_USE_THIRDPARTIES)) {
412  // Thirdparty
413  if ($soc->id > 0) {
414  print '<td class="fieldrequired">'.$langs->trans('ThirdParty').'</td>';
415  print '<td>';
416  print $soc->getNomUrl(1);
417  print '<input type="hidden" name="socid" value="'.$soc->id.'">';
418  // Outstanding Bill
419  $arrayoutstandingbills = $soc->getOutstandingBills();
420  $outstandingBills = $arrayoutstandingbills['opened'];
421  print ' ('.$langs->trans('CurrentOutstandingBill').': ';
422  print price($outstandingBills, '', $langs, 0, 0, -1, $conf->currency);
423  if ($soc->outstanding_limit != '') {
424  if ($outstandingBills > $soc->outstanding_limit) {
425  print img_warning($langs->trans("OutstandingBillReached"));
426  }
427  print ' / '.price($soc->outstanding_limit, '', $langs, 0, 0, -1, $conf->currency);
428  }
429  print ')';
430  print '</td>';
431  } else {
432  print '<td class="fieldrequired">'.$langs->trans('ThirdParty').'</td>';
433  print '<td>';
434  print $form->select_company($soc->id, 'socid', '(s.client = 1 OR s.client = 3) AND status=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300');
435  // Option to reload page to retrieve customer informations. Note, this clear other input
436  if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED)) {
437  print '<script type="text/javascript">
438  $(document).ready(function() {
439  $("#socid").change(function() {
440  console.log("We have changed the company - Reload page");
441  var socid = $(this).val();
442  var fac_rec = $(\'#fac_rec\').val();
443  // reload page
444  $("input[name=action]").val("create");
445  $("form[name=add]").submit();
446  });
447  });
448  </script>';
449  }
450  print ' <a href="'.DOL_URL_ROOT.'/societe/card.php?action=create&client=3&fournisseur=0&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create').'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddThirdParty").'"></span></a>';
451  print '</td>';
452  }
453  print '</tr>'."\n";
454  }
455 
456  // Date
457  print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("Date").'</td><td>';
458  print $form->selectDate($donation_date ? $donation_date : -1, '', '', '', '', "add", 1, 1);
459  print '</td>';
460 
461  // Amount
462  print "<tr>".'<td class="fieldrequired">'.$langs->trans("Amount").'</td><td><input type="text" name="amount" value="'.dol_escape_htmltag(GETPOST("amount")).'" size="10"> '.$langs->trans("Currency".$conf->currency).'</td></tr>';
463 
464  // Public donation
465  print '<tr><td class="fieldrequired">'.$langs->trans("PublicDonation")."</td><td>";
466  print $form->selectyesno("public", $public_donation, 1);
467  print "</td></tr>\n";
468 
469  if (!isModEnabled('societe') || empty($conf->global->DONATION_USE_THIRDPARTIES)) {
470  print "<tr>".'<td>'.$langs->trans("Company").'</td><td><input type="text" name="societe" value="'.dol_escape_htmltag(GETPOST("societe")).'" class="maxwidth200"></td></tr>';
471  print "<tr>".'<td>'.$langs->trans("Lastname").'</td><td><input type="text" name="lastname" value="'.dol_escape_htmltag(GETPOST("lastname")).'" class="maxwidth200"></td></tr>';
472  print "<tr>".'<td>'.$langs->trans("Firstname").'</td><td><input type="text" name="firstname" value="'.dol_escape_htmltag(GETPOST("firstname")).'" class="maxwidth200"></td></tr>';
473  print "<tr>".'<td>'.$langs->trans("Address").'</td><td>';
474  print '<textarea name="address" wrap="soft" class="quatrevingtpercent" rows="3">'.dol_escape_htmltag(GETPOST("address", "alphanohtml"), 0, 1).'</textarea></td></tr>';
475 
476  // Zip / Town
477  print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>';
478  print $formcompany->select_ziptown((GETPOSTISSET("zipcode") ? GETPOST("zipcode") : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6);
479  print ' ';
480  print $formcompany->select_ziptown((GETPOSTISSET("town") ? GETPOST("town") : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id'));
481  print '</tr>';
482 
483  // Country
484  print '<tr><td><label for="selectcountry_id">'.$langs->trans('Country').'</label></td><td class="maxwidthonsmartphone">';
485  print img_picto('', 'globe-americas', 'class="paddingrightonly"').$form->select_country(GETPOST('country_id') != '' ?GETPOST('country_id') : $object->country_id);
486  if ($user->admin) {
487  print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
488  }
489  print '</td></tr>';
490 
491  print "<tr>".'<td>'.$langs->trans("EMail").'</td><td>'.img_picto('', 'object_email', 'class="paddingrightonly"').'<input type="text" name="email" value="'.dol_escape_htmltag(GETPOST("email")).'" class="maxwidth200"></td></tr>';
492  }
493 
494  // Payment mode
495  print "<tr><td>".$langs->trans("PaymentMode")."</td><td>\n";
496  $selected = GETPOST('modepayment', 'int');
497  print img_picto('', 'payment', 'class="pictofixedwidth"');
498  print $form->select_types_paiements($selected, 'modepayment', 'CRDT', 0, 1, 0, 0, 1, 'maxwidth200 widthcentpercentminusx', 1);
499  print "</td></tr>\n";
500 
501  // Public note
502  print '<tr>';
503  print '<td class="tdtop">'.$langs->trans('NotePublic').'</td>';
504  print '<td>';
505  if (!isset($note_public)) {
506  $note_public = $object->getDefaultCreateValueFor('note_public');
507  }
508  $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%');
509  print $doleditor->Create(1);
510  print '</td></tr>';
511 
512  // Private note
513  if (empty($user->socid)) {
514  print '<tr>';
515  print '<td class="tdtop">'.$langs->trans('NotePrivate').'</td>';
516  print '<td>';
517  if (!isset($note_private)) {
518  $note_private = $object->getDefaultCreateValueFor('note_private');
519  }
520  $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%');
521  print $doleditor->Create(1);
522  print '</td></tr>';
523  }
524 
525  if (isModEnabled('project')) {
526  print "<tr><td>".$langs->trans("Project")."</td><td>";
527  print img_picto('', 'project', 'class="pictofixedwidth"');
528  print $formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500');
529  print "</td></tr>\n";
530  }
531 
532  // Other attributes
533  $parameters = array();
534  $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
535  print $hookmanager->resPrint;
536  if (empty($reshook)) {
537  print $object->showOptionals($extrafields, 'create', $parameters);
538  }
539 
540  print '</tbody>';
541  print "</table>\n";
542 
543  print dol_get_fiche_end();
544 
545  print $form->buttonsSaveCancel();
546 
547  print "</form>\n";
548 }
549 
550 
551 /* ************************************************************ */
552 /* */
553 /* Donation card in edit mode */
554 /* */
555 /* ************************************************************ */
556 
557 if (!empty($id) && $action == 'edit') {
558  $result = $object->fetch($id);
559  if ($result < 0) {
560  dol_print_error($db, $object->error); exit;
561  }
562  $result = $object->fetch_optionals();
563  if ($result < 0) {
564  dol_print_error($db); exit;
565  }
566 
567  $hselected = 'card';
568  $head = donation_prepare_head($object);
569 
570  print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
571  print '<input type="hidden" name="token" value="'.newToken().'">';
572  print '<input type="hidden" name="action" value="update">';
573  print '<input type="hidden" name="rowid" value="'.$object->id.'">';
574  print '<input type="hidden" name="amount" value="'.$object->amount.'">';
575 
576 
577  print dol_get_fiche_head($head, $hselected, $langs->trans("Donation"), 0, 'donation');
578 
579  print '<table class="border centpercent">';
580 
581  // Ref
582  print '<tr><td>'.$langs->trans("Ref").'</td><td colspan="2">';
583  print $object->getNomUrl();
584  print '</td>';
585  print '</tr>';
586 
587  // Date
588  print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Date").'</td><td>';
589  print $form->selectDate($object->date, '', '', '', '', "update");
590  print '</td>';
591 
592  // Amount
593  if ($object->statut == 0) {
594  print "<tr>".'<td class="fieldrequired">'.$langs->trans("Amount").'</td><td><input type="text" name="amount" size="10" value="'.price($object->amount).'"> '.$langs->trans("Currency".$conf->currency).'</td></tr>';
595  } else {
596  print '<tr><td>'.$langs->trans("Amount").'</td><td>';
597  print price($object->amount, 0, $langs, 0, 0, -1, $conf->currency);
598  print '</td></tr>';
599  }
600 
601  print '<tr><td class="fieldrequired">'.$langs->trans("PublicDonation")."</td><td>";
602  print $form->selectyesno("public", $object->public, 1);
603  print "</td>";
604  print "</tr>\n";
605 
606  if (isModEnabled("societe") && !empty($conf->global->DONATION_USE_THIRDPARTIES)) {
607  $company = new Societe($db);
608 
609  print '<tr><td>'.$langs->trans("ThirdParty").'</td><td colspan="2">';
610  if ($object->socid > 0) {
611  $result = $company->fetch($object->socid);
612  print $company->getNomUrl(1);
613  }
614  print '</td></tr>';
615  } else {
616  $langs->load("companies");
617  print '<tr><td>'.$langs->trans("Company").'</td><td><input type="text" name="societe" class="maxwidth200" value="'.dol_escape_htmltag($object->societe).'"></td></tr>';
618  print '<tr><td>'.$langs->trans("Lastname").'</td><td><input type="text" name="lastname" class="maxwidth200" value="'.dol_escape_htmltag($object->lastname).'"></td></tr>';
619  print '<tr><td>'.$langs->trans("Firstname").'</td><td><input type="text" name="firstname" class="maxwidth200" value="'.dol_escape_htmltag($object->firstname).'"></td></tr>';
620  print '<tr><td>'.$langs->trans("Address").'</td><td>';
621  print '<textarea name="address" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">'.dol_escape_htmltag($object->address, 0, 1).'</textarea></td></tr>';
622 
623  // Zip / Town
624  print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>';
625  print $formcompany->select_ziptown((GETPOSTISSET("zipcode") ? GETPOSTISSET("zipcode") : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6);
626  print ' ';
627  print $formcompany->select_ziptown((GETPOSTISSET("town") ? GETPOST("town") : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id'));
628  print '</tr>';
629 
630  // Country
631  print '<tr><td class="titlefieldcreate">'.$langs->trans('Country').'</td><td>';
632  print $form->select_country((!empty($object->country_id) ? $object->country_id : $mysoc->country_code), 'country_id');
633  if ($user->admin) {
634  print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
635  }
636  print '</td></tr>';
637 
638  print "<tr>".'<td>'.$langs->trans("EMail").'</td><td><input type="text" name="email" class="maxwidth200" value="'.dol_escape_htmltag($object->email).'"></td></tr>';
639  }
640  // Payment mode
641  print "<tr><td>".$langs->trans("PaymentMode")."</td><td>\n";
642  if ($object->mode_reglement_id) {
643  $selected = $object->mode_reglement_id;
644  } else {
645  $selected = '';
646  }
647  $form->select_types_paiements($selected, 'modepayment', 'CRDT', 0, 1);
648  print "</td></tr>\n";
649 
650  // Status
651  print "<tr>".'<td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
652 
653  // Project
654  if (isModEnabled('project')) {
655  $formproject = new FormProjets($db);
656 
657  $langs->load('projects');
658  print '<tr><td>'.$langs->trans('Project').'</td><td>';
659  $formproject->select_projects(-1, $object->fk_project, 'fk_project', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500');
660  print '</td></tr>';
661  }
662 
663  // Other attributes
664  $parameters = array();
665  $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
666  print $hookmanager->resPrint;
667  if (empty($reshook)) {
668  print $object->showOptionals($extrafields, 'edit', $parameters);
669  }
670 
671  print "</table>\n";
672 
673  print dol_get_fiche_end();
674 
675  print $form->buttonsSaveCancel();
676 
677  print "</form>\n";
678 }
679 
680 
681 
682 /* ************************************************************ */
683 /* */
684 /* Donation card in view mode */
685 /* */
686 /* ************************************************************ */
687 if (!empty($id) && $action != 'edit') {
688  $formconfirm = "";
689  // Confirmation delete
690  if ($action == 'delete') {
691  $text = $langs->trans("ConfirmDeleteADonation");
692  print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("DeleteADonation"), $text, "confirm_delete", '', '', 1);
693  }
694 
695  $result = $object->fetch($id);
696  if ($result < 0) {
697  dol_print_error($db, $object->error); exit;
698  }
699  $result = $object->fetch_optionals();
700  if ($result < 0) {
701  dol_print_error($db); exit;
702  }
703 
704  $hselected = 'card';
705 
706  $head = donation_prepare_head($object);
707  print dol_get_fiche_head($head, $hselected, $langs->trans("Donation"), -1, 'donation');
708 
709  // Print form confirm
710  print $formconfirm;
711 
712  $linkback = '<a href="'.DOL_URL_ROOT.'/don/list.php'.(!empty($socid) ? '?socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
713 
714  $morehtmlref = '<div class="refidno">';
715  // Project
716  if (isModEnabled('project')) {
717  $langs->load("projects");
718  $morehtmlref .= $langs->trans('Project').' ';
719  if ($user->rights->don->creer) {
720  if ($action != 'classify') {
721  $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
722  }
723  if ($action == 'classify') {
724  //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
725  $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
726  $morehtmlref .= '<input type="hidden" name="action" value="classin">';
727  $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
728  $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1, 0, 'maxwidth500');
729  $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
730  $morehtmlref .= '</form>';
731  } else {
732  $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
733  }
734  } else {
735  if (!empty($object->fk_project)) {
736  $proj = new Project($db);
737  $proj->fetch($object->fk_project);
738  $morehtmlref .= ' : '.$proj->getNomUrl(1);
739  if ($proj->title) {
740  $morehtmlref .= ' - '.$proj->title;
741  }
742  } else {
743  $morehtmlref .= '';
744  }
745  }
746  }
747  $morehtmlref .= '</div>';
748 
749 
750  dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref);
751 
752 
753  print '<div class="fichecenter">';
754  print '<div class="fichehalfleft">';
755  print '<div class="underbanner clearboth"></div>';
756 
757  print '<table class="border tableforfield" width="100%">';
758 
759  // Date
760  print '<tr><td class="titlefield">'.$langs->trans("Date").'</td><td colspan="2">';
761  print dol_print_date($object->date, "day");
762  print "</td>";
763 
764  print '<tr><td>'.$langs->trans("Amount").'</td><td colspan="2">';
765  print price($object->amount, 0, $langs, 0, 0, -1, $conf->currency);
766  print '</td></tr>';
767 
768  print '<tr><td>'.$langs->trans("PublicDonation").'</td><td colspan="2">';
769  print yn($object->public);
770  print '</td></tr>';
771 
772  if (isModEnabled("societe") && !empty($conf->global->DONATION_USE_THIRDPARTIES)) {
773  $company = new Societe($db);
774 
775  print '<tr><td>'.$langs->trans("ThirdParty").'</td><td colspan="2">';
776  if ($object->socid > 0) {
777  $result = $company->fetch($object->socid);
778  print $company->getNomUrl(1);
779  }
780  print '</td></tr>';
781  } else {
782  print '<tr><td>'.$langs->trans("Company").'</td><td colspan="2">'.$object->societe.'</td></tr>';
783  print '<tr><td>'.$langs->trans("Lastname").'</td><td colspan="2">'.$object->lastname.'</td></tr>';
784  print '<tr><td>'.$langs->trans("Firstname").'</td><td colspan="2">'.$object->firstname.'</td></tr>';
785  }
786 
787  // Payment mode
788  print "<tr><td>".$langs->trans("PaymentMode")."</td><td>";
789  $form->form_modes_reglement(null, $object->mode_reglement_id, 'none');
790  print "</td></tr>\n";
791 
792  // Other attributes
793  $cols = 2;
794  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
795 
796  print '</table>';
797 
798  print '</div>';
799  print '<div class="fichehalfright">';
800 
801  /*
802  * Payments
803  */
804  $sql = "SELECT p.rowid, p.num_payment, p.datep as dp, p.amount,";
805  $sql .= "c.code as type_code,c.libelle as paiement_type";
806  $sql .= " FROM ".MAIN_DB_PREFIX."payment_donation as p";
807  $sql .= ", ".MAIN_DB_PREFIX."c_paiement as c ";
808  $sql .= ", ".MAIN_DB_PREFIX."don as d";
809  $sql .= " WHERE d.rowid = ".((int) $id);
810  $sql .= " AND p.fk_donation = d.rowid";
811  $sql .= " AND d.entity IN (".getEntity('donation').")";
812  $sql .= " AND p.fk_typepayment = c.id";
813  $sql .= " ORDER BY dp";
814 
815  //print $sql;
816  $resql = $db->query($sql);
817  if ($resql) {
818  $num = $db->num_rows($resql);
819  $i = 0; $total = 0; $totalpaid = 0;
820  print '<table class="noborder paymenttable centpercent">';
821  print '<tr class="liste_titre">';
822  print '<td>'.$langs->trans("RefPayment").'</td>';
823  print '<td>'.$langs->trans("Date").'</td>';
824  print '<td>'.$langs->trans("Type").'</td>';
825  print '<td class="right">'.$langs->trans("Amount").'</td>';
826  print '</tr>';
827 
828  while ($i < $num) {
829  $objp = $db->fetch_object($resql);
830 
831  print '<tr class="oddeven"><td>';
832  print '<a href="'.DOL_URL_ROOT.'/don/payment/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"), "payment").' '.$objp->rowid.'</a></td>';
833  print '<td>'.dol_print_date($db->jdate($objp->dp), 'day')."</td>\n";
834  $labeltype = $langs->trans("PaymentType".$objp->type_code) != ("PaymentType".$objp->type_code) ? $langs->trans("PaymentType".$objp->type_code) : $objp->paiement_type;
835  print "<td>".$labeltype.' '.$objp->num_payment."</td>\n";
836  print '<td class="right">'.price($objp->amount)."</td>\n";
837  print "</tr>";
838  $totalpaid += $objp->amount;
839  $i++;
840  }
841 
842  if ($object->paid == 0) {
843  print "<tr><td colspan=\"3\" class=\"right\">".$langs->trans("AlreadyPaid")." :</td><td class=\"right\">".price($totalpaid)."</td></tr>\n";
844  print "<tr><td colspan=\"3\" class=\"right\">".$langs->trans("AmountExpected")." :</td><td class=\"right\">".price($object->amount)."</td></tr>\n";
845 
846  $remaintopay = $object->amount - $totalpaid;
847 
848  print "<tr><td colspan=\"3\" class=\"right\">".$langs->trans("RemainderToPay")." :</td>";
849  print '<td class="right'.(!empty($resteapayeraffiche) ? ' amountremaintopay' : '').'">'.price($remaintopay)."</td></tr>\n";
850  }
851  print "</table>";
852  $db->free($resql);
853  } else {
854  dol_print_error($db);
855  }
856 
857  print '</div>';
858  print '</div>';
859 
860  print '<div class="clearboth"></div>';
861 
862  print dol_get_fiche_end();
863 
864  $remaintopay = $object->amount - $totalpaid;
865 
866  // Actions buttons
867 
868  print '<div class="tabsAction">';
869 
870  // Re-open
871  if ($permissiontoadd && $object->statut == $object::STATUS_CANCELED) {
872  print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_reopen&confirm=yes&token='.newToken().'">'.$langs->trans("ReOpen").'</a>';
873  }
874 
875  print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&rowid='.$object->id.'">'.$langs->trans('Modify').'</a></div>';
876 
877  if ($object->statut == $object::STATUS_DRAFT) {
878  print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=valid_promesse&token='.newToken().'">'.$langs->trans("ValidPromess").'</a></div>';
879  }
880 
881  if (($object->statut == $object::STATUS_DRAFT || $object->statut == $object::STATUS_VALIDATED) && $totalpaid == 0 && $object->paid == 0) {
882  print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=set_cancel&token='.newToken().'">'.$langs->trans("ClassifyCanceled")."</a></div>";
883  }
884 
885  // Create payment
886  if ($object->statut == $object::STATUS_VALIDATED && $object->paid == 0 && $user->rights->don->creer) {
887  if ($remaintopay == 0) {
888  print '<div class="inline-block divButAction"><span class="butActionRefused classfortooltip" title="'.$langs->trans("DisabledBecauseRemainderToPayIsZero").'">'.$langs->trans('DoPayment').'</span></div>';
889  } else {
890  print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/don/payment/payment.php?rowid='.$object->id.'&action=create&token='.newToken().'">'.$langs->trans('DoPayment').'</a></div>';
891  }
892  }
893 
894  // Classify 'paid'
895  if ($object->statut == $object::STATUS_VALIDATED && round($remaintopay) == 0 && $object->paid == 0 && $user->rights->don->creer) {
896  print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=set_paid&token='.newToken().'">'.$langs->trans("ClassifyPaid")."</a></div>";
897  }
898 
899  // Delete
900  if ($user->rights->don->supprimer) {
901  if ($object->statut == $object::STATUS_CANCELED || $object->statut == $object::STATUS_DRAFT) {
902  print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?rowid='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans("Delete")."</a></div>";
903  } else {
904  print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans("Delete")."</a></div>";
905  }
906  } else {
907  print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans("Delete")."</a></div>";
908  }
909 
910  print "</div>";
911 
912 
913  print '<div class="fichecenter"><div class="fichehalfleft">';
914 
915  /*
916  * Generated documents
917  */
918  $filename = dol_sanitizeFileName($object->id);
919  $filedir = $conf->don->dir_output."/".dol_sanitizeFileName($object->id);
920  $urlsource = $_SERVER['PHP_SELF'].'?rowid='.$object->id;
921  $genallowed = (($object->paid == 0 || $user->admin) && $user->rights->don->lire);
922  $delallowed = $user->rights->don->creer;
923 
924  print $formfile->showdocuments('donation', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf);
925 
926  // Show links to link elements
927  $linktoelem = $form->showLinkToObjectBlock($object, null, array('don'));
928  $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
929 
930  // Show online payment link
931  $useonlinepayment = (isModEnabled('paypal') || isModEnabled('stripe') || isModEnabled('paybox'));
932 
933  if ($useonlinepayment) { //$object->statut != Facture::STATUS_DRAFT &&
934  print '<br><!-- Link to pay -->'."\n";
935  require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
936  print showOnlinePaymentUrl('donation', $object->ref).'<br>';
937  }
938 
939  print '</div><div class="fichehalfright">';
940 
941  print '</div></div>';
942 }
943 
944 llxFooter();
945 $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 donations.
Definition: don.class.php:39
Class to manage standard extra fields.
Class to build HTML component for third parties management Only common components are here.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class to manage building of HTML components.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
$parameters
Actions.
Definition: card.php:79
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
donation_prepare_head($object)
Prepare array with list of tabs.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int 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)
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.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$formconfirm
if ($action == 'delbookkeepingyear') {
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.