dolibarr  20.0.0-alpha
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 .= (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("Contact") : $langs->trans("ContactAddress"));
64  }
65  if ($action == 'edit') {
66  $out .= (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("EditContact") : $langs->trans("EditContactAddress"));
67  }
68  if ($action == 'create') {
69  $out .= (getDolGlobalString('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 $conf, $db, $langs, $user;
87  global $form;
88 
89  $ret = $this->getObject($id);
90 
91  parent::assign_values($action, $id);
92 
93  $this->tpl['title'] = $this->getTitle($action);
94  $this->tpl['error'] = $this->error;
95  $this->tpl['errors'] = $this->errors;
96 
97  if ($action == 'view') {
98  // Card header
99  $head = contact_prepare_head($this->object);
100  $title = $this->getTitle($action);
101 
102  $this->tpl['showhead'] = dol_get_fiche_head($head, 'card', $title, 0, 'contact');
103  $this->tpl['showend'] = dol_get_fiche_end();
104 
105  $objsoc = new Societe($db);
106  $objsoc->fetch($this->object->socid);
107 
108  $this->tpl['actionstodo'] = show_actions_todo($conf, $langs, $db, $objsoc, $this->object, 1);
109 
110  $this->tpl['actionsdone'] = show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1);
111  } else {
112  // Confirm delete contact
113  if ($action == 'delete' && $user->hasRight('societe', 'contact', 'supprimer')) {
114  $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1);
115  }
116  }
117  }
118 }
Common Abstract Class for contact managmeent.
Default Class to manage contacts.
getTitle($action)
Return the title of card.
assign_values(&$action, $id)
Assign custom values for canvas.
__construct($db, $dirmodule, $targetmodule, $canvas, $card)
Constructor.
Class to manage third parties objects (customers, suppliers, prospects...)
show_actions_done($conf, $langs, $db, $filterobj, $objcon=null, $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).
show_actions_todo($conf, $langs, $db, $filterobj, $objcon=null, $noprint=0, $actioncode='')
Show html area with actions to do.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
contact_prepare_head(Contact $object)
Prepare array with list of tabs.
Definition: contact.lib.php:33
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.