dolibarr  17.0.3
actions_contactcard_default.class.php
Go to the documentation of this file.
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 
24 include_once DOL_DOCUMENT_ROOT.'/contact/canvas/actions_contactcard_common.class.php';
25 
31 {
41  public function __construct($db, $dirmodule, $targetmodule, $canvas, $card)
42  {
43  $this->db = $db;
44  $this->dirmodule = $dirmodule;
45  $this->targetmodule = $targetmodule;
46  $this->canvas = $canvas;
47  $this->card = $card;
48  }
49 
56  private function getTitle($action)
57  {
58  global $langs, $conf;
59 
60  $out = '';
61 
62  if ($action == 'view') {
63  $out .= (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contact") : $langs->trans("ContactAddress"));
64  }
65  if ($action == 'edit') {
66  $out .= (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("EditContact") : $langs->trans("EditContactAddress"));
67  }
68  if ($action == 'create') {
69  $out .= (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("NewContact") : $langs->trans("NewContactAddress"));
70  }
71 
72  return $out;
73  }
74 
75  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
83  public function assign_values(&$action, $id)
84  {
85  // phpcs:enable
86  global $limit, $offset, $sortfield, $sortorder;
87  global $conf, $db, $langs, $user;
88  global $form;
89 
90  $ret = $this->getObject($id);
91 
92  parent::assign_values($action, $id);
93 
94  $this->tpl['title'] = $this->getTitle($action);
95  $this->tpl['error'] = $this->error;
96  $this->tpl['errors'] = $this->errors;
97 
98  if ($action == 'view') {
99  // Card header
100  $head = contact_prepare_head($this->object);
101  $title = $this->getTitle($action);
102 
103  $this->tpl['showhead'] = dol_get_fiche_head($head, 'card', $title, 0, 'contact');
104  $this->tpl['showend'] = dol_get_fiche_end();
105 
106  $objsoc = new Societe($db);
107  $objsoc->fetch($this->object->socid);
108 
109  $this->tpl['actionstodo'] = show_actions_todo($conf, $langs, $db, $objsoc, $this->object, 1);
110 
111  $this->tpl['actionsdone'] = show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1);
112  } else {
113  // Confirm delete contact
114  if ($action == 'delete' && $user->rights->societe->contact->supprimer) {
115  $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1);
116  }
117  }
118  }
119 }
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:49
db
$conf db
API class for accounts.
Definition: inc.php:41
ActionsContactCardDefault
Classe permettant la gestion des contacts par defaut.
Definition: actions_contactcard_default.class.php:30
show_actions_todo
show_actions_todo($conf, $langs, $db, $filterobj, $objcon='', $noprint=0, $actioncode='')
Show html area with actions to do.
Definition: company.lib.php:1427
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
show_actions_done
show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=0, $actioncode='', $donetodo='done', $filters=array(), $sortfield='a.datep, a.id', $sortorder='DESC', $module='')
Show html area with actions (done or not, ignore the name of function).
Definition: company.lib.php:1458
ActionsContactCardDefault\__construct
__construct($db, $dirmodule, $targetmodule, $canvas, $card)
Constructor.
Definition: actions_contactcard_default.class.php:41
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1858
ActionsContactCardCommon
Classe permettant la gestion des contacts par defaut.
Definition: actions_contactcard_common.class.php:28
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2054
ActionsContactCardDefault\getTitle
getTitle($action)
Return the title of card.
Definition: actions_contactcard_default.class.php:56
ActionsContactCardCommon\getObject
getObject($id)
Get object.
Definition: actions_contactcard_common.class.php:63
contact_prepare_head
contact_prepare_head(Contact $object)
Prepare array with list of tabs.
Definition: contact.lib.php:33
ActionsContactCardDefault\assign_values
assign_values(&$action, $id)
Assign custom values for canvas.
Definition: actions_contactcard_default.class.php:83