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