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 18/** 19 * \file htdocs/core/lib/donation.lib.php 20 * \ingroup Donation 21 * \brief Library of donation functions 22 */ 23 24/** 25 * Prepare array with list of admin tabs 26 * 27 * @return array Array of tabs to show 28 */ 29function donation_admin_prepare_head() 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 57/** 58 * Prepare array with list of tabs 59 * 60 * @param Don $object Donation 61 * @return array Array of tabs to show 62 */ 63function 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) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($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 marginleftonlyshort">'.$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} 110