dolibarr  7.0.0-beta
donation.lib.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
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 <http://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("Card");
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 . '/' . get_exdir($filename,2,0,1,$object,'donation'). '/'. 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) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
89  $head[$h][2] = 'documents';
90  $h++;
91 
92  $nbNote = 0;
93  if(!empty($object->note_private)) $nbNote++;
94  if(!empty($object->note_public)) $nbNote++;
95  $head[$h][0] = DOL_URL_ROOT.'/don/note.php?id='.$object->id;
96  $head[$h][1] = $langs->trans("Notes");
97  if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
98  $head[$h][2] = 'note';
99  $h++;
100 
101  $head[$h][0] = DOL_URL_ROOT . '/don/info.php?id=' . $object->id;
102  $head[$h][1] = $langs->trans("Info");
103  $head[$h][2] = 'info';
104  $h++;
105 
106  complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation', 'remove');
107 
108  return $head;
109 }
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add')
Complete or removed entries into a head array (used to build tabs).
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart)
Return a path to have a the directory according to object where files are stored. ...
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="")
Scan a directory and return a list of files/directories.
Definition: files.lib.php:58
donation_admin_prepare_head()
Prepare array with list of admin tabs.
donation_prepare_head($object)
Prepare array with list of tabs.