dolibarr 21.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 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26// Load Dolibarr environment
27require '../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
29require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
32require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
33require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php';
34require_once DOL_DOCUMENT_ROOT.'/partnership/lib/partnership.lib.php';
35
36// Load translation files required by the page
37$langs->loadLangs(array("companies","members","partnership", "other"));
38
39// Get parameters
40$id = GETPOSTINT('rowid') ? GETPOSTINT('rowid') : GETPOSTINT('id');
41$ref = GETPOST('ref', 'alpha');
42$action = GETPOST('action', 'aZ09');
43$confirm = GETPOST('confirm', 'alpha');
44$cancel = GETPOST('cancel', 'aZ09');
45$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'partnershipcard'; // To manage different context of search
46$backtopage = GETPOST('backtopage', 'alpha');
47$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
48//$lineid = GETPOST('lineid', 'int');
49
50$object = new Adherent($db);
51if ($id > 0) {
52 $object->fetch($id);
53}
54
55// Initialize a technical objects
56$object = new Partnership($db);
57$extrafields = new ExtraFields($db);
58$adht = new AdherentType($db);
59$diroutputmassaction = $conf->partnership->dir_output.'/temp/massgeneration/'.$user->id;
60$hookmanager->initHooks(array('partnershipthirdparty', 'globalcard')); // Note that conf->hooks_modules contains array
61
62// Fetch optionals attributes and labels
63$extrafields->fetch_name_optionals_label($object->table_element);
64
65$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
66
67// Initialize array of search criteria
68$search_all = GETPOST("search_all", 'alpha');
69$search = array();
70
71foreach ($object->fields as $key => $val) {
72 if (GETPOST('search_'.$key, 'alpha')) {
73 $search[$key] = GETPOST('search_'.$key, 'alpha');
74 }
75}
76
77// Load object
78include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'.
79
80$permissiontoread = $user->hasRight('partnership', 'read');
81$permissiontoadd = $user->hasRight('partnership', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
82$permissiontodelete = $user->hasRight('partnership', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
83$permissionnote = $user->hasRight('partnership', 'write'); // Used by the include of actions_setnotes.inc.php
84$permissiondellink = $user->hasRight('partnership', 'write'); // Used by the include of actions_dellink.inc.php
85$usercanclose = $user->hasRight('partnership', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
86$upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1];
87
88
89if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') != 'member') {
90 accessforbidden('Partnership module is not activated for members');
91}
92if (!isModEnabled('partnership')) {
94}
95if (empty($permissiontoread)) {
97}
98if ($action == 'edit' && empty($permissiontoadd)) {
100}
101if (($action == 'update' || $action == 'edit') && $object->status != $object::STATUS_DRAFT) {
103}
104
105
106// Security check
107$result = restrictedArea($user, 'adherent', $id, '', '', 'socid', 'rowid', 0);
108
109
110/*
111 * Actions
112 */
113
114$parameters = array();
115$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
116if ($reshook < 0) {
117 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
118}
119
120$date_start = dol_mktime(0, 0, 0, GETPOSTINT('date_partnership_startmonth'), GETPOSTINT('date_partnership_startday'), GETPOSTINT('date_partnership_startyear'));
121$date_end = dol_mktime(0, 0, 0, GETPOSTINT('date_partnership_endmonth'), GETPOSTINT('date_partnership_endday'), GETPOSTINT('date_partnership_endyear'));
122
123if (empty($reshook)) {
124 $error = 0;
125
126 $backtopage = dol_buildpath('/partnership/partnership.php', 1).'?rowid='.($id > 0 ? $id : '__ID__');
127
128 // Actions when linking object each other
129 include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
130}
131
132$object->fields['fk_member']['visible'] = 0;
133if ($object->id > 0 && $object->status == $object::STATUS_REFUSED && empty($action)) {
134 $object->fields['reason_decline_or_cancel']['visible'] = 1;
135}
136$object->fields['note_public']['visible'] = 1;
137
138
139/*
140 * View
141 */
142
143$form = new Form($db);
144$formfile = new FormFile($db);
145
146$title = $langs->trans("Partnership");
147$help_url = "EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros|DE:Modul_Mitglieder";
148
149llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-member page-card_partnership');
150
151$form = new Form($db);
152
153if ($id > 0) {
154 $langs->load("members");
155
156 $object = new Adherent($db);
157 $result = $object->fetch($id);
158
159 if (isModEnabled('notification')) {
160 $langs->load("mails");
161 }
162
163 $adht->fetch($object->typeid);
164
165 $head = member_prepare_head($object);
166
167 print dol_get_fiche_head($head, 'partnership', $langs->trans("ThirdParty"), -1, 'user');
168
169 $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
170
171 dol_banner_tab($object, 'rowid', $linkback);
172
173 print '<div class="fichecenter">';
174
175 print '<div class="underbanner clearboth"></div>';
176 print '<table class="border centpercent tableforfield">';
177
178 // Login
179 if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
180 print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$object->login.'&nbsp;</td></tr>';
181 }
182
183 // Type
184 print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td class="valeur">'.$adht->getNomUrl(1)."</td></tr>\n";
185
186 // Morphy
187 print '<tr><td>'.$langs->trans("MemberNature").'</td><td class="valeur" >'.$object->getmorphylib().'</td>';
188 print '</tr>';
189
190 // Company
191 print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->company.'</td></tr>';
192
193 // Civility
194 print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'&nbsp;</td>';
195 print '</tr>';
196
197 print '</table>';
198
199 print '</div>';
200
201 print dol_get_fiche_end();
202} else {
203 dol_print_error(null, 'Parameter rowid not defined');
204}
205
206
207// Part to show record
208if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
209 // Buttons for actions
210
211 if ($action != 'presend') {
212 print '<div class="tabsAction">'."\n";
213 $parameters = array();
214 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
215 if ($reshook < 0) {
216 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
217 }
218
219 if (empty($reshook)) {
220 // Show
221 if ($permissiontoadd) {
222 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);
223 }
224 }
225 print '</div>'."\n";
226 }
227
228
229 //$morehtmlright = 'partnership/partnership_card.php?action=create&backtopage=%2Fdolibarr%2Fhtdocs%2Fpartnership%2Fpartnership_list.php';
230 $morehtmlright = '';
231
232 print load_fiche_titre($langs->trans("PartnershipDedicatedToThisMember", $langs->transnoentitiesnoconv("Partnership")), $morehtmlright, '');
233
234 $memberid = $object->id;
235
236
237 // TODO Replace this card with the list of all partnerships.
238
239 $object = new Partnership($db);
240 $partnershipid = $object->fetch(0, "", $memberid);
241
242 if ($partnershipid > 0) {
243 print '<div class="fichecenter">';
244 print '<div class="fichehalfleft">';
245 print '<div class="underbanner clearboth"></div>';
246 print '<table class="border centpercent tableforfield">'."\n";
247
248 // Common attributes
249 //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field
250 //unset($object->fields['fk_project']); // Hide field already shown in banner
251 //unset($object->fields['fk_member']); // Hide field already shown in banner
252 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
253
254 // End of subscription date
255 $fadherent = new Adherent($db);
256 $fadherent->fetch($object->fk_member);
257 print '<tr><td>'.$langs->trans("SubscriptionEndDate").'</td><td class="valeur">';
258 if ($fadherent->datefin) {
259 print dol_print_date($fadherent->datefin, 'day');
260 if ($fadherent->hasDelay()) {
261 print " ".img_warning($langs->trans("Late"));
262 }
263 } else {
264 if (!$adht->subscription) {
265 print $langs->trans("SubscriptionNotRecorded");
266 if ($fadherent->statut > 0) {
267 print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled
268 }
269 } else {
270 print $langs->trans("SubscriptionNotReceived");
271 if ($fadherent->statut > 0) {
272 print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled
273 }
274 }
275 }
276 print '</td></tr>';
277
278 print '</table>';
279 print '</div>';
280 }
281}
282
283// End of page
284llxFooter();
285$db->close();
$id
Definition account.php:39
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
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:70
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.
llxFooter()
Footer empty.
Definition document.php:107
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.
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.