dolibarr 22.0.5
donation.lib.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr>
3 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.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
31{
32 global $langs, $conf, $db;
33
34 $extrafields = new ExtraFields($db);
35 $extrafields->fetch_name_optionals_label('don');
36
37 $h = 0;
38 $head = array();
39
40 $head[$h][0] = DOL_URL_ROOT.'/don/admin/donation.php';
41 $head[$h][1] = $langs->trans("Miscellaneous");
42 $head[$h][2] = 'general';
43 $h++;
44
45 // Show more tabs from modules
46 // Entries must be declared in modules descriptor with line
47 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
48 // $this->tabs = array('entity:-tabname); to remove a tab
49 complete_head_from_modules($conf, $langs, null, $head, $h, 'donation_admin');
50
51 $head[$h][0] = DOL_URL_ROOT.'/don/admin/donation_extrafields.php';
52 $head[$h][1] = $langs->trans("ExtraFields");
53 $nbExtrafields = $extrafields->attributes['don']['count'];
54 if ($nbExtrafields > 0) {
55 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
56 }
57 $head[$h][2] = 'attributes';
58 $h++;
59
60 complete_head_from_modules($conf, $langs, null, $head, $h, 'donation_admin', 'remove');
61
62 $head[$h][0] = DOL_URL_ROOT.'/don/admin/website.php';
63 $head[$h][1] = $langs->trans("BlankSubscriptionForm");
64 $head[$h][2] = 'website';
65 $h++;
66
67 complete_head_from_modules($conf, $langs, null, $head, $h, 'donation_admin', 'remove');
68
69 return $head;
70}
71
79{
80 global $db, $langs, $conf;
81
82 $h = 0;
83 $head = array();
84
85 $head[$h][0] = DOL_URL_ROOT.'/don/card.php?id='.$object->id;
86 $head[$h][1] = $langs->trans("Donation");
87 $head[$h][2] = 'card';
88 $h++;
89
90 // Show more tabs from modules
91 // Entries must be declared in modules descriptor with line
92 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
93 // $this->tabs = array('entity:-tabname); to remove a tab
94 complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation', 'add', 'core');
95
96 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
97 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
98 $upload_dir = $conf->don->dir_output.'/'.dol_sanitizeFileName($object->ref);
99 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
100 $nbLinks = Link::count($db, $object->element, $object->id);
101 $head[$h][0] = DOL_URL_ROOT.'/don/document.php?id='.$object->id;
102 $head[$h][1] = $langs->trans('Documents');
103 if (($nbFiles + $nbLinks) > 0) {
104 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
105 }
106 $head[$h][2] = 'documents';
107 $h++;
108
109 $nbNote = 0;
110 if (!empty($object->note_private)) {
111 $nbNote++;
112 }
113 if (!empty($object->note_public)) {
114 $nbNote++;
115 }
116 $head[$h][0] = DOL_URL_ROOT.'/don/note.php?id='.$object->id;
117 $head[$h][1] = $langs->trans("Notes");
118 if ($nbNote > 0) {
119 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
120 }
121 $head[$h][2] = 'note';
122 $h++;
123
124 $head[$h][0] = DOL_URL_ROOT.'/don/info.php?id='.$object->id;
125 $head[$h][1] = $langs->trans("Info");
126 $head[$h][2] = 'info';
127 $h++;
128
129 complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation', 'add', 'external');
130
131 complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation', 'remove');
132
133 return $head;
134}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
Class to manage standard extra fields.
donation_prepare_head($object)
Prepare array with list of tabs.
donation_admin_prepare_head()
Prepare array with list of admin tabs.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:63
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79