actions_adherentcard_default.class.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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') $out .= (!empty($conf->global->ADHERENT_ADDRESSES_MANAGEMENT) ? $langs->trans("Adherent") : $langs->trans("ContactAddress"));
  59. if ($action == 'edit') $out .= (!empty($conf->global->ADHERENT_ADDRESSES_MANAGEMENT) ? $langs->trans("EditAdherent") : $langs->trans("EditAdherentAddress"));
  60. if ($action == 'create') $out .= (!empty($conf->global->ADHERENT_ADDRESSES_MANAGEMENT) ? $langs->trans("NewAdherent") : $langs->trans("NewAdherentAddress"));
  61. return $out;
  62. }
  63. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
  64. /**
  65. * Assign custom values for canvas
  66. *
  67. * @param string $action Type of action
  68. * @param int $id Id
  69. * @return void
  70. */
  71. public function assign_values(&$action, $id)
  72. {
  73. // phpcs:enable
  74. global $limit, $offset, $sortfield, $sortorder;
  75. global $conf, $db, $langs, $user;
  76. global $form;
  77. $ret = $this->getObject($id);
  78. parent::assign_values($action, $id);
  79. $this->tpl['title'] = $this->getTitle($action);
  80. $this->tpl['error'] = $this->error;
  81. $this->tpl['errors'] = $this->errors;
  82. if ($action == 'view')
  83. {
  84. // Card header
  85. $head = member_prepare_head($this->object);
  86. $title = $this->getTitle($action);
  87. $this->tpl['showhead'] = dol_get_fiche_head($head, 'card', $title, 0, 'adherent');
  88. $this->tpl['showend'] = dol_get_fiche_end();
  89. $objsoc = new Societe($db);
  90. $objsoc->fetch($this->object->socid);
  91. $this->tpl['actionstodo'] = show_actions_todo($conf, $langs, $db, $objsoc, $this->object, 1);
  92. $this->tpl['actionsdone'] = show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1);
  93. }
  94. else
  95. {
  96. // Confirm delete contact
  97. if ($action == 'delete' && $user->rights->adherent->supprimer)
  98. {
  99. $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("DeleteAdherent"), $langs->trans("ConfirmDeleteAdherent"), "confirm_delete", '', 0, 1);
  100. }
  101. }
  102. if ($action == 'list')
  103. {
  104. $this->LoadListDatas($limit, $offset, $sortfield, $sortorder);
  105. }
  106. }
  107. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
  108. /**
  109. * Fetch datas list and save into ->list_datas
  110. *
  111. * @param int $limit Limit number of responses
  112. * @param int $offset Offset for first response
  113. * @param string $sortfield Sort field
  114. * @param string $sortorder Sort order ('ASC' or 'DESC')
  115. * @return void
  116. */
  117. public function LoadListDatas($limit, $offset, $sortfield, $sortorder)
  118. {
  119. // phpcs:enable
  120. global $conf, $langs;
  121. //$this->getFieldList();
  122. $this->list_datas = array();
  123. }
  124. }