dolibarr 25.0.0-alpha
partnership.php
1<?php
2/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2021 NextGestion <contact@nextgestion.com>
4 * Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
5 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27// Load Dolibarr environment
28require '../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
38require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
39require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
40require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
41require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
42require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php';
43require_once DOL_DOCUMENT_ROOT.'/partnership/lib/partnership.lib.php';
44
45
46// Load translation files required by the page
47$langs->loadLangs(array("companies","members","partnership", "other"));
48
49// Get parameters
50$id = GETPOSTINT('rowid') ? GETPOSTINT('rowid') : GETPOSTINT('id');
51$ref = GETPOST('ref', 'alpha');
52$action = GETPOST('action', 'aZ09');
53$confirm = GETPOST('confirm', 'alpha');
54$cancel = GETPOST('cancel', 'alpha');
55$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'partnershipcard'; // To manage different context of search
56$backtopage = GETPOST('backtopage', 'alpha');
57$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
58//$lineid = GETPOST('lineid', 'int');
59
60$object = new Adherent($db);
61if ($id > 0) {
62 $object->fetch($id);
63}
64
65// Initialize a technical objects
66$object = new Partnership($db);
67$adht = new AdherentType($db);
68$diroutputmassaction = $conf->partnership->dir_output.'/temp/massgeneration/'.$user->id;
69$hookmanager->initHooks(array('partnershipthirdparty', 'globalcard')); // Note that conf->hooks_modules contains array
70
71// Fetch optionals attributes and labels
72$extrafields->fetch_name_optionals_label($object->table_element);
73
74$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
75
76// Initialize array of search criteria
77$search_all = GETPOST("search_all", 'alpha');
78$search = array();
79
80foreach ($object->fields as $key => $val) {
81 if (GETPOST('search_'.$key, 'alpha')) {
82 $search[$key] = GETPOST('search_'.$key, 'alpha');
83 }
84}
85
86// Load object
87include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'.
88
89$permissiontoread = $user->hasRight('partnership', 'read');
90$permissiontoadd = $user->hasRight('partnership', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
91$permissiontodelete = $user->hasRight('partnership', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
92$permissionnote = $user->hasRight('partnership', 'write'); // Used by the include of actions_setnotes.inc.php
93$permissiondellink = $user->hasRight('partnership', 'write'); // Used by the include of actions_dellink.inc.php
94$usercanclose = $user->hasRight('partnership', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
95$upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1];
96
97
98if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') != 'member') {
99 accessforbidden('Partnership module is not activated for members');
100}
101if (!isModEnabled('partnership')) {
103}
104if (empty($permissiontoread)) {
106}
107if ($action == 'edit' && empty($permissiontoadd)) {
109}
110if (($action == 'update' || $action == 'edit') && $object->status != $object::STATUS_DRAFT) {
112}
113
114
115// Security check
116restrictedArea($user, 'adherent', $id, '', '', 'socid', 'rowid', 0);
117
118
119/*
120 * Actions
121 */
122
123$parameters = array();
124$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
125if ($reshook < 0) {
126 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
127}
128
129$date_start = dol_mktime(0, 0, 0, GETPOSTINT('date_partnership_startmonth'), GETPOSTINT('date_partnership_startday'), GETPOSTINT('date_partnership_startyear'));
130$date_end = dol_mktime(0, 0, 0, GETPOSTINT('date_partnership_endmonth'), GETPOSTINT('date_partnership_endday'), GETPOSTINT('date_partnership_endyear'));
131
132if (empty($reshook)) {
133 $error = 0;
134
135 $backtopage = dol_buildpath('/partnership/partnership.php', 1).'?rowid='.($id > 0 ? $id : '__ID__');
136
137 // Actions when linking object each other
138 include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
139}
140
141$object->fields['fk_member']['visible'] = 0;
142if ($object->id > 0 && $object->status == $object::STATUS_REFUSED && empty($action)) {
143 $object->fields['reason_decline_or_cancel']['visible'] = 1;
144}
145$object->fields['note_public']['visible'] = 1;
146
147
148/*
149 * View
150 */
151
152$form = new Form($db);
153$formfile = new FormFile($db);
154
155$title = $langs->trans("Partnership");
156$help_url = "EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros|DE:Modul_Mitglieder";
157
158llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-member page-card_partnership');
159
160$form = new Form($db);
161
162if ($id > 0) {
163 $langs->load("members");
164
165 $object = new Adherent($db);
166 $result = $object->fetch($id);
167
168 if (isModEnabled('notification')) {
169 $langs->load("mails");
170 }
171
172 $adht->fetch($object->typeid);
173
174 $head = member_prepare_head($object);
175
176 print dol_get_fiche_head($head, 'partnership', $langs->trans("ThirdParty"), -1, 'user');
177
178 $linkback = '<a href="'.dolBuildUrl(DOL_URL_ROOT.'/adherents/list.php', ['restore_lastsearch_values' => 1]).'">'.$langs->trans("BackToList").'</a>';
179
180 dol_banner_tab($object, 'rowid', $linkback);
181
182 print '<div class="fichecenter">';
183
184 print '<div class="underbanner clearboth"></div>';
185 print '<table class="border centpercent tableforfield">';
186
187 // Login
188 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
189 print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$object->login.'&nbsp;</td></tr>';
190 }
191
192 // Type
193 print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td class="valeur">'.$adht->getNomUrl(1)."</td></tr>\n";
194
195 // Morphy
196 print '<tr><td>'.$langs->trans("MemberNature").'</td><td class="valeur" >'.$object->getmorphylib().'</td>';
197 print '</tr>';
198
199 // Company
200 print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->company.'</td></tr>';
201
202 // Civility
203 print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'&nbsp;</td>';
204 print '</tr>';
205
206 print '</table>';
207
208 print '</div>';
209
210 print dol_get_fiche_end();
211} else {
212 dol_print_error(null, 'Parameter rowid not defined');
213}
214
215
216// Part to show record
217if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
218 // Buttons for actions
219
220 if ($action != 'presend') {
221 print '<div class="tabsAction">'."\n";
222 $parameters = array();
223 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
224 if ($reshook < 0) {
225 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
226 }
227
228 if (empty($reshook)) {
229 // Show
230 if ($permissiontoadd) {
231 print dolGetButtonAction($langs->trans('AddPartnership'), '', 'default', DOL_URL_ROOT.'/partnership/partnership_card.php?action=create&fk_member='.$object->id.'&backtopage='.urlencode(DOL_URL_ROOT.'/adherents/partnership.php?id='.$object->id), '', $permissiontoadd);
232 }
233 }
234 print '</div>'."\n";
235 }
236
237
238 //$morehtmlright = 'partnership/partnership_card.php?action=create&backtopage=%2Fdolibarr%2Fhtdocs%2Fpartnership%2Fpartnership_list.php';
239 $morehtmlright = '';
240
241 print load_fiche_titre($langs->trans("PartnershipDedicatedToThisMember", $langs->transnoentitiesnoconv("Partnership")), $morehtmlright, '');
242
243 $memberid = $object->id;
244
245
246 // TODO Replace this card with the list of all partnerships.
247
248 $object = new Partnership($db);
249 $partnershipid = $object->fetch(0, "", $memberid);
250
251 if ($partnershipid > 0) {
252 print '<div class="fichecenter">';
253 print '<div class="fichehalfleft">';
254 print '<div class="underbanner clearboth"></div>';
255 print '<table class="border centpercent tableforfield">'."\n";
256
257 // Common attributes
258 //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field
259 //unset($object->fields['fk_project']); // Hide field already shown in banner
260 //unset($object->fields['fk_member']); // Hide field already shown in banner
261 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
262
263 // End of subscription date
264 $fadherent = new Adherent($db);
265 $fadherent->fetch($object->fk_member);
266 print '<tr><td>'.$langs->trans("SubscriptionEndDate").'</td><td class="valeur">';
267 if ($fadherent->datefin) {
268 print dol_print_date($fadherent->datefin, 'day');
269 if ($fadherent->hasDelay()) {
270 print " ".img_warning($langs->trans("Late"));
271 }
272 } else {
273 if (!$adht->subscription) {
274 print $langs->trans("SubscriptionNotRecorded");
275 if ($fadherent->status > 0) {
276 print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled
277 }
278 } else {
279 print $langs->trans("SubscriptionNotReceived");
280 if ($fadherent->status > 0) {
281 print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled
282 }
283 }
284 }
285 print '</td></tr>';
286
287 print '</table>';
288 print '</div>';
289 }
290}
291
292// End of page
293llxFooter();
294$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage members of a foundation.
Class to manage members type.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class for Partnership.
$date_start
Variables from include:
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
Definition html.lib.php:542
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition html.lib.php:740
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
member_prepare_head(Adherent $object)
Return array head with list of tabs to view object information.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.