dolibarr  7.0.0-beta
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@capnetworks.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 $langs->load("other");
34 $langs->load("companies");
35 $langs->load("contact");
36 
37 $id = GETPOST('id','int');
38 $action = GETPOST('action','aZ09');
39 $confirm = GETPOST('confirm', 'alpha');
40 
41 $object = new Contact($db);
42 
43 // Get object canvas (By default, this is not defined, so standard usage of dolibarr)
44 $object->getCanvas($id);
45 $objcanvas=null;
46 $canvas = (! empty($object->canvas)?$object->canvas:GETPOST("canvas"));
47 if (! empty($canvas))
48 {
49  require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
50  $objcanvas = new Canvas($db, $action);
51  $objcanvas->getCanvas('contact', 'contactcard', $canvas);
52 }
53 
54 // Security check
55 if ($user->societe_id) $socid=$user->societe_id;
56 $result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', $objcanvas); // If we create a contact with no company (shared contacts), no check on write permission
57 
58 // Get parameters
59 $sortfield = GETPOST("sortfield",'alpha');
60 $sortorder = GETPOST("sortorder",'alpha');
61 $page = GETPOST("page",'int');
62 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
63 $offset = $conf->liste_limit * $page;
64 $pageprev = $page - 1;
65 $pagenext = $page + 1;
66 if (! $sortorder) $sortorder="ASC";
67 if (! $sortfield) $sortfield="name";
68 
69 if ($id > 0) $object->fetch($id);
70 
71 $upload_dir = $conf->societe->multidir_output[$object->entity].'/contact/'.dol_sanitizeFileName($object->ref);
72 $modulepart='contact';
73 
74 
75 /*
76  * Actions
77  */
78 
79 include DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
80 
81 
82 /*
83  * View
84  */
85 
86 $form = new Form($db);
87 
88 $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
89 if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/',$conf->global->MAIN_HTML_TITLE) && $object->lastname) $title=$object->lastname;
90 $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
91 llxHeader('', $title, $helpurl);
92 
93 if ($object->id)
94 {
95  $head = contact_prepare_head($object);
96  $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
97 
98  dol_fiche_head($head, 'documents', $title, -1, 'contact');
99 
100 
101  // Construit liste des fichiers
102  $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
103  $totalsize=0;
104  foreach($filearray as $key => $file)
105  {
106  $totalsize+=$file['size'];
107  }
108 
109  $linkback = '<a href="'.DOL_URL_ROOT.'/contact/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
110 
111  $morehtmlref='<div class="refidno">';
112  if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
113  {
114  $objsoc=new Societe($db);
115  $objsoc->fetch($object->socid);
116  // Thirdparty
117  $morehtmlref.=$langs->trans('ThirdParty') . ' : ';
118  if ($objsoc->id > 0) $morehtmlref.=$objsoc->getNomUrl(1);
119  else $morehtmlref.=$langs->trans("ContactNotLinkedToCompany");
120  }
121  $morehtmlref.='</div>';
122 
123  dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref);
124 
125  print '<div class="fichecenter">';
126 
127  print '<div class="underbanner clearboth"></div>';
128  print '<table class="border centpercent">';
129 
130  // Company
131  /*
132  if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
133  {
134  if ($object->socid > 0)
135  {
136  $objsoc = new Societe($db);
137  $objsoc->fetch($object->socid);
138 
139  print '<tr><td>'.$langs->trans("ThirdParty").'</td><td colspan="3">'.$objsoc->getNomUrl(1).'</td></tr>';
140  }
141 
142  else
143  {
144  print '<tr><td>'.$langs->trans("ThirdParty").'</td><td colspan="3">';
145  print $langs->trans("ContactNotLinkedToCompany");
146  print '</td></tr>';
147  }
148  }*/
149 
150  // Civility
151  print '<tr><td class="titlefield">'.$langs->trans("UserTitle").'</td><td colspan="3">';
152  print $object->getCivilityLabel();
153  print '</td></tr>';
154 
155  print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
156  print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
157  print '</table>';
158 
159  print '</div>';
160 
161  dol_fiche_end();
162 
163  $modulepart = 'contact';
164  $permission = $user->rights->societe->contact->creer;
165  $permtoedit = $user->rights->societe->contact->creer;
166  $param = '&id=' . $object->id;
167  include DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
168 } else {
169  print $langs->trans("ErrorUnknown");
170 }
171 
172 
173 llxFooter();
174 
175 $db->close();
Class to manage canvas.
llxHeader()
Header empty.
Definition: document.php:70
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
Show tab header of a card.
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.
if(empty($reshook)) $form
View.
Definition: perms.php:103
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="")
Scan a directory and return a list of files/directories.
Definition: files.lib.php:58
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage generation of HTML components Only common components must be here.
Class to manage third parties objects (customers, suppliers, prospects...)
if($_POST["cancel"]==$langs->trans("Cancel")&&!$id) if($action== 'setdatev'&&$user->rights->tax->charges->creer) if($action== 'add'&&$_POST["cancel"]<> $langs->trans("Cancel")) if($action== 'delete') $title
Actions.
Definition: card.php:183
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
print
Draft customers invoices.
Definition: index.php:91
llxFooter()
Footer empty.
Definition: document.php:76
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $objcanvas=null)
Check permissions of a user to show a page and an object.