dolibarr  13.0.2
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 require '../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
34 
35 $langs->loadLangs(array("companies", "other"));
36 
37 $action = GETPOST('action', 'aZ09');
38 $confirm = GETPOST('confirm');
39 $id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'));
40 $ref = GETPOST('ref', 'alpha');
41 
42 // Security check
43 if ($user->socid > 0)
44 {
45  unset($action);
46  $socid = $user->socid;
47 }
48 $result = restrictedArea($user, 'societe', $id, '&societe');
49 
50 // Get parameters
51 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
52 $sortfield = GETPOST("sortfield", 'alpha');
53 $sortorder = GETPOST("sortorder", 'alpha');
54 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
55 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
56 $offset = $limit * $page;
57 $pageprev = $page - 1;
58 $pagenext = $page + 1;
59 
60 if (!empty($conf->global->MAIN_DOC_SORT_FIELD)) { $sortfield = $conf->global->MAIN_DOC_SORT_FIELD; }
61 if (!empty($conf->global->MAIN_DOC_SORT_ORDER)) { $sortorder = $conf->global->MAIN_DOC_SORT_ORDER; }
62 
63 if (!$sortorder) $sortorder = "ASC";
64 if (!$sortfield) $sortfield = "position_name";
65 
66 $object = new Societe($db);
67 if ($id > 0 || !empty($ref))
68 {
69  $result = $object->fetch($id, $ref);
70 
71  $upload_dir = $conf->societe->multidir_output[$object->entity]."/".$object->id;
72  $courrier_dir = $conf->societe->multidir_output[$object->entity]."/courrier/".get_exdir($object->id, 0, 0, 0, $object, 'thirdparty');
73 }
74 
75 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
76 $hookmanager->initHooks(array('thirdpartydocument', 'globalcard'));
77 
78 
79 
80 /*
81  * Actions
82  */
83 
84 include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
85 
86 
87 /*
88  * View
89  */
90 
91 $form = new Form($db);
92 
93 $title = $langs->trans("ThirdParty").' - '.$langs->trans("Files");
94 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name.' - '.$langs->trans("Files");
95 $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
96 llxHeader('', $title, $help_url);
97 
98 if ($object->id)
99 {
100  /*
101  * Show tabs
102  */
103  if (!empty($conf->notification->enabled)) $langs->load("mails");
104  $head = societe_prepare_head($object);
105 
106  $form = new Form($db);
107 
108  print dol_get_fiche_head($head, 'document', $langs->trans("ThirdParty"), -1, 'company');
109 
110 
111  // Build file list
112  $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
113  $totalsize = 0;
114  foreach ($filearray as $key => $file)
115  {
116  $totalsize += $file['size'];
117  }
118 
119  $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
120 
121  dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
122 
123  print '<div class="fichecenter">';
124 
125  print '<div class="underbanner clearboth"></div>';
126  print '<table class="border tableforfield centpercent">';
127 
128  // Prefix
129  if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
130  {
131  print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
132  }
133 
134  if ($object->client)
135  {
136  print '<tr><td class="titlefield">';
137  print $langs->trans('CustomerCode').'</td><td colspan="3">';
138  print $object->code_client;
139  $tmpcheck = $object->check_codeclient();
140  if ($tmpcheck != 0 && $tmpcheck != -5) {
141  print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
142  }
143  print '</td></tr>';
144  }
145 
146  if ($object->fournisseur)
147  {
148  print '<tr><td class="titlefield">';
149  print $langs->trans('SupplierCode').'</td><td colspan="3">';
150  print $object->code_fournisseur;
151  $tmpcheck = $object->check_codefournisseur();
152  if ($tmpcheck != 0 && $tmpcheck != -5) {
153  print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
154  }
155  print '</td></tr>';
156  }
157 
158  // Number of files
159  print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
160 
161  // Total size
162  print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize, 1, 1).'</td></tr>';
163 
164  print '</table>';
165 
166  print '</div>';
167 
169 
170  $modulepart = 'societe';
171  $permission = $user->rights->societe->creer;
172  $permtoedit = $user->rights->societe->creer;
173  $param = '&id='.$object->id;
174  include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
175 } else {
176  accessforbidden('', 0, 0);
177 }
178 
179 // End of page
180 llxFooter();
181 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
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.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
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:60
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
Definition: company.lib.php:42
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Definition: index.php:89
dol_print_size($size, $shortvalue=0, $shortunit=0)
Return string with formated size.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.
llxFooter()
Empty footer.
Definition: wrapper.php:59