dolibarr 24.0.0-beta
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 * Copyright (C) 2025-2026 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
32{
33 global $langs, $conf, $extrafields;
34
35 $extrafields->fetch_name_optionals_label('don');
36
37 $h = 0;
38 $head = array();
39
40 $head[$h][0] = dolBuildUrl(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] = dolBuildUrl(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] = dolBuildUrl(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] = dolBuildUrl(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] = dolBuildUrl(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] = dolBuildUrl(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] = dolBuildUrl(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(! $sortfield) if(! $sortorder) $object
Definition account.php:100
donation_prepare_head($object)
Prepare array with list of tabs.
donation_admin_prepare_head()
Prepare array with list of admin tabs.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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:64
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
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).