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