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