dolibarr 21.0.0-beta
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 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';
29require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
30require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
33require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
34require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php';
35require_once DOL_DOCUMENT_ROOT.'/partnership/lib/partnership.lib.php';
36
45// Load translation files required by the page
46$langs->loadLangs(array("companies","members","partnership", "other"));
47
48// Get parameters
49$id = GETPOSTINT('rowid') ? GETPOSTINT('rowid') : GETPOSTINT('id');
50$ref = GETPOST('ref', 'alpha');
51$action = GETPOST('action', 'aZ09');
52$confirm = GETPOST('confirm', 'alpha');
53$cancel = GETPOST('cancel', 'aZ09');
54$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'partnershipcard'; // To manage different context of search
55$backtopage = GETPOST('backtopage', 'alpha');
56$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
57//$lineid = GETPOST('lineid', 'int');
58
59$object = new Adherent($db);
60if ($id > 0) {
61 $object->fetch($id);
62}
63
64// Initialize a technical objects
65$object = new Partnership($db);
66$extrafields = new ExtraFields($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
116$result = restrictedArea($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="'.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->statut > 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->statut > 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
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:87
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:71
Class to manage members of a foundation.
Class to manage members type.
Class to manage standard extra fields.
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.
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...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
member_prepare_head(Adherent $object)
Return array head with list of tabs to view object information.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
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.