actions_adherentcard_default.class.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. /* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
  3. * Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2012-2018 Philippe Grand <philippe.grand@atoo-net.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/adherents/canvas/default/actions_adherentcard_default.class.php
  21. * \ingroup member
  22. * \brief File of class Thirdparty member card controller (default canvas)
  23. */
  24. include_once DOL_DOCUMENT_ROOT.'/adherents/canvas/actions_adherentcard_common.class.php';
  25. /**
  26. * \class ActionsAdherentCardDefault
  27. * \brief Class allowing the management of the members by default
  28. */
  29. class ActionsAdherentCardDefault extends ActionsAdherentCardCommon
  30. {
  31. /**
  32. * Constructor
  33. *
  34. * @param DoliDB $db Handler acces data base
  35. * @param string $dirmodule Name of directory of module
  36. * @param string $targetmodule Name of directory of module where canvas is stored
  37. * @param string $canvas Name of canvas
  38. * @param string $card Name of tab (sub-canvas)
  39. */
  40. public function __construct($db, $dirmodule, $targetmodule, $canvas, $card)
  41. {
  42. $this->db = $db;
  43. $this->dirmodule = $dirmodule;
  44. $this->targetmodule = $targetmodule;
  45. $this->canvas = $canvas;
  46. $this->card = $card;
  47. }
  48. /**
  49. * Return the title of card
  50. *
  51. * @param string $action Action code
  52. * @return string Title
  53. */
  54. private function getTitle($action)
  55. {
  56. global $langs, $conf;
  57. $out = '';
  58. if ($action == 'view') {
  59. $out .= (!empty($conf->global->ADHERENT_ADDRESSES_MANAGEMENT) ? $langs->trans("Adherent") : $langs->trans("ContactAddress"));
  60. }
  61. if ($action == 'edit') {
  62. $out .= (!empty($conf->global->ADHERENT_ADDRESSES_MANAGEMENT) ? $langs->trans("EditAdherent") : $langs->trans("EditAdherentAddress"));
  63. }
  64. if ($action == 'create') {
  65. $out .= (!empty($conf->global->ADHERENT_ADDRESSES_MANAGEMENT) ? $langs->trans("NewAdherent") : $langs->trans("NewAdherentAddress"));
  66. }
  67. return $out;
  68. }
  69. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
  70. /**
  71. * Assign custom values for canvas
  72. *
  73. * @param string $action Type of action
  74. * @param int $id Id
  75. * @return void
  76. */
  77. public function assign_values(&$action, $id)
  78. {
  79. // phpcs:enable
  80. global $conf, $db, $langs, $user;
  81. global $form;
  82. $ret = $this->getObject($id);
  83. parent::assign_values($action, $id);
  84. $this->tpl['title'] = $this->getTitle($action);
  85. $this->tpl['error'] = $this->error;
  86. $this->tpl['errors'] = $this->errors;
  87. if ($action == 'view') {
  88. // Card header
  89. $head = member_prepare_head($this->object);
  90. $title = $this->getTitle($action);
  91. $this->tpl['showhead'] = dol_get_fiche_head($head, 'card', $title, 0, 'adherent');
  92. $this->tpl['showend'] = dol_get_fiche_end();
  93. $objsoc = new Societe($db);
  94. $objsoc->fetch($this->object->socid);
  95. $this->tpl['actionstodo'] = show_actions_todo($conf, $langs, $db, $objsoc, $this->object, 1);
  96. $this->tpl['actionsdone'] = show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1);
  97. } else {
  98. // Confirm delete contact
  99. if ($action == 'delete' && $user->hasRight('adherent', 'supprimer')) {
  100. $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("DeleteAdherent"), $langs->trans("ConfirmDeleteAdherent"), "confirm_delete", '', 0, 1);
  101. }
  102. }
  103. }
  104. }