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