dolibarr 19.0.3
document.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
6 * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
7 * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29// Load Dolibarr environment
30require '../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
34require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
35
36
37// Load translation files required by the page
38$langs->loadLangs(array("companies", "other"));
39
40
41// Get parameters
42$action = GETPOST('action', 'aZ09');
43$confirm = GETPOST('confirm');
44$id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'));
45$ref = GETPOST('ref', 'alpha');
46
47$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
48$sortfield = GETPOST('sortfield', 'aZ09comma');
49$sortorder = GETPOST('sortorder', 'aZ09comma');
50$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
51
52if (empty($page) || $page == -1) {
53 $page = 0;
54} // If $page is not defined, or '' or -1
55
56$offset = $limit * $page;
57$pageprev = $page - 1;
58$pagenext = $page + 1;
59
60if (getDolGlobalString('MAIN_DOC_SORT_FIELD')) {
61 $sortfield = $conf->global->MAIN_DOC_SORT_FIELD;
62}
63if (getDolGlobalString('MAIN_DOC_SORT_ORDER')) {
64 $sortorder = $conf->global->MAIN_DOC_SORT_ORDER;
65}
66
67if (!$sortorder) {
68 $sortorder = "ASC";
69}
70if (!$sortfield) {
71 $sortfield = "position_name";
72}
73
74// Initialize objects
75$object = new Societe($db);
76if ($id > 0 || !empty($ref)) {
77 $result = $object->fetch($id, $ref);
78
79 $upload_dir = $conf->societe->multidir_output[$object->entity]."/".$object->id;
80 $courrier_dir = $conf->societe->multidir_output[$object->entity]."/courrier/".get_exdir($object->id, 0, 0, 0, $object, 'thirdparty');
81}
82
83// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
84$hookmanager->initHooks(array('thirdpartydocument', 'globalcard'));
85
86$permissiontoadd = $user->hasRight('societe', 'creer'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
87
88// Security check
89if ($user->socid > 0) {
90 unset($action);
91 $socid = $user->socid;
92}
93$result = restrictedArea($user, 'societe', $object->id, '&societe');
94
95if (empty($object->id)) {
97}
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 = $langs->trans("ThirdParty").' - '.$langs->trans("Files");
114if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
115 $title = $object->name.' - '.$langs->trans("Files");
116}
117$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
118llxHeader('', $title, $help_url);
119
120// Show tabs
121if (isModEnabled('notification')) {
122 $langs->load("mails");
123}
124$head = societe_prepare_head($object);
125
126print dol_get_fiche_head($head, 'document', $langs->trans("ThirdParty"), -1, 'company');
127
128
129// Build file list
130$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1);
131$totalsize = 0;
132foreach ($filearray as $key => $file) {
133 $totalsize += $file['size'];
134}
135
136$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
137
138dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
139
140print '<div class="fichecenter">';
141
142print '<div class="underbanner clearboth"></div>';
143print '<table class="border tableforfield centpercent">';
144
145// Type Prospect/Customer/Supplier
146print '<tr><td class="titlefield">'.$langs->trans('NatureOfThirdParty').'</td><td>';
147print $object->getTypeUrl(1);
148print '</td></tr>';
149
150// Prefix
151if (getDolGlobalString('SOCIETE_USEPREFIX')) { // Old not used prefix field
152 print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
153}
154
155if ($object->client) {
156 print '<tr><td class="titlefield">';
157 print $langs->trans('CustomerCode').'</td><td colspan="3">';
158 print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client));
159 $tmpcheck = $object->check_codeclient();
160 if ($tmpcheck != 0 && $tmpcheck != -5) {
161 print ' <span class="error">('.$langs->trans("WrongCustomerCode").')</span>';
162 }
163 print '</td></tr>';
164}
165
166if ($object->fournisseur) {
167 print '<tr><td class="titlefield">';
168 print $langs->trans('SupplierCode').'</td><td colspan="3">';
169 print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur));
170 $tmpcheck = $object->check_codefournisseur();
171 if ($tmpcheck != 0 && $tmpcheck != -5) {
172 print ' <span class="error">('.$langs->trans("WrongSupplierCode").')</span>';
173 }
174 print '</td></tr>';
175}
176
177// Number of files
178print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
179
180// Total size
181print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize, 1, 1).'</td></tr>';
182
183print '</table>';
184
185print '</div>';
186
187print dol_get_fiche_end();
188
189$modulepart = 'societe';
190$permissiontoadd = $user->hasRight('societe', 'creer');
191$permtoedit = $user->hasRight('societe', 'creer');
192$param = '&id='.$object->id;
193include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
194
195// End of page
196llxFooter();
197$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 generation of HTML components Only common components must be here.
Class to manage third parties objects (customers, suppliers, prospects...)
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
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.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.