dolibarr  16.0.5
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 
26 require '../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/contact.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
32 
33 // Load translation files required by the page
34 $langs->loadLangs(array('other', 'companies', 'contact'));
35 
36 $id = GETPOST('id', 'int');
37 $action = GETPOST('action', 'aZ09');
38 $confirm = GETPOST('confirm', 'alpha');
39 
40 $object = new Contact($db);
41 
42 // Get object canvas (By default, this is not defined, so standard usage of dolibarr)
43 $object->getCanvas($id);
44 $objcanvas = null;
45 $canvas = (!empty($object->canvas) ? $object->canvas : GETPOST("canvas"));
46 if (!empty($canvas)) {
47  require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
48  $objcanvas = new Canvas($db, $action);
49  $objcanvas->getCanvas('contact', 'contactcard', $canvas);
50 }
51 
52 // Get parameters
53 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
54 $sortfield = GETPOST('sortfield', 'aZ09comma');
55 $sortorder = GETPOST('sortorder', 'aZ09comma');
56 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
57 if (empty($page) || $page == -1) {
58  $page = 0;
59 } // If $page is not defined, or '' or -1
60 $offset = $limit * $page;
61 $pageprev = $page - 1;
62 $pagenext = $page + 1;
63 
64 if (!empty($conf->global->MAIN_DOC_SORT_FIELD)) {
65  $sortfield = $conf->global->MAIN_DOC_SORT_FIELD;
66 }
67 if (!empty($conf->global->MAIN_DOC_SORT_ORDER)) {
68  $sortorder = $conf->global->MAIN_DOC_SORT_ORDER;
69 }
70 
71 if (!$sortorder) {
72  $sortorder = "ASC";
73 }
74 if (!$sortfield) {
75  $sortfield = "name";
76 }
77 
78 if ($id > 0) {
79  $object->fetch($id);
80 }
81 
82 $upload_dir = $conf->societe->multidir_output[$object->entity].'/contact/'.dol_sanitizeFileName($object->ref);
83 $modulepart = 'contact';
84 
85 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
86 $hookmanager->initHooks(array('contactdocument'));
87 
88 // Security check
89 if ($user->socid) {
90  $socid = $user->socid;
91 }
92 $result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', 0); // If we create a contact with no company (shared contacts), no check on write permission
93 
94 $permissiontoadd = $user->rights->societe->contact->creer; // Used by the include of actions_dellink.inc.php
95 
96 
97 /*
98  * Actions
99  */
100 
101 include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
102 
103 
104 /*
105  * View
106  */
107 
108 $form = new Form($db);
109 
110 $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
111 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) {
112  $title = $object->lastname;
113 }
114 $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
115 llxHeader('', $title, $help_url);
116 
117 if ($object->id) {
118  $head = contact_prepare_head($object);
119  $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
120 
121  print dol_get_fiche_head($head, 'documents', $title, -1, 'contact');
122 
123 
124  // Build file list
125  $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
126  $totalsize = 0;
127  foreach ($filearray as $key => $file) {
128  $totalsize += $file['size'];
129  }
130 
131  $linkback = '<a href="'.DOL_URL_ROOT.'/contact/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
132 
133  $morehtmlref = '<a href="'.DOL_URL_ROOT.'/contact/vcard.php?id='.$object->id.'" class="refid">';
134  $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
135  $morehtmlref .= '</a>';
136 
137  $morehtmlref .= '<div class="refidno">';
138  if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
139  $objsoc = new Societe($db);
140  $objsoc->fetch($object->socid);
141  // Thirdparty
142  $morehtmlref .= $langs->trans('ThirdParty').' : ';
143  if ($objsoc->id > 0) {
144  $morehtmlref .= $objsoc->getNomUrl(1);
145  } else {
146  $morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
147  }
148  }
149  $morehtmlref .= '</div>';
150 
151  dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref);
152 
153  print '<div class="fichecenter">';
154 
155  print '<div class="underbanner clearboth"></div>';
156  print '<table class="border tableforfield centpercent">';
157 
158  // Company
159  /*
160  if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
161  {
162  if ($object->socid > 0)
163  {
164  $objsoc = new Societe($db);
165  $objsoc->fetch($object->socid);
166 
167  print '<tr><td>'.$langs->trans("ThirdParty").'</td><td colspan="3">'.$objsoc->getNomUrl(1).'</td></tr>';
168  }
169 
170  else
171  {
172  print '<tr><td>'.$langs->trans("ThirdParty").'</td><td colspan="3">';
173  print $langs->trans("ContactNotLinkedToCompany");
174  print '</td></tr>';
175  }
176  }*/
177 
178  // Civility
179  print '<tr><td class="titlefield">'.$langs->trans("UserTitle").'</td><td colspan="3">';
180  print $object->getCivilityLabel();
181  print '</td></tr>';
182 
183  print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
184  print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize, 1, 1).'</td></tr>';
185  print '</table>';
186 
187  print '</div>';
188 
189  print dol_get_fiche_end();
190 
191  $modulepart = 'contact';
192  $permissiontoadd = $user->rights->societe->contact->creer;
193  $permtoedit = $user->rights->societe->contact->creer;
194  $param = '&id='.$object->id;
195  include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
196 } else {
197  print $langs->trans("ErrorUnknown");
198 }
199 
200 
201 llxFooter();
202 
203 $db->close();
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:48
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1212
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
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
llxFooter
llxFooter()
Footer empty.
Definition: document.php:89
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
dol_dir_list
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
Definition: files.lib.php:60
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:2032
$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
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3866
llxHeader
if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) if(isset($_GET["hashp"]) &&!defined("NOLOGIN")) if((isset($_GET["modulepart"]) && $_GET["modulepart"]=='medias')) llxHeader()
Header empty.
Definition: document.php:80
Contact
Class to manage contact/addresses.
Definition: contact.class.php:40
dol_print_size
dol_print_size($size, $shortvalue=0, $shortunit=0)
Return string with formated size.
Definition: functions.lib.php:2870
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:1808
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2004
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
contact_prepare_head
contact_prepare_head(Contact $object)
Prepare array with list of tabs.
Definition: contact.lib.php:33