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