dolibarr  20.0.0-beta
partnership.lib.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2021 Dorian Laurent <i.merraha@sofimedmaroc.com>
3  * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
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  $langs->loadLangs(array("members", "partnership"));
35 
36  $extrafields = new ExtraFields($db);
37  $extrafields->fetch_name_optionals_label('partnership');
38 
39  $h = 0;
40  $head = array();
41 
42  $head[$h][0] = DOL_URL_ROOT . '/partnership/admin/setup.php';
43  $head[$h][1] = $langs->trans("Settings");
44  $head[$h][2] = 'settings';
45  $h++;
46 
47 
48  $head[$h][0] = DOL_URL_ROOT . '/partnership/admin/partnership_extrafields.php';
49  $head[$h][1] = $langs->trans("ExtraFields");
50  $nbExtrafields = $extrafields->attributes['partnership']['count'];
51  if ($nbExtrafields > 0) {
52  $head[$h][1] .= '<span class="badge marginleftonlyshort">' . $nbExtrafields . '</span>';
53  }
54  $head[$h][2] = 'partnership_extrafields';
55  $h++;
56 
57  $head[$h][0] = DOL_URL_ROOT . '/partnership/admin/website.php';
58  $head[$h][1] = $langs->trans("BlankSubscriptionForm");
59  $head[$h][2] = 'website';
60  $h++;
61 
62  // Show more tabs from modules
63  // Entries must be declared in modules descriptor with line
64  //$this->tabs = array(
65  // 'entity:+tabname:Title:@partnership:/partnership/mypage.php?id=__ID__'
66  //); // to add new tab
67  //$this->tabs = array(
68  // 'entity:-tabname:Title:@partnership:/partnership/mypage.php?id=__ID__'
69  //); // to remove a tab
70  complete_head_from_modules($conf, $langs, null, $head, $h, 'partnership');
71 
72  complete_head_from_modules($conf, $langs, null, $head, $h, 'partnership', 'remove');
73 
74  return $head;
75 }
76 
84 {
85  global $db, $langs, $conf;
86 
87  $langs->load("partnership");
88 
89  $h = 0;
90  $head = array();
91 
92  $head[$h][0] = DOL_URL_ROOT . '/partnership/partnership_card.php?id=' . $object->id;
93  $head[$h][1] = $langs->trans("Card");
94  $head[$h][2] = 'card';
95  $h++;
96 
97  if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
98  $nbNote = 0;
99  if (!empty($object->note_private)) {
100  $nbNote++;
101  }
102  if (!empty($object->note_public)) {
103  $nbNote++;
104  }
105  $head[$h][0] = DOL_URL_ROOT . '/partnership/partnership_note.php?id=' . $object->id;
106  $head[$h][1] = $langs->trans('Notes');
107  if ($nbNote > 0) {
108  $head[$h][1] .= (!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER') ? '<span class="badge marginleftonlyshort">' . $nbNote . '</span>' : '');
109  }
110  $head[$h][2] = 'note';
111  $h++;
112  }
113 
114  require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
115  require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
116  $upload_dir = $conf->partnership->dir_output . "/partnership/" . dol_sanitizeFileName($object->ref);
117  $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
118  $nbLinks = Link::count($db, $object->element, $object->id);
119  $head[$h][0] = DOL_URL_ROOT . '/partnership/partnership_document.php?id=' . $object->id;
120  $head[$h][1] = $langs->trans('Documents');
121  if (($nbFiles + $nbLinks) > 0) {
122  $head[$h][1] .= '<span class="badge marginleftonlyshort">' . ($nbFiles + $nbLinks) . '</span>';
123  }
124  $head[$h][2] = 'document';
125  $h++;
126 
127  $head[$h][0] = DOL_URL_ROOT . '/partnership/partnership_agenda.php?id=' . $object->id;
128  $head[$h][1] = $langs->trans("Events");
129  $head[$h][2] = 'agenda';
130  $h++;
131 
132  // Show more tabs from modules
133  // Entries must be declared in modules descriptor with line
134  //$this->tabs = array(
135  // 'entity:+tabname:Title:@partnership:/partnership/mypage.php?id=__ID__'
136  //); // to add new tab
137  //$this->tabs = array(
138  // 'entity:-tabname:Title:@partnership:/partnership/mypage.php?id=__ID__'
139  //); // to remove a tab
140  complete_head_from_modules($conf, $langs, $object, $head, $h, 'partnership');
141 
142  complete_head_from_modules($conf, $langs, $object, $head, $h, 'partnership', 'remove');
143 
144  return $head;
145 }
if($user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition: card.php:58
Class to manage standard extra fields.
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).
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
partnershipAdminPrepareHead()
Prepare admin pages header.
partnershipPrepareHead($object)
Prepare array of tabs for Partnership.