dolibarr 19.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 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
30{
31 global $langs, $conf, $db;
32
33 $extrafields = new ExtraFields($db);
34 $extrafields->fetch_name_optionals_label('don');
35
36 $h = 0;
37 $head = array();
38
39 $head[$h][0] = DOL_URL_ROOT.'/don/admin/donation.php';
40 $head[$h][1] = $langs->trans("Miscellaneous");
41 $head[$h][2] = 'general';
42 $h++;
43
44 // Show more tabs from modules
45 // Entries must be declared in modules descriptor with line
46 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
47 // $this->tabs = array('entity:-tabname); to remove a tab
48 complete_head_from_modules($conf, $langs, null, $head, $h, 'donation_admin');
49
50 $head[$h][0] = DOL_URL_ROOT.'/don/admin/donation_extrafields.php';
51 $head[$h][1] = $langs->trans("ExtraFields");
52 $nbExtrafields = $extrafields->attributes['don']['count'];
53 if ($nbExtrafields > 0) {
54 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbExtrafields.'</span>';
55 }
56 $head[$h][2] = 'attributes';
57 $h++;
58
59 complete_head_from_modules($conf, $langs, null, $head, $h, 'donation_admin', 'remove');
60
61 return $head;
62}
63
70function donation_prepare_head($object)
71{
72 global $db, $langs, $conf;
73
74 $h = 0;
75 $head = array();
76
77 $head[$h][0] = DOL_URL_ROOT.'/don/card.php?id='.$object->id;
78 $head[$h][1] = $langs->trans("Donation");
79 $head[$h][2] = 'card';
80 $h++;
81
82 // Show more tabs from modules
83 // Entries must be declared in modules descriptor with line
84 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
85 // $this->tabs = array('entity:-tabname); to remove a tab
86 complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation', 'add', 'core');
87
88 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
89 require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
90 $upload_dir = $conf->don->dir_output.'/'.dol_sanitizeFileName($object->ref);
91 $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
92 $nbLinks = Link::count($db, $object->element, $object->id);
93 $head[$h][0] = DOL_URL_ROOT.'/don/document.php?id='.$object->id;
94 $head[$h][1] = $langs->trans('Documents');
95 if (($nbFiles + $nbLinks) > 0) {
96 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
97 }
98 $head[$h][2] = 'documents';
99 $h++;
100
101 $nbNote = 0;
102 if (!empty($object->note_private)) {
103 $nbNote++;
104 }
105 if (!empty($object->note_public)) {
106 $nbNote++;
107 }
108 $head[$h][0] = DOL_URL_ROOT.'/don/note.php?id='.$object->id;
109 $head[$h][1] = $langs->trans("Notes");
110 if ($nbNote > 0) {
111 $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
112 }
113 $head[$h][2] = 'note';
114 $h++;
115
116 $head[$h][0] = DOL_URL_ROOT.'/don/info.php?id='.$object->id;
117 $head[$h][1] = $langs->trans("Info");
118 $head[$h][2] = 'info';
119 $h++;
120
121 complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation', 'add', 'external');
122
123 complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation', 'remove');
124
125 return $head;
126}
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($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:62
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).