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