dolibarr 23.0.3
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 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, $db;
34
35 $extrafields = new ExtraFields($db);
36 $extrafields->fetch_name_optionals_label('don');
37
38 $h = 0;
39 $head = array();
40
41 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/don/admin/donation.php');
42 $head[$h][1] = $langs->trans("Miscellaneous");
43 $head[$h][2] = 'general';
44 $h++;
45
46 // Show more tabs from modules
47 // Entries must be declared in modules descriptor with line
48 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
49 // $this->tabs = array('entity:-tabname); to remove a tab
50 complete_head_from_modules($conf, $langs, null, $head, $h, 'donation_admin');
51
52 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/don/admin/donation_extrafields.php');
53 $head[$h][1] = $langs->trans("ExtraFields");
54 $nbExtrafields = $extrafields->attributes['don']['count'];
55 if ($nbExtrafields > 0) {
56 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
57 }
58 $head[$h][2] = 'attributes';
59 $h++;
60
61 complete_head_from_modules($conf, $langs, null, $head, $h, 'donation_admin', 'remove');
62
63 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/don/admin/website.php');
64 $head[$h][1] = $langs->trans("BlankSubscriptionForm");
65 $head[$h][2] = 'website';
66 $h++;
67
68 complete_head_from_modules($conf, $langs, null, $head, $h, 'donation_admin', 'remove');
69
70 return $head;
71}
72
80{
81 global $db, $langs, $conf;
82
83 $h = 0;
84 $head = array();
85
86 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/don/card.php', ['id' => $object->id]);
87 $head[$h][1] = $langs->trans("Donation");
88 $head[$h][2] = 'card';
89 $h++;
90
91 // Show more tabs from modules
92 // Entries must be declared in modules descriptor with line
93 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
94 // $this->tabs = array('entity:-tabname); to remove a tab
95 complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation', 'add', 'core');
96
97 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
98 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
99 $upload_dir = $conf->don->dir_output.'/'.dol_sanitizeFileName($object->ref);
100 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
101 $nbLinks = Link::count($db, $object->element, $object->id);
102 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/don/document.php', ['id' => $object->id]);
103 $head[$h][1] = $langs->trans('Documents');
104 if (($nbFiles + $nbLinks) > 0) {
105 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
106 }
107 $head[$h][2] = 'documents';
108 $h++;
109
110 $nbNote = 0;
111 if (!empty($object->note_private)) {
112 $nbNote++;
113 }
114 if (!empty($object->note_public)) {
115 $nbNote++;
116 }
117 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/don/note.php', ['id' => $object->id]);
118 $head[$h][1] = $langs->trans("Notes");
119 if ($nbNote > 0) {
120 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
121 }
122 $head[$h][2] = 'note';
123 $h++;
124
125 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/don/info.php', ['id' => $object->id]);
126 $head[$h][1] = $langs->trans("Info");
127 $head[$h][2] = 'info';
128 $h++;
129
130 complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation', 'add', 'external');
131
132 complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation', 'remove');
133
134 return $head;
135}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
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:64
dolBuildUrl($url, $params=[], $addtoken=false)
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).