dolibarr 21.0.0-alpha
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 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
30// Load Dolibarr environment
31require '../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
34require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
35require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
36
37
38// Load translation files required by the page
39$langs->loadLangs(array("companies", "other"));
40
41
42// Get parameters
43$action = GETPOST('action', 'aZ09');
44$confirm = GETPOST('confirm');
45$id = (GETPOSTINT('socid') ? GETPOSTINT('socid') : GETPOSTINT('id'));
46$ref = GETPOST('ref', 'alpha');
47
48$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
49$sortfield = GETPOST('sortfield', 'aZ09comma');
50$sortorder = GETPOST('sortorder', 'aZ09comma');
51$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
52
53if (empty($page) || $page == -1) {
54 $page = 0;
55} // If $page is not defined, or '' or -1
56
57$offset = $limit * $page;
58$pageprev = $page - 1;
59$pagenext = $page + 1;
60
61if (getDolGlobalString('MAIN_DOC_SORT_FIELD')) {
62 $sortfield = getDolGlobalString('MAIN_DOC_SORT_FIELD');
63}
64if (getDolGlobalString('MAIN_DOC_SORT_ORDER')) {
65 $sortorder = getDolGlobalString('MAIN_DOC_SORT_ORDER');
66}
67
68if (!$sortorder) {
69 $sortorder = "ASC";
70}
71if (!$sortfield) {
72 $sortfield = "position_name";
73}
74
75// Initialize objects
76$object = new Societe($db);
77if ($id > 0 || !empty($ref)) {
78 $result = $object->fetch($id, $ref);
79
80 $upload_dir = $conf->societe->multidir_output[$object->entity]."/".$object->id;
81 $courrier_dir = $conf->societe->multidir_output[$object->entity]."/courrier/".get_exdir($object->id, 0, 0, 0, $object, 'thirdparty');
82}
83
84// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
85$hookmanager->initHooks(array('thirdpartydocument', 'globalcard'));
86
87$permissiontoadd = $user->hasRight('societe', 'creer'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
88
89// Security check
90if ($user->socid > 0) {
91 unset($action);
92 $socid = $user->socid;
93}
94$result = restrictedArea($user, 'societe', $object->id, '&societe');
95
96if (empty($object->id)) {
98}
99
100
101/*
102 * Actions
103 */
104
105include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
106
107
108/*
109 * View
110 */
111
112$form = new Form($db);
113
114$title = $langs->trans("ThirdParty").' - '.$langs->trans("Files");
115if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/', getDolGlobalString('MAIN_HTML_TITLE')) && $object->name) {
116 $title = $object->name.' - '.$langs->trans("Files");
117}
118$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
119llxHeader('', $title, $help_url);
120
121// Show tabs
122$head = societe_prepare_head($object);
123
124print dol_get_fiche_head($head, 'document', $langs->trans("ThirdParty"), -1, 'company');
125
126
127// Build file list
128$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1);
129$totalsize = 0;
130foreach ($filearray as $key => $file) {
131 $totalsize += $file['size'];
132}
133
134$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
135
136dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
137
138print '<div class="fichecenter">';
139
140print '<div class="underbanner clearboth"></div>';
141print '<table class="border tableforfield centpercent">';
142
143// Type Prospect/Customer/Supplier
144print '<tr><td class="titlefield">'.$langs->trans('NatureOfThirdParty').'</td><td>';
145print $object->getTypeUrl(1);
146print '</td></tr>';
147
148// Prefix
149if (getDolGlobalString('SOCIETE_USEPREFIX')) { // Old not used prefix field
150 print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
151}
152
153if ($object->client) {
154 print '<tr><td class="titlefield">';
155 print $langs->trans('CustomerCode').'</td><td colspan="3">';
157 $tmpcheck = $object->check_codeclient();
158 if ($tmpcheck != 0 && $tmpcheck != -5) {
159 print ' <span class="error">('.$langs->trans("WrongCustomerCode").')</span>';
160 }
161 print '</td></tr>';
162}
163
164if ($object->fournisseur) {
165 print '<tr><td class="titlefield">';
166 print $langs->trans('SupplierCode').'</td><td colspan="3">';
168 $tmpcheck = $object->check_codefournisseur();
169 if ($tmpcheck != 0 && $tmpcheck != -5) {
170 print ' <span class="error">('.$langs->trans("WrongSupplierCode").')</span>';
171 }
172 print '</td></tr>';
173}
174
175// Number of files
176print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
177
178// Total size
179print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize, 1, 1).'</td></tr>';
180
181print '</table>';
182
183print '</div>';
184
185print dol_get_fiche_end();
186
187$modulepart = 'societe';
188$permissiontoadd = $user->hasRight('societe', 'creer');
189$permtoedit = $user->hasRight('societe', 'creer');
190$param = '&id='.$object->id;
191include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
192
193// End of page
194llxFooter();
195$db->close();
$id
Definition account.php:39
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
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:70
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.
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.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
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.
getDolGlobalString($key, $default='')
Return a 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.