dolibarr 19.0.3
document.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2014 Alexandre Spangaro <aspangaro@open-dsi.fr>
3 * Copyright (C) 2015-2021 Frederic France <frederic.france@free.fr>
4 * Copyright (C) 2017 Regis Houssin <regis.houssin@inodbox.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
27// Load Dolibarr environment
28require '../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/contact.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
34
35// Load translation files required by the page
36$langs->loadLangs(array('other', 'companies', 'contact'));
37
38// Get parameters
39$id = GETPOST('id', 'int');
40$action = GETPOST('action', 'aZ09');
41$confirm = GETPOST('confirm', 'alpha');
42
43$object = new Contact($db);
44
45// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
46$object->getCanvas($id);
47$objcanvas = null;
48$canvas = (!empty($object->canvas) ? $object->canvas : GETPOST("canvas"));
49if (!empty($canvas)) {
50 require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
51 $objcanvas = new Canvas($db, $action);
52 $objcanvas->getCanvas('contact', 'contactcard', $canvas);
53}
54
55// Get parameters
56$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
57$sortfield = GETPOST('sortfield', 'aZ09comma');
58$sortorder = GETPOST('sortorder', 'aZ09comma');
59$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
60if (empty($page) || $page == -1) {
61 $page = 0;
62} // If $page is not defined, or '' or -1
63$offset = $limit * $page;
64$pageprev = $page - 1;
65$pagenext = $page + 1;
66
67if (getDolGlobalString('MAIN_DOC_SORT_FIELD')) {
68 $sortfield = $conf->global->MAIN_DOC_SORT_FIELD;
69}
70if (getDolGlobalString('MAIN_DOC_SORT_ORDER')) {
71 $sortorder = $conf->global->MAIN_DOC_SORT_ORDER;
72}
73
74if (!$sortorder) {
75 $sortorder = "ASC";
76}
77if (!$sortfield) {
78 $sortfield = "name";
79}
80
81if ($id > 0) {
82 $object->fetch($id);
83}
84
85$upload_dir = $conf->societe->multidir_output[$object->entity].'/contact/'.dol_sanitizeFileName($object->ref);
86$modulepart = 'contact';
87
88// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
89$hookmanager->initHooks(array('contactdocument'));
90
91// Security check
92if ($user->socid) {
93 $socid = $user->socid;
94}
95$result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', 0); // If we create a contact with no company (shared contacts), no check on write permission
96
97$permissiontoadd = $user->hasRight('societe', 'contact', 'creer'); // Used by the include of actions_dellink.inc.php
98
99
100/*
101 * Actions
102 */
103
104include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
105
106
107/*
108 * View
109 */
110
111$form = new Form($db);
112
113$title = (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
114if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) {
115 $title = $object->lastname;
116}
117$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
118llxHeader('', $title, $help_url);
119
120if ($object->id) {
121 $head = contact_prepare_head($object);
122 $title = (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
123
124 print dol_get_fiche_head($head, 'documents', $title, -1, 'contact');
125
126
127 // Build file list
128 $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1);
129 $totalsize = 0;
130 foreach ($filearray as $key => $file) {
131 $totalsize += $file['size'];
132 }
133
134 $linkback = '<a href="'.DOL_URL_ROOT.'/contact/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
135
136 $morehtmlref = '<a href="'.DOL_URL_ROOT.'/contact/vcard.php?id='.$object->id.'" class="refid">';
137 $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
138 $morehtmlref .= '</a>';
139
140 $morehtmlref .= '<div class="refidno">';
141 if (!getDolGlobalString('SOCIETE_DISABLE_CONTACTS')) {
142 $objsoc = new Societe($db);
143 $objsoc->fetch($object->socid);
144 // Thirdparty
145 if ($objsoc->id > 0) {
146 $morehtmlref .= $objsoc->getNomUrl(1);
147 } else {
148 $morehtmlref .= '<span class="opacitymedium">'.$langs->trans("ContactNotLinkedToCompany").'</span>';
149 }
150 }
151 $morehtmlref .= '</div>';
152
153 dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref);
154
155 print '<div class="fichecenter">';
156
157 print '<div class="underbanner clearboth"></div>';
158 print '<table class="border tableforfield centpercent">';
159
160 // Company
161 /*
162 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
163 {
164 if ($object->socid > 0)
165 {
166 $objsoc = new Societe($db);
167 $objsoc->fetch($object->socid);
168
169 print '<tr><td>'.$langs->trans("ThirdParty").'</td><td colspan="3">'.$objsoc->getNomUrl(1).'</td></tr>';
170 }
171
172 else
173 {
174 print '<tr><td>'.$langs->trans("ThirdParty").'</td><td colspan="3">';
175 print $langs->trans("ContactNotLinkedToCompany");
176 print '</td></tr>';
177 }
178 }*/
179
180 // Civility
181 print '<tr><td class="titlefield">'.$langs->trans("UserTitle").'</td><td colspan="3">';
182 print $object->getCivilityLabel();
183 print '</td></tr>';
184
185 print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
186 print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize, 1, 1).'</td></tr>';
187 print '</table>';
188
189 print '</div>';
190
191 print dol_get_fiche_end();
192
193 $modulepart = 'contact';
194 $permissiontoadd = $user->hasRight('societe', 'contact', 'creer');
195 $permtoedit = $user->hasRight('societe', 'contact', 'creer');
196 $param = '&id='.$object->id;
197 include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
198} else {
199 print $langs->trans("ErrorUnknown");
200}
201
202
203llxFooter();
204
205$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class to manage canvas.
Class to manage generation of HTML components Only common components must be here.
Class to manage third parties objects (customers, suppliers, prospects...)
contact_prepare_head(Contact $object)
Prepare array with list of tabs.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:62
dol_print_size($size, $shortvalue=0, $shortunit=0)
Return string with formated size.
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.
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
restrictedArea(User $user, $features, $object=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.
Contact()
Old copy.
Definition index.php:572