actions_card_individual.class.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. /* Copyright (C) 2010-2011 Regis Houssin <regis.houssin@inodbox.com>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * \file htdocs/societe/canvas/individual/actions_card_individual.class.php
  19. * \ingroup thirdparty
  20. * \brief Fichier de la classe Thirdparty card controller (individual canvas)
  21. */
  22. include_once DOL_DOCUMENT_ROOT.'/societe/canvas/actions_card_common.class.php';
  23. /**
  24. * ActionsCardIndividual
  25. *
  26. * Class with controller methods for individual canvas
  27. */
  28. class ActionsCardIndividual extends ActionsCardCommon
  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 Action code
  51. * @return string Title
  52. */
  53. private function getTitle($action)
  54. {
  55. global $langs;
  56. $out = '';
  57. if ($action == 'view') {
  58. $out .= $langs->trans("Individual");
  59. }
  60. if ($action == 'edit') {
  61. $out .= $langs->trans("EditCompany");
  62. }
  63. if ($action == 'create') {
  64. $out .= $langs->trans("NewCompany");
  65. }
  66. return $out;
  67. }
  68. /**
  69. * Execute actions
  70. * @deprecated Use the doActions of hooks instead of this.
  71. *
  72. * @param string $action Action
  73. * @param int $id Id of object (may be empty for creation)
  74. * @return int <0 if KO, >0 if OK
  75. */
  76. public function doActions(&$action, $id)
  77. {
  78. $ret = $this->getObject($id);
  79. $return = parent::doActions($action);
  80. return $return;
  81. }
  82. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
  83. /**
  84. * Assign custom values for canvas (for example into this->tpl to be used by templates)
  85. *
  86. * @param string $action Type of action
  87. * @param integer $id Id of object
  88. * @param string $ref Ref of object
  89. * @return void
  90. */
  91. public function assign_values(&$action, $id = 0, $ref = '')
  92. {
  93. // phpcs:enable
  94. global $conf, $langs;
  95. global $form, $formcompany;
  96. $ret = $this->getObject($id, $ref);
  97. parent::assign_values($action);
  98. $this->tpl['title'] = load_fiche_titre($this->getTitle($action));
  99. if ($action == 'create' || $action == 'edit') {
  100. $this->tpl['select_civility'] = $formcompany->select_civility(GETPOST('civility_id'));
  101. } else {
  102. // Confirm delete third party
  103. if ($action == 'delete' || $conf->use_javascript_ajax) {
  104. $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$this->object->id, $langs->trans("DeleteAnIndividual"), $langs->trans("ConfirmDeleteIndividual"), "confirm_delete", '', 0, "1,action-delete");
  105. }
  106. }
  107. }
  108. /**
  109. * Check permissions of a user to show a page and an object. Check read permission
  110. * If $_REQUEST['action'] defined, we also check write permission.
  111. *
  112. * @param User $user User to check
  113. * @param string $features Features to check (in most cases, it's module name)
  114. * @param int $objectid Object ID if we want to check permission on a particular record (optional)
  115. * @param string $dbtablename Table name where object is stored. Not used if objectid is null (optional)
  116. * @param string $feature2 Feature to check (second level of permission)
  117. * @param string $dbt_keyfield Field name for socid foreign key if not fk_soc. (optional)
  118. * @param string $dbt_select Field name for select if not rowid. (optional)
  119. * @return int 1
  120. */
  121. public function restrictedArea($user, $features = 'societe', $objectid = 0, $dbtablename = '', $feature2 = '', $dbt_keyfield = 'fk_soc', $dbt_select = 'rowid')
  122. {
  123. return restrictedArea($user, $features, $objectid, $dbtablename, $feature2, $dbt_keyfield, $dbt_select);
  124. }
  125. }