dolibarr  16.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  *
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;
32 
33  $h = 0;
34  $head = array();
35 
36  $head[$h][0] = DOL_URL_ROOT.'/don/admin/donation.php';
37  $head[$h][1] = $langs->trans("Miscellaneous");
38  $head[$h][2] = 'general';
39  $h++;
40 
41  // Show more tabs from modules
42  // Entries must be declared in modules descriptor with line
43  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
44  // $this->tabs = array('entity:-tabname); to remove a tab
45  complete_head_from_modules($conf, $langs, null, $head, $h, 'donation_admin');
46 
47  $head[$h][0] = DOL_URL_ROOT.'/don/admin/donation_extrafields.php';
48  $head[$h][1] = $langs->trans("ExtraFields");
49  $head[$h][2] = 'attributes';
50  $h++;
51 
52  complete_head_from_modules($conf, $langs, null, $head, $h, 'donation_admin', 'remove');
53 
54  return $head;
55 }
56 
63 function donation_prepare_head($object)
64 {
65  global $db, $langs, $conf;
66 
67  $h = 0;
68  $head = array();
69 
70  $head[$h][0] = DOL_URL_ROOT.'/don/card.php?id='.$object->id;
71  $head[$h][1] = $langs->trans("Donation");
72  $head[$h][2] = 'card';
73  $h++;
74 
75  // Show more tabs from modules
76  // Entries must be declared in modules descriptor with line
77  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
78  // $this->tabs = array('entity:-tabname); to remove a tab
79  complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation');
80 
81  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
82  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
83  $upload_dir = $conf->don->dir_output.'/'.dol_sanitizeFileName($object->ref);
84  $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
85  $nbLinks = Link::count($db, $object->element, $object->id);
86  $head[$h][0] = DOL_URL_ROOT.'/don/document.php?id='.$object->id;
87  $head[$h][1] = $langs->trans('Documents');
88  if (($nbFiles + $nbLinks) > 0) {
89  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
90  }
91  $head[$h][2] = 'documents';
92  $h++;
93 
94  $nbNote = 0;
95  if (!empty($object->note_private)) {
96  $nbNote++;
97  }
98  if (!empty($object->note_public)) {
99  $nbNote++;
100  }
101  $head[$h][0] = DOL_URL_ROOT.'/don/note.php?id='.$object->id;
102  $head[$h][1] = $langs->trans("Notes");
103  if ($nbNote > 0) {
104  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
105  }
106  $head[$h][2] = 'note';
107  $h++;
108 
109  $head[$h][0] = DOL_URL_ROOT.'/don/info.php?id='.$object->id;
110  $head[$h][1] = $langs->trans("Info");
111  $head[$h][2] = 'info';
112  $h++;
113 
114  complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation', 'remove');
115 
116  return $head;
117 }
donation_admin_prepare_head
donation_admin_prepare_head()
Prepare array with list of admin tabs.
Definition: donation.lib.php:29
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1226
donation_prepare_head
donation_prepare_head($object)
Prepare array with list of tabs.
Definition: donation.lib.php:63
dol_dir_list
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
Definition: files.lib.php:60
complete_head_from_modules
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add')
Complete or removed entries into a head array (used to build tabs).
Definition: functions.lib.php:9038