dolibarr 21.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 *
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 return $head;
63}
64
72{
73 global $db, $langs, $conf;
74
75 $h = 0;
76 $head = array();
77
78 $head[$h][0] = DOL_URL_ROOT.'/don/card.php?id='.$object->id;
79 $head[$h][1] = $langs->trans("Donation");
80 $head[$h][2] = 'card';
81 $h++;
82
83 // Show more tabs from modules
84 // Entries must be declared in modules descriptor with line
85 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
86 // $this->tabs = array('entity:-tabname); to remove a tab
87 complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation', 'add', 'core');
88
89 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
90 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
91 $upload_dir = $conf->don->dir_output.'/'.dol_sanitizeFileName($object->ref);
92 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
93 $nbLinks = Link::count($db, $object->element, $object->id);
94 $head[$h][0] = DOL_URL_ROOT.'/don/document.php?id='.$object->id;
95 $head[$h][1] = $langs->trans('Documents');
96 if (($nbFiles + $nbLinks) > 0) {
97 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
98 }
99 $head[$h][2] = 'documents';
100 $h++;
101
102 $nbNote = 0;
103 if (!empty($object->note_private)) {
104 $nbNote++;
105 }
106 if (!empty($object->note_public)) {
107 $nbNote++;
108 }
109 $head[$h][0] = DOL_URL_ROOT.'/don/note.php?id='.$object->id;
110 $head[$h][1] = $langs->trans("Notes");
111 if ($nbNote > 0) {
112 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
113 }
114 $head[$h][2] = 'note';
115 $h++;
116
117 $head[$h][0] = DOL_URL_ROOT.'/don/info.php?id='.$object->id;
118 $head[$h][1] = $langs->trans("Info");
119 $head[$h][2] = 'info';
120 $h++;
121
122 complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation', 'add', 'external');
123
124 complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation', 'remove');
125
126 return $head;
127}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
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
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
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).
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79