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