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