dolibarr  16.0.5
contact.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2003 Brian Fraval <brian@fraval.org>
4  * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
5  * Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
6  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
7  * Copyright (C) 2008 Patrick Raguin <patrick.raguin@auguria.net>
8  * Copyright (C) 2010-2016 Juanjo Menent <jmenent@2byte.es>
9  * Copyright (C) 2011-2013 Alexandre Spangaro <aspangaro@open-dsi.fr>
10  * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
11  * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
12  * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
13  *
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program. If not, see <https://www.gnu.org/licenses/>.
26  */
27 
34 require '../main.inc.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
39 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
40 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
41 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
42 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
43 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
44 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
45 if (!empty($conf->adherent->enabled)) {
46  require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
47 }
48 
49 $langs->loadLangs(array("companies", "commercial", "bills", "banks", "users"));
50 if (!empty($conf->categorie->enabled)) {
51  $langs->load("categories");
52 }
53 if (!empty($conf->incoterm->enabled)) {
54  $langs->load("incoterm");
55 }
56 if (!empty($conf->notification->enabled)) {
57  $langs->load("mails");
58 }
59 
60 $mesg = ''; $error = 0; $errors = array();
61 
62 $action = (GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view');
63 $cancel = GETPOST('cancel', 'alpha');
64 $backtopage = GETPOST('backtopage', 'alpha');
65 $confirm = GETPOST('confirm');
66 $socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int');
67 if ($user->socid) {
68  $socid = $user->socid;
69 }
70 if (empty($socid) && $action == 'view') {
71  $action = 'create';
72 }
73 
74 $object = new Societe($db);
75 $extrafields = new ExtraFields($db);
76 
77 // fetch optionals attributes and labels
78 $extrafields->fetch_name_optionals_label($object->table_element);
79 
80 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
81 $hookmanager->initHooks(array('thirdpartycontact', 'globalcard'));
82 
83 if ($object->fetch($socid) <= 0 && $action == 'view') {
84  $langs->load("errors");
85  print($langs->trans('ErrorRecordNotFound'));
86  exit;
87 }
88 
89 // Get object canvas (By default, this is not defined, so standard usage of dolibarr)
90 $canvas = $object->canvas ? $object->canvas : GETPOST("canvas");
91 $objcanvas = null;
92 if (!empty($canvas)) {
93  require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
94  $objcanvas = new Canvas($db, $action);
95  $objcanvas->getCanvas('thirdparty', 'card', $canvas);
96 }
97 
98 // Security check
99 $result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', 0);
100 if (empty($user->rights->societe->contact->lire)) {
101  accessforbidden();
102 }
103 
104 
105 /*
106  * Actions
107  */
108 
109 $parameters = array('id'=>$socid, 'objcanvas'=>$objcanvas);
110 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
111 if ($reshook < 0) {
112  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
113 }
114 
115 if (empty($reshook)) {
116  if ($cancel) {
117  $action = '';
118  if (!empty($backtopage)) {
119  header("Location: ".$backtopage);
120  exit;
121  }
122  }
123 
124  // Selection of new fields
125  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
126 }
127 
128 
129 /*
130  * View
131  */
132 
133 $form = new Form($db);
134 $formfile = new FormFile($db);
135 $formadmin = new FormAdmin($db);
136 $formcompany = new FormCompany($db);
137 
138 if ($socid > 0 && empty($object->id)) {
139  $result = $object->fetch($socid);
140  if ($result <= 0) {
141  dol_print_error('', $object->error);
142  }
143 }
144 
145 $title = $langs->trans("ThirdParty");
146 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
147  $title = $object->name." - ".$langs->trans('ContactsAddresses');
148 }
149 $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
150 llxHeader('', $title, $help_url);
151 
152 $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
153 
154 
155 if (!empty($object->id)) {
156  $res = $object->fetch_optionals();
157 }
158 //if ($res < 0) { dol_print_error($db); exit; }
159 
160 
161 $head = societe_prepare_head($object);
162 
163 print dol_get_fiche_head($head, 'contact', $langs->trans("ThirdParty"), 0, 'company');
164 
165 $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
166 
167 dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom');
168 
169 print dol_get_fiche_end();
170 
171 print '<br>';
172 
173 if ($action != 'presend') {
174  // Contacts list
175  if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
176  $result = show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id, 1);
177  }
178 }
179 
180 // End of page
181 llxFooter();
182 $db->close();
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:48
restrictedArea
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
Definition: security.lib.php:234
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
FormAdmin
Class to generate html code for admin pages.
Definition: html.formadmin.class.php:30
dol_banner_tab
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
Definition: functions.lib.php:2046
$help_url
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:116
FormCompany
Class to build HTML component for third parties management Only common components are here.
Definition: html.formcompany.class.php:40
FormFile
Class to offer components to list and upload files.
Definition: html.formfile.class.php:36
show_contacts
show_contacts($conf, $langs, $db, $object, $backtopage='', $showuserlogin=0)
Show html area for list of contacts.
Definition: company.lib.php:907
Canvas
Class to manage canvas.
Definition: canvas.class.php:29
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:1822
societe_prepare_head
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
Definition: company.lib.php:42
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
ExtraFields
Class to manage standard extra fields.
Definition: extrafields.class.php:39
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59