dolibarr  16.0.5
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;
32 
33  $langs->loadLangs(array("members", "partnership"));
34 
35  $h = 0;
36  $head = array();
37 
38  $head[$h][0] = dol_buildpath("/partnership/admin/setup.php", 1);
39  $head[$h][1] = $langs->trans("Settings");
40  $head[$h][2] = 'settings';
41  $h++;
42 
43 
44  $head[$h][0] = dol_buildpath("/partnership/admin/partnership_extrafields.php", 1);
45  $head[$h][1] = $langs->trans("ExtraFields");
46  $head[$h][2] = 'partnership_extrafields';
47  $h++;
48 
49  $head[$h][0] = dol_buildpath("/partnership/admin/website.php", 1);
50  $head[$h][1] = $langs->trans("BlankSubscriptionForm");
51  $head[$h][2] = 'website';
52  $h++;
53 
54  /*
55  $head[$h][0] = dol_buildpath("/partnership/admin/about.php", 1);
56  $head[$h][1] = $langs->trans("About");
57  $head[$h][2] = 'about';
58  $h++;
59  */
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  return $head;
72 }
73 
80 function partnershipPrepareHead($object)
81 {
82  global $db, $langs, $conf;
83 
84  $langs->load("partnership");
85 
86  $h = 0;
87  $head = array();
88 
89  $head[$h][0] = dol_buildpath("/partnership/partnership_card.php", 1).'?id='.$object->id;
90  $head[$h][1] = $langs->trans("Card");
91  $head[$h][2] = 'card';
92  $h++;
93 
94  if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
95  $nbNote = 0;
96  if (!empty($object->note_private)) {
97  $nbNote++;
98  }
99  if (!empty($object->note_public)) {
100  $nbNote++;
101  }
102  $head[$h][0] = dol_buildpath('/partnership/partnership_note.php', 1).'?id='.$object->id;
103  $head[$h][1] = $langs->trans('Notes');
104  if ($nbNote > 0) {
105  $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '<span class="badge marginleftonlyshort">'.$nbNote.'</span>' : '');
106  }
107  $head[$h][2] = 'note';
108  $h++;
109  }
110 
111  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
112  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
113  $upload_dir = $conf->partnership->dir_output."/partnership/".dol_sanitizeFileName($object->ref);
114  $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
115  $nbLinks = Link::count($db, $object->element, $object->id);
116  $head[$h][0] = dol_buildpath("/partnership/partnership_document.php", 1).'?id='.$object->id;
117  $head[$h][1] = $langs->trans('Documents');
118  if (($nbFiles + $nbLinks) > 0) {
119  $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
120  }
121  $head[$h][2] = 'document';
122  $h++;
123 
124  $head[$h][0] = dol_buildpath("/partnership/partnership_agenda.php", 1).'?id='.$object->id;
125  $head[$h][1] = $langs->trans("Events");
126  $head[$h][2] = 'agenda';
127  $h++;
128 
129  // Show more tabs from modules
130  // Entries must be declared in modules descriptor with line
131  //$this->tabs = array(
132  // 'entity:+tabname:Title:@partnership:/partnership/mypage.php?id=__ID__'
133  //); // to add new tab
134  //$this->tabs = array(
135  // 'entity:-tabname:Title:@partnership:/partnership/mypage.php?id=__ID__'
136  //); // to remove a tab
137  complete_head_from_modules($conf, $langs, $object, $head, $h, 'partnership');
138 
139  complete_head_from_modules($conf, $langs, $object, $head, $h, 'partnership', 'remove');
140 
141  return $head;
142 }
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1226
dol_buildpath
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Definition: functions.lib.php:1062
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
partnershipAdminPrepareHead
partnershipAdminPrepareHead()
Prepare admin pages header.
Definition: partnership.lib.php:29
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
partnershipPrepareHead
partnershipPrepareHead($object)
Prepare array of tabs for Partnership.
Definition: partnership.lib.php:80