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