dolibarr 18.0.6
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)) $object->fields['reason_decline_or_cancel']['visible'] = 1;
133$object->fields['note_public']['visible'] = 1;
134
135
136/*
137 * View
138 */
139
140$form = new Form($db);
141$formfile = new FormFile($db);
142
143$title = $langs->trans("Partnership");
144llxHeader('', $title);
145
146$form = new Form($db);
147
148if ($id > 0) {
149 $langs->load("members");
150
151 $object = new Adherent($db);
152 $result = $object->fetch($id);
153
154 if (isModEnabled('notification')) {
155 $langs->load("mails");
156 }
157
158 $adht->fetch($object->typeid);
159
160 $head = member_prepare_head($object);
161
162 print dol_get_fiche_head($head, 'partnership', $langs->trans("ThirdParty"), -1, 'user');
163
164 $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
165
166 dol_banner_tab($object, 'rowid', $linkback);
167
168 print '<div class="fichecenter">';
169
170 print '<div class="underbanner clearboth"></div>';
171 print '<table class="border centpercent tableforfield">';
172
173 // Login
174 if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
175 print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$object->login.'&nbsp;</td></tr>';
176 }
177
178 // Type
179 print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td class="valeur">'.$adht->getNomUrl(1)."</td></tr>\n";
180
181 // Morphy
182 print '<tr><td>'.$langs->trans("MemberNature").'</td><td class="valeur" >'.$object->getmorphylib().'</td>';
183 print '</tr>';
184
185 // Company
186 print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->company.'</td></tr>';
187
188 // Civility
189 print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'&nbsp;</td>';
190 print '</tr>';
191
192 print '</table>';
193
194 print '</div>';
195
196 print dol_get_fiche_end();
197} else {
198 dol_print_error('', 'Parameter rowid not defined');
199}
200
201
202// Part to show record
203if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
204 // Buttons for actions
205
206 if ($action != 'presend') {
207 print '<div class="tabsAction">'."\n";
208 $parameters = array();
209 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
210 if ($reshook < 0) {
211 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
212 }
213
214 if (empty($reshook)) {
215 // Show
216 if ($permissiontoadd) {
217 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);
218 }
219 }
220 print '</div>'."\n";
221 }
222
223
224 //$morehtmlright = 'partnership/partnership_card.php?action=create&backtopage=%2Fdolibarr%2Fhtdocs%2Fpartnership%2Fpartnership_list.php';
225 $morehtmlright = '';
226
227 print load_fiche_titre($langs->trans("PartnershipDedicatedToThisMember", $langs->transnoentitiesnoconv("Partnership")), $morehtmlright, '');
228
229 $memberid = $object->id;
230
231
232 // TODO Replace this card with the list of all partnerships.
233
234 $object = new Partnership($db);
235 $partnershipid = $object->fetch(0, "", $memberid);
236
237 if ($partnershipid > 0) {
238 print '<div class="fichecenter">';
239 print '<div class="fichehalfleft">';
240 print '<div class="underbanner clearboth"></div>';
241 print '<table class="border centpercent tableforfield">'."\n";
242
243 // Common attributes
244 //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field
245 //unset($object->fields['fk_project']); // Hide field already shown in banner
246 //unset($object->fields['fk_member']); // Hide field already shown in banner
247 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
248
249 // End of subscription date
250 $fadherent = new Adherent($db);
251 $fadherent->fetch($object->fk_member);
252 print '<tr><td>'.$langs->trans("SubscriptionEndDate").'</td><td class="valeur">';
253 if ($fadherent->datefin) {
254 print dol_print_date($fadherent->datefin, 'day');
255 if ($fadherent->hasDelay()) {
256 print " ".img_warning($langs->trans("Late"));
257 }
258 } else {
259 if (!$adht->subscription) {
260 print $langs->trans("SubscriptionNotRecorded");
261 if ($fadherent->statut > 0) {
262 print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled
263 }
264 } else {
265 print $langs->trans("SubscriptionNotReceived");
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 }
270 }
271 print '</td></tr>';
272
273 print '</table>';
274 print '</div>';
275 }
276}
277
278// End of page
279llxFooter();
280$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:56
llxFooter()
Empty footer.
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.
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.