actions_contactcard_default.class.php 3.9 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. *
  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. /**
  19. * \file htdocs/contact/canvas/default/actions_contactcard_default.class.php
  20. * \ingroup thirdparty
  21. * \brief Fichier de la classe Thirdparty contact card controller (default canvas)
  22. */
  23. include_once DOL_DOCUMENT_ROOT.'/contact/canvas/actions_contactcard_common.class.php';
  24. /**
  25. * \class ActionsContactCardDefault
  26. * \brief Classe permettant la gestion des contacts par defaut
  27. */
  28. class ActionsContactCardDefault extends ActionsContactCardCommon
  29. {
  30. /**
  31. * Constructor
  32. *
  33. * @param DoliDB $db Handler acces base de donnees
  34. * @param string $dirmodule Name of directory of module
  35. * @param string $targetmodule Name of directory of module where canvas is stored
  36. * @param string $canvas Name of canvas
  37. * @param string $card Name of tab (sub-canvas)
  38. */
  39. public function __construct($db, $dirmodule, $targetmodule, $canvas, $card)
  40. {
  41. $this->db = $db;
  42. $this->dirmodule = $dirmodule;
  43. $this->targetmodule = $targetmodule;
  44. $this->canvas = $canvas;
  45. $this->card = $card;
  46. }
  47. /**
  48. * Return the title of card
  49. *
  50. * @param string $action Code action
  51. * @return string Title
  52. */
  53. private function getTitle($action)
  54. {
  55. global $langs, $conf;
  56. $out = '';
  57. if ($action == 'view') {
  58. $out .= (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contact") : $langs->trans("ContactAddress"));
  59. }
  60. if ($action == 'edit') {
  61. $out .= (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("EditContact") : $langs->trans("EditContactAddress"));
  62. }
  63. if ($action == 'create') {
  64. $out .= (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("NewContact") : $langs->trans("NewContactAddress"));
  65. }
  66. return $out;
  67. }
  68. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
  69. /**
  70. * Assign custom values for canvas
  71. *
  72. * @param string $action Type of action
  73. * @param int $id Id
  74. * @return void
  75. */
  76. public function assign_values(&$action, $id)
  77. {
  78. // phpcs:enable
  79. global $limit, $offset, $sortfield, $sortorder;
  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 = contact_prepare_head($this->object);
  90. $title = $this->getTitle($action);
  91. $this->tpl['showhead'] = dol_get_fiche_head($head, 'card', $title, 0, 'contact');
  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->rights->societe->contact->supprimer) {
  100. $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1);
  101. }
  102. }
  103. }
  104. }