dolibarr 24.0.0-beta
partnership_card.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017-2021 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2021 NextGestion <contact@nextgestion.com>
4 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
5 * Copyright (C) 2024-2025 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.formcompany.class.php';
38require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
39require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
40require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php';
41require_once DOL_DOCUMENT_ROOT.'/partnership/lib/partnership.lib.php';
42
43// Load translation files required by the page
44$langs->loadLangs(array("partnership", "other"));
45
46// Get parameters
47$id = GETPOSTINT('id');
48$ref = GETPOST('ref', 'alpha');
49$action = GETPOST('action', 'aZ09');
50$confirm = GETPOST('confirm', 'alpha');
51$cancel = GETPOST('cancel');
52$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
53$backtopage = GETPOST('backtopage', 'alpha');
54$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
55$lineid = GETPOSTINT('lineid');
56$dol_openinpopup = GETPOST('dol_openinpopup', 'aZ09');
57
58// Initialize a technical objects
60$extrafields = new ExtraFields($db);
61$diroutputmassaction = $conf->partnership->dir_output.'/temp/massgeneration/'.$user->id;
62$hookmanager->initHooks(array('partnershipcard', 'globalcard')); // Note that conf->hooks_modules contains array
63
64// Fetch optionals attributes and labels
65$extrafields->fetch_name_optionals_label($object->table_element);
66
67$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
68
69// Initialize array of search criteria
70$search_all = GETPOST("search_all", 'alpha');
71$search = array();
72
73foreach ($object->fields as $key => $val) {
74 if (GETPOST('search_'.$key, 'alpha')) {
75 $search[$key] = GETPOST('search_'.$key, 'alpha');
76 }
77}
78
79if (empty($action) && empty($id) && empty($ref)) {
80 $action = 'view';
81}
82
83// Load object
84include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'.
85
86
87$permissiontoread = $user->hasRight('partnership', 'read');
88$permissiontoadd = $user->hasRight('partnership', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
89$permissiontodelete = $user->hasRight('partnership', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
90$permissionnote = $user->hasRight('partnership', 'write'); // Used by the include of actions_setnotes.inc.php
91$permissiondellink = $user->hasRight('partnership', 'write'); // Used by the include of actions_dellink.inc.php
92$upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1];
93$managedfor = getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty');
94
95// Security check (enable the most restrictive one)
96//if ($user->socid > 0) accessforbidden();
97//if ($user->socid > 0) $socid = $user->socid;
98//$isdraft = (isset($object->status) && ($object->status == $object::STATUS_DRAFT) ? 1 : 0);
99//restrictedArea($user, $object->module, $object->id, $object->table_element, $object->element, 'fk_soc', 'rowid', $isdraft);
100if (!isModEnabled('partnership')) {
102}
103if (!$permissiontoread) {
105}
106if ($object->id > 0 && !($object->fk_member > 0) && $managedfor == 'member') {
108}
109if ($object->id > 0 && !($object->fk_soc > 0) && $managedfor == 'thirdparty') {
111}
112
113
114/*
115 * Actions
116 */
117
118$parameters = array();
119$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
120if ($reshook < 0) {
121 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
122}
123
124if (empty($reshook)) {
125 $error = 0;
126
127 $backurlforlist = dol_buildpath('/partnership/partnership_list.php', 1);
128
129 if (empty($backtopage) || ($cancel && empty($id))) {
130 if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
131 if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
132 $backtopage = $backurlforlist;
133 } else {
134 $backtopage = dol_buildpath('/partnership/partnership_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
135 }
136 }
137 }
138
139 $fk_partner = ($managedfor == 'member') ? GETPOSTINT('fk_member') : GETPOSTINT('fk_soc');
140 $obj_partner = ($managedfor == 'member') ? $object->fk_member : $object->fk_soc;
141
142 $triggermodname = 'PARTNERSHIP_MODIFY'; // Name of trigger action code to execute when we modify record
143
144 // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
145 include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
146
147 // Action accept object
148 if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd) {
149 $result = $object->validate($user);
150 if ($result >= 0) {
151 // Define output language
152 if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
153 $outputlangs = $langs;
154 $newlang = '';
155 if (getDolGlobalInt('MAIN_MULTILANGS') /* && empty($newlang) */ && GETPOST('lang_id', 'aZ09')) {
156 $newlang = GETPOST('lang_id', 'aZ09');
157 }
158 if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
159 $newlang = $object->thirdparty->default_lang;
160 }
161 if (!empty($newlang)) {
162 $outputlangs = new Translate("", $conf);
163 $outputlangs->setDefaultLang($newlang);
164 }
165
166 $ret = $object->fetch($id); // Reload to get new records
167
168 $model = $object->model_pdf;
169
170 $retgen = $object->generateDocument($model, $outputlangs, 0, 0, 0);
171 if ($retgen < 0) {
172 setEventMessages($object->error, $object->errors, 'warnings');
173 }
174 }
175 } else {
176 setEventMessages($object->error, $object->errors, 'errors');
177 }
178 } elseif ($action == 'confirm_accept' && $confirm == 'yes' && $permissiontoadd) {
179 $result = $object->approve($user);
180 if ($result >= 0) {
181 // Define output language
182 if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
183 $outputlangs = $langs;
184 $newlang = '';
185 if (getDolGlobalInt('MAIN_MULTILANGS') /* && empty($newlang) */ && GETPOST('lang_id', 'aZ09')) {
186 $newlang = GETPOST('lang_id', 'aZ09');
187 }
188 if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
189 $newlang = $object->thirdparty->default_lang;
190 }
191 if (!empty($newlang)) {
192 $outputlangs = new Translate("", $conf);
193 $outputlangs->setDefaultLang($newlang);
194 }
195
196 $ret = $object->fetch($id); // Reload to get new records
197
198 $model = $object->model_pdf;
199
200 $retgen = $object->generateDocument($model, $outputlangs, 0, 0, 0);
201 if ($retgen < 0) {
202 setEventMessages($object->error, $object->errors, 'warnings');
203 }
204 }
205 } else {
206 setEventMessages($object->error, $object->errors, 'errors');
207 }
208 } elseif ($action == 'confirm_refuse' && $permissiontoadd && !GETPOST('cancel', 'alpha')) {
209 // Close proposal
210 if (!(GETPOST('reason_decline_or_cancel', 'alpha'))) {
211 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Refuse")), null, 'errors');
212 $action = 'refuse';
213 } else {
214 // prevent browser refresh from closing proposal several times
215 if ($object->status != $object::STATUS_REFUSED) {
216 $db->begin();
217
218 $result = $object->refused($user, GETPOST('reason_decline_or_cancel', 'restricthtml'));
219 if ($result < 0) {
220 setEventMessages($object->error, $object->errors, 'errors');
221 $error++;
222 } else {
223 $object->reason_decline_or_cancel = GETPOST('reason_decline_or_cancel', 'restricthtml');
224 }
225
226 if (!$error) {
227 $db->commit();
228 } else {
229 $db->rollback();
230 }
231 }
232 }
233 }
234 // Actions when linking object each other
235 include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
236
237 // Actions when printing a doc from card
238 include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
239
240 // Action to move up and down lines of object
241 //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
242
243 // Action to build doc
244 include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
245
246 if ($action == 'set_thirdparty' && $permissiontoadd) {
247 $object->setValueFrom('fk_soc', GETPOSTINT('fk_soc'), '', null, 'date', '', $user, $triggermodname);
248 }
249 if ($action == 'classin' && $permissiontoadd) {
250 $object->setProject(GETPOSTINT('projectid'));
251 }
252
253 // Actions to send emails
254 $triggersendname = 'PARTNERSHIP_SENTBYMAIL';
255 $autocopy = 'MAIN_MAIL_AUTOCOPY_PARTNERSHIP_TO';
256 $trackid = 'pship'.$object->id;
257 include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
258
259 if (!empty($id) && !empty(GETPOST('confirm'))) {
260 header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
261 exit;
262 }
263}
264
265if ($object->id > 0 && $object->status == $object::STATUS_REFUSED) {
266 $object->fields['reason_decline_or_cancel']['visible'] = 3;
267}
268
269
270
271/*
272 * View
273 */
274
275$form = new Form($db);
276$formfile = new FormFile($db);
277$formproject = new FormProjets($db);
278
279$title = $langs->trans("Partnership");
280$help_url = '';
281llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-partnership page-card');
282
283// Part to create
284if ($action == 'create') {
285 if (empty($permissiontoadd)) {
286 accessforbidden('NotEnoughPermissions', 0, 1);
287 }
288
289 print load_fiche_titre($langs->trans("NewPartnership"), '', 'object_'.$object->picto);
290
291 print '<form method="POST" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
292 print '<input type="hidden" name="token" value="'.newToken().'">';
293 print '<input type="hidden" name="action" value="add">';
294 if ($backtopage) {
295 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
296 }
297 if ($backtopageforcancel) {
298 print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
299 }
300
301 print dol_get_fiche_head(array(), '');
302
303 print '<table class="border centpercent tableforfieldcreate">'."\n";
304
305 // Common attributes
306 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php';
307
308 // Other attributes
309 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
310
311 print '</table>'."\n";
312
313 print dol_get_fiche_end();
314
315 print $form->buttonsSaveCancel("Create");
316
317 print '</form>';
318
319 //dol_set_focus('input[name="ref"]');
320}
321
322// Part to edit record
323if (($id || $ref) && $action == 'edit') {
324 print load_fiche_titre($langs->trans("Partnership"), '', 'object_'.$object->picto);
325
326 print '<form method="POST" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
327 print '<input type="hidden" name="token" value="'.newToken().'">';
328 print '<input type="hidden" name="action" value="update">';
329 print '<input type="hidden" name="id" value="'.$object->id.'">';
330 if ($backtopage) {
331 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
332 }
333 if ($backtopageforcancel) {
334 print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
335 }
336
337 print dol_get_fiche_head();
338
339 print '<table class="border centpercent tableforfieldedit">'."\n";
340
341 // Common attributes
342 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php';
343
344 // Other attributes
345 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
346
347 print '</table>';
348
349 print dol_get_fiche_end();
350
351 print $form->buttonsSaveCancel();
352
353 print '</form>';
354}
355
356// Part to show record
357if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
358 $head = partnershipPrepareHead($object);
359
360 print dol_get_fiche_head($head, 'card', $langs->trans("Partnership"), -1, $object->picto);
361
362 $formconfirm = '';
363
364 // Confirmation to delete
365 if ($action == 'delete') {
366 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeletePartnership'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
367 }
368 // Confirmation to delete line
369 if ($action == 'deleteline') {
370 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
371 }
372 // Clone confirmation
373 if ($action == 'clone') {
374 // Create an array for form
375 $formquestion = array();
376 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
377 }
378 // Close confirmation
379 if ($action == 'close') {
380 // Create an array for form
381 $formquestion = array();
382 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClose'), $langs->trans('ConfirmClosePartnershipAsk', $object->ref), 'confirm_close', $formquestion, 'yes', 1);
383 }
384 // Reopon confirmation
385 if ($action == 'reopen') {
386 // Create an array for form
387 $formquestion = array();
388 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('PartnershipToReopen'), $langs->trans('PartnershipConfirmReOpenAsk', $object->ref), 'confirm_reopen', $formquestion, 'yes', 1);
389 }
390
391 // Refuse confirmation
392 if ($action == 'refuse') {
393 //Form to close proposal (signed or not)
394 $formquestion = array(
395 array('type' => 'text', 'name' => 'reason_decline_or_cancel', 'label' => $langs->trans("Note"), 'morecss' => 'reason_decline_or_cancel minwidth400', 'value' => '') // Field to complete private note (not replace)
396 );
397
398 // if (isModEnabled('notification')) {
399 // require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';
400 // $notify = new Notify($db);
401 // $formquestion = array_merge($formquestion, array(
402 // array('type' => 'onecolumn', 'value' => $notify->confirmMessage('PARTNERSHIP_CLOSE_DENY', $object->socid, $object)),
403 // ));
404 // }
405
406 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToRefuse'), '', 'confirm_refuse', $formquestion, '', 1, 250);
407 }
408
409 // Call Hook formConfirm
410 $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
411 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
412 if (empty($reshook)) {
413 $formconfirm .= $hookmanager->resPrint;
414 } elseif ($reshook > 0) {
415 $formconfirm = $hookmanager->resPrint;
416 }
417
418 // Print form confirm
419 print $formconfirm;
420
421
422 // Object card
423 // ------------------------------------------------------------
424 $linkback = '<a href="'.dol_buildpath('/partnership/partnership_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
425
426 $morehtmlref = '<div class="refidno">';
427 $morehtmlref .= '</div>';
428
429 if ($managedfor == 'member') {
430 $object->next_prev_filter = "te.fk_member:>:0"; // usf filter
431 } else {
432 $object->next_prev_filter = "te.fk_soc:>:0"; // usf filter
433 }
434
435 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
436
437
438 print '<div class="fichecenter">';
439 print '<div class="fichehalfleft">';
440 print '<div class="underbanner clearboth"></div>';
441 print '<table class="border centpercent tableforfield">'."\n";
442
443 // Common attributes
444 //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field
445 unset($object->fields['fk_member']); // Hide field already shown later
446 unset($object->fields['fk_soc']); // Hide field already shown later
447 include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
448
449 // End of subscription date
450 if ($managedfor == 'thirdparty' && isModEnabled('societe')) {
451 print '<tr><td class="titlefieldmiddle">'.$langs->trans("ThirdParty").'</td><td class="valeur">';
452 print $object->thirdparty->getNomUrl(-1);
453 print '</td></tr>';
454
455 if (isModEnabled('member')) {
456 include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
457 include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
458 $fadherent = new Adherent($db);
459 $fadherent->fetch(0, '', $object->fk_soc);
460 print '<tr><td>'.$langs->trans("Member").'</td><td class="valeur">';
461 if ($fadherent->id > 0) {
462 print $fadherent->getNomUrl(-1);
463 }
464 print '</td></tr>';
465
466 if ($fadherent->id > 0) {
467 print '<tr><td>'.$langs->trans("SubscriptionEndDate").'</td><td class="valeur">';
468 if ($fadherent->datefin) {
469 print dol_print_date($fadherent->datefin, 'day');
470 if ($fadherent->hasDelay()) {
471 print " ".img_warning($langs->trans("Late"));
472 }
473 } else {
474 $adht = new AdherentType($db);
475 $adht->fetch($fadherent->typeid);
476 if (!$adht->subscription) {
477 print $langs->trans("SubscriptionNotRecorded");
478 if ($fadherent->status > 0) {
479 print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled
480 }
481 } else {
482 print $langs->trans("SubscriptionNotReceived");
483 if ($fadherent->status > 0) {
484 print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled
485 }
486 }
487 }
488 print '</td></tr>';
489 }
490 }
491 }
492 if ($managedfor == 'member' && isModEnabled('member') && $object->fk_member > 0) {
493 include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
494 include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
495
496 $fadherent = new Adherent($db);
497 $fadherent->fetch($object->fk_member);
498
499 print '<tr><td class="titlefieldmiddle">'.$langs->trans("Member").'</td><td class="valeur">';
500 print $fadherent->getNomUrl(-1);
501 print '</td></tr>';
502
503 print '<tr><td>'.$langs->trans("SubscriptionEndDate").'</td><td class="valeur">';
504 if ($fadherent->datefin) {
505 print dol_print_date($fadherent->datefin, 'day');
506 if ($fadherent->hasDelay()) {
507 print " ".img_warning($langs->trans("Late"));
508 }
509 } else {
510 $adht = new AdherentType($db);
511 $adht->fetch($fadherent->typeid);
512 if (!$adht->subscription) {
513 print $langs->trans("SubscriptionNotRecorded");
514 if ($fadherent->status > 0) {
515 print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled
516 }
517 } else {
518 print $langs->trans("SubscriptionNotReceived");
519 if ($fadherent->status > 0) {
520 print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled
521 }
522 }
523 }
524 print '</td></tr>';
525 }
526
527 // Other attributes. Fields from hook formObjectOptions and Extrafields.
528 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
529
530 print '</table>';
531 print '</div>';
532 print '</div>';
533
534 print '<div class="clearboth"></div>';
535
536 print dol_get_fiche_end();
537
538
539 /*
540 * Lines
541 */
542
543 if (!empty($object->table_element_line)) {
544 // Show object lines
545 $result = $object->getLinesArray();
546
547 print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '' : '#line_'.GETPOSTINT('lineid')).'" method="POST">
548 <input type="hidden" name="token" value="' . newToken().'">
549 <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
550 <input type="hidden" name="mode" value="">
551 <input type="hidden" name="page_y" value="">
552 <input type="hidden" name="id" value="' . $object->id.'">
553 ';
554
555 if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
556 include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
557 }
558
559 print '<div class="div-table-responsive-no-min">';
560 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
561 print '<table id="tablelines" class="noborder noshadow" width="100%">';
562 }
563
564 if (!empty($object->lines)) {
565 $object->printObjectLines($action, $mysoc, null, GETPOSTINT('lineid'), 1);
566 }
567
568 // Form to add new line
569 if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') {
570 if ($action != 'editline') {
571 // Add products/services form
572
573 $parameters = array();
574 $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
575 if ($reshook < 0) {
576 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
577 }
578 if (empty($reshook)) {
579 $object->formAddObjectLine(1, $mysoc, $soc);
580 }
581 }
582 }
583
584 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
585 print '</table>';
586 }
587 print '</div>';
588
589 print "</form>\n";
590 }
591
592
593 // Buttons for actions
594
595 if ($action != 'presend' && $action != 'editline') {
596 print '<div class="tabsAction">'."\n";
597 $parameters = array();
598 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
599 if ($reshook < 0) {
600 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
601 }
602
603 if (empty($reshook)) {
604 // Send
605 if (empty($user->socid)) {
606 print dolGetButtonAction('', $langs->trans('SendMail'), 'email', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&token='.newToken().'&mode=init#formmailbeforetitle');
607 }
608
609 print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd);
610
611 // Back to draft
612 if ($object->status != $object::STATUS_DRAFT) {
613 print dolGetButtonAction('', $langs->trans('SetToDraft'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes&token='.newToken(), '', $permissiontoadd);
614 }
615
616 // Validate
617 if ($object->status == $object::STATUS_DRAFT) {
618 if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
619 print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes&token='.newToken(), '', $permissiontoadd);
620 } else {
621 $langs->load("errors");
622 print dolGetButtonAction($langs->trans("ErrorAddAtLeastOneLineFirst"), $langs->trans("Validate"), 'default', '#', '', 0);
623 }
624 }
625
626 // Approve
627 if ($object->status == $object::STATUS_VALIDATED) {
628 if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
629 print dolGetButtonAction($langs->trans('Approve'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_accept&confirm=yes&token='.newToken(), '', $permissiontoadd);
630 } else {
631 $langs->load("errors");
632 print dolGetButtonAction($langs->trans("ErrorAddAtLeastOneLineFirst"), $langs->trans("Approved"), 'default', '#', '', 0);
633 }
634 }
635
636 // Cancel
637 if ($permissiontoadd) {
638 if ($object->status == $object::STATUS_APPROVED) {
639 print dolGetButtonAction($langs->trans('Resiliate'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close&token='.newToken(), '', $permissiontoadd);
640 } elseif ($object->status > $object::STATUS_APPROVED) {
641 // print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen&token='.newToken().'">'.$langs->trans("Re-Open").'</a>'."\n";
642 print dolGetButtonAction($langs->trans('Re-Open'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_reopen&confirm=yes&token='.newToken(), '', $permissiontoadd);
643 }
644 }
645
646 // Refuse
647 if ($permissiontoadd) {
648 if ($object->status != $object::STATUS_DRAFT && $object->status != $object::STATUS_APPROVED && $object->status != $object::STATUS_CANCELED && $object->status != $object::STATUS_REFUSED) {
649 print dolGetButtonAction($langs->trans('Refuse'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=refuse&token='.newToken(), '', $permissiontoadd);
650 }
651 }
652
653 // Delete (need delete permission, or if draft, just need create/modify permission)
654 print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete&token='.newToken(), '', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd));
655 }
656 print '</div>'."\n";
657 }
658
659
660 // Select mail models is same action as presend
661 if (GETPOST('modelselected')) {
662 $action = 'presend';
663 }
664
665 if ($action != 'presend') {
666 print '<div class="fichecenter"><div class="fichehalfleft">';
667 print '<a name="builddoc"></a>'; // ancre
668
669 $includedocgeneration = 0;
670
671 // Documents
672 if ($includedocgeneration) {
673 $objref = dol_sanitizeFileName($object->ref);
674 $relativepath = $objref.'/'.$objref.'.pdf';
675 $filedir = $conf->partnership->dir_output.'/'.$object->element.'/'.$objref;
676 $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
677 $genallowed = $permissiontoread; // If you can read, you can build the PDF to read content
678 $delallowed = $permissiontoadd; // If you can create/edit, you can remove a file on card
679 print $formfile->showdocuments('partnership:Partnership', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
680 }
681
682 // Show links to link elements
683 $tmparray = $form->showLinkToObjectBlock($object, array(), array('partnership'), 1);
684 $linktoelem = $tmparray['linktoelem'];
685 $htmltoenteralink = $tmparray['htmltoenteralink'];
686 print $htmltoenteralink;
687
688 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
689
690
691 print '</div><div class="fichehalfright">';
692
693 $MAXEVENT = 10;
694
695 $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/partnership/partnership_agenda.php?id='.$object->id);
696
697 // List of actions on element
698 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
699 $formactions = new FormActions($db);
700 $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter);
701
702 print '</div></div>';
703 }
704
705 //Select mail models is same action as presend
706 if (GETPOST('modelselected')) {
707 $action = 'presend';
708 }
709
710 // Presend form
711 $modelmail = 'partnership_send';
712 $defaulttopic = 'InformationMessage';
713 $diroutput = $conf->partnership->dir_output;
714 $trackid = 'pship'.$object->id;
715
716 include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
717}
718
719// End of page
720llxFooter();
721$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
Class to manage members of a foundation.
Class to manage members type.
Class to manage standard extra fields.
Class to manage building of HTML components.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class to manage building of HTML components.
Class for Partnership.
Class to manage translations.
global $mysoc
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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_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).
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
partnershipPrepareHead($object)
Prepare array of tabs for Partnership.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.