dolibarr 21.0.0-beta
document.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2014-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
3 * Copyright (C) 2015-2024 Frédéric 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
43// Load translation files required by the page
44$langs->loadLangs(array('other', 'companies', 'contact'));
45
46// Get parameters
47$id = GETPOSTINT('id');
48$action = GETPOST('action', 'aZ09');
49$confirm = GETPOST('confirm', 'alpha');
50
51$object = new Contact($db);
52
53// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
54$object->getCanvas($id);
55$objcanvas = null;
56$canvas = (!empty($object->canvas) ? $object->canvas : GETPOST("canvas"));
57if (!empty($canvas)) {
58 require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
59 $objcanvas = new Canvas($db, $action);
60 $objcanvas->getCanvas('contact', 'contactcard', $canvas);
61}
62
63// Get parameters
64$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
65$sortfield = GETPOST('sortfield', 'aZ09comma');
66$sortorder = GETPOST('sortorder', 'aZ09comma');
67$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT('page');
68if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
69 // If $page is not defined, or '' or -1 or if we click on clear filters
70 $page = 0;
71}
72$offset = $limit * $page;
73$pageprev = $page - 1;
74$pagenext = $page + 1;
75
76if (getDolGlobalString('MAIN_DOC_SORT_FIELD')) {
77 $sortfield = getDolGlobalString('MAIN_DOC_SORT_FIELD');
78}
79if (getDolGlobalString('MAIN_DOC_SORT_ORDER')) {
80 $sortorder = getDolGlobalString('MAIN_DOC_SORT_ORDER');
81}
82
83if (!$sortorder) {
84 $sortorder = "ASC";
85}
86if (!$sortfield) {
87 $sortfield = "name";
88}
89
90if ($id > 0) {
91 $object->fetch($id);
92}
93
94$upload_dir = $conf->societe->multidir_output[$object->entity].'/contact/'.dol_sanitizeFileName($object->ref);
95$modulepart = 'contact';
96
97// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
98$hookmanager->initHooks(array('contactdocument'));
99
100// Security check
101if ($user->socid) {
102 $socid = $user->socid;
103}
104$result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', 0); // If we create a contact with no company (shared contacts), no check on write permission
105
106$permissiontoadd = $user->hasRight('societe', 'contact', 'creer'); // Used by the include of actions_dellink.inc.php
107
108
109/*
110 * Actions
111 */
112
113include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
114
115
116/*
117 * View
118 */
119
120$form = new Form($db);
121
122$title = $langs->trans("ContactLinkedFiles");
123if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/contactnameonly/', getDolGlobalString('MAIN_HTML_TITLE')) && $object->lastname) {
124 $title = $object->lastname;
125}
126$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
127
128llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-societe page-contact-card_documents');
129
130if ($object->id) {
131 $head = contact_prepare_head($object);
132 $title = (getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
133
134 print dol_get_fiche_head($head, 'documents', $title, -1, 'contact');
135
136
137 // Build file list
138 $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1);
139 $totalsize = 0;
140 foreach ($filearray as $key => $file) {
141 $totalsize += $file['size'];
142 }
143
144 $linkback = '<a href="'.DOL_URL_ROOT.'/contact/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
145
146 $morehtmlref = '<a href="'.DOL_URL_ROOT.'/contact/vcard.php?id='.$object->id.'" class="refid">';
147 $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
148 $morehtmlref .= '</a>';
149
150 $morehtmlref .= '<div class="refidno">';
151 if (!getDolGlobalString('SOCIETE_DISABLE_CONTACTS')) {
152 $objsoc = new Societe($db);
153 $objsoc->fetch($object->socid);
154 // Thirdparty
155 if ($objsoc->id > 0) {
156 $morehtmlref .= $objsoc->getNomUrl(1);
157 } else {
158 $morehtmlref .= '<span class="opacitymedium">'.$langs->trans("ContactNotLinkedToCompany").'</span>';
159 }
160 }
161 $morehtmlref .= '</div>';
162
163 dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref);
164
165 print '<div class="fichecenter">';
166
167 print '<div class="underbanner clearboth"></div>';
168 print '<table class="border tableforfield centpercent">';
169
170 // Company
171 /*
172 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
173 {
174 if ($object->socid > 0)
175 {
176 $objsoc = new Societe($db);
177 $objsoc->fetch($object->socid);
178
179 print '<tr><td>'.$langs->trans("ThirdParty").'</td><td colspan="3">'.$objsoc->getNomUrl(1).'</td></tr>';
180 }
181
182 else
183 {
184 print '<tr><td>'.$langs->trans("ThirdParty").'</td><td colspan="3">';
185 print $langs->trans("ContactNotLinkedToCompany");
186 print '</td></tr>';
187 }
188 }*/
189
190 // Civility
191 print '<tr><td class="titlefield">'.$langs->trans("UserTitle").'</td><td colspan="3">';
192 print $object->getCivilityLabel();
193 print '</td></tr>';
194
195 print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
196 print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize, 1, 1).'</td></tr>';
197 print '</table>';
198
199 print '</div>';
200
201 print dol_get_fiche_end();
202
203 $modulepart = 'contact';
204 $permissiontoadd = $user->hasRight('societe', 'contact', 'creer');
205 $permtoedit = $user->hasRight('societe', 'contact', 'creer');
206 $param = '&id='.$object->id;
207 include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
208} else {
209 print $langs->trans("ErrorUnknown");
210}
211
212
213llxFooter();
214
215$db->close();
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
Class to manage canvas.
Class to manage contact/addresses.
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.
llxFooter()
Footer empty.
Definition document.php:107
dol_dir_list($utf8_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:63
dol_print_size($size, $shortvalue=0, $shortunit=0)
Return string with formatted size.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
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 a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
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.