dolibarr  9.0.0
document.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2014 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
3  * Copyright (C) 2015 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 <http://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 {
48  require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
49  $objcanvas = new Canvas($db, $action);
50  $objcanvas->getCanvas('contact', 'contactcard', $canvas);
51 }
52 
53 // Security check
54 if ($user->societe_id) $socid=$user->societe_id;
55 $result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', $objcanvas); // If we create a contact with no company (shared contacts), no check on write permission
56 
57 // Get parameters
58 $sortfield = GETPOST("sortfield",'alpha');
59 $sortorder = GETPOST("sortorder",'alpha');
60 $page = GETPOST("page",'int');
61 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
62 $offset = $conf->liste_limit * $page;
63 $pageprev = $page - 1;
64 $pagenext = $page + 1;
65 if (! $sortorder) $sortorder="ASC";
66 if (! $sortfield) $sortfield="name";
67 
68 if ($id > 0) $object->fetch($id);
69 
70 $upload_dir = $conf->societe->multidir_output[$object->entity].'/contact/'.dol_sanitizeFileName($object->ref);
71 $modulepart='contact';
72 
73 
74 /*
75  * Actions
76  */
77 
78 include DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
79 
80 
81 /*
82  * View
83  */
84 
85 $form = new Form($db);
86 
87 $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
88 if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/',$conf->global->MAIN_HTML_TITLE) && $object->lastname) $title=$object->lastname;
89 $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
90 llxHeader('', $title, $helpurl);
91 
92 if ($object->id)
93 {
94  $head = contact_prepare_head($object);
95  $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
96 
97  dol_fiche_head($head, 'documents', $title, -1, 'contact');
98 
99 
100  // Build file list
101  $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
102  $totalsize=0;
103  foreach($filearray as $key => $file)
104  {
105  $totalsize+=$file['size'];
106  }
107 
108  $linkback = '<a href="'.DOL_URL_ROOT.'/contact/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
109 
110  $morehtmlref='<div class="refidno">';
111  if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
112  {
113  $objsoc=new Societe($db);
114  $objsoc->fetch($object->socid);
115  // Thirdparty
116  $morehtmlref.=$langs->trans('ThirdParty') . ' : ';
117  if ($objsoc->id > 0) $morehtmlref.=$objsoc->getNomUrl(1);
118  else $morehtmlref.=$langs->trans("ContactNotLinkedToCompany");
119  }
120  $morehtmlref.='</div>';
121 
122  dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref);
123 
124  print '<div class="fichecenter">';
125 
126  print '<div class="underbanner clearboth"></div>';
127  print '<table class="border centpercent">';
128 
129  // Company
130  /*
131  if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
132  {
133  if ($object->socid > 0)
134  {
135  $objsoc = new Societe($db);
136  $objsoc->fetch($object->socid);
137 
138  print '<tr><td>'.$langs->trans("ThirdParty").'</td><td colspan="3">'.$objsoc->getNomUrl(1).'</td></tr>';
139  }
140 
141  else
142  {
143  print '<tr><td>'.$langs->trans("ThirdParty").'</td><td colspan="3">';
144  print $langs->trans("ContactNotLinkedToCompany");
145  print '</td></tr>';
146  }
147  }*/
148 
149  // Civility
150  print '<tr><td class="titlefield">'.$langs->trans("UserTitle").'</td><td colspan="3">';
151  print $object->getCivilityLabel();
152  print '</td></tr>';
153 
154  print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
155  print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize,1,1).'</td></tr>';
156  print '</table>';
157 
158  print '</div>';
159 
160  dol_fiche_end();
161 
162  $modulepart = 'contact';
163  $permission = $user->rights->societe->contact->creer;
164  $permtoedit = $user->rights->societe->contact->creer;
165  $param = '&id=' . $object->id;
166  include DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
167 } else {
168  print $langs->trans("ErrorUnknown");
169 }
170 
171 
172 llxFooter();
173 
174 $db->close();
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
Class to manage canvas.
Class to manage contact/addresses.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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.
Class to manage generation of HTML components Only common components must be here.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_fiche_end($notab=0)
Show tab footer of a card.
contact_prepare_head(Contact $object)
Prepare array with list of tabs.
Definition: contact.lib.php:33
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:59
dol_print_size($size, $shortvalue=0, $shortunit=0)
Return string with formated size.
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
llxFooter()
Footer empty.
Definition: document.php:68
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='')
Show tab header of a card.
if(isset($_GET["hashp"]) &&! defined("NOLOGIN")) if((isset($_GET["modulepart"]) && $_GET["modulepart"]=='medias')) llxHeader()
Header empty.
Definition: document.php:60