dolibarr  16.0.5
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 // Get parameters
43 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
44 $sortfield = GETPOST('sortfield', 'aZ09comma');
45 $sortorder = GETPOST('sortorder', 'aZ09comma');
46 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
47 if (empty($page) || $page == -1) {
48  $page = 0;
49 } // If $page is not defined, or '' or -1
50 $offset = $limit * $page;
51 $pageprev = $page - 1;
52 $pagenext = $page + 1;
53 
54 if (!empty($conf->global->MAIN_DOC_SORT_FIELD)) {
55  $sortfield = $conf->global->MAIN_DOC_SORT_FIELD;
56 }
57 if (!empty($conf->global->MAIN_DOC_SORT_ORDER)) {
58  $sortorder = $conf->global->MAIN_DOC_SORT_ORDER;
59 }
60 
61 if (!$sortorder) {
62  $sortorder = "ASC";
63 }
64 if (!$sortfield) {
65  $sortfield = "position_name";
66 }
67 
68 $object = new Societe($db);
69 if ($id > 0 || !empty($ref)) {
70  $result = $object->fetch($id, $ref);
71 
72  $upload_dir = $conf->societe->multidir_output[$object->entity]."/".$object->id;
73  $courrier_dir = $conf->societe->multidir_output[$object->entity]."/courrier/".get_exdir($object->id, 0, 0, 0, $object, 'thirdparty');
74 }
75 
76 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
77 $hookmanager->initHooks(array('thirdpartydocument', 'globalcard'));
78 
79 $permissiontoadd = $user->rights->societe->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
80 
81 // Security check
82 if ($user->socid > 0) {
83  unset($action);
84  $socid = $user->socid;
85 }
86 $result = restrictedArea($user, 'societe', $object->id, '&societe');
87 
88 $permissiontoadd = $user->rights->societe->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles
89 
90 
91 /*
92  * Actions
93  */
94 
95 include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
96 
97 
98 /*
99  * View
100  */
101 
102 $form = new Form($db);
103 
104 $title = $langs->trans("ThirdParty").' - '.$langs->trans("Files");
105 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
106  $title = $object->name.' - '.$langs->trans("Files");
107 }
108 $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
109 llxHeader('', $title, $help_url);
110 
111 if ($object->id) {
112  /*
113  * Show tabs
114  */
115  if (!empty($conf->notification->enabled)) {
116  $langs->load("mails");
117  }
118  $head = societe_prepare_head($object);
119 
120  $form = new Form($db);
121 
122  print dol_get_fiche_head($head, 'document', $langs->trans("ThirdParty"), -1, 'company');
123 
124 
125  // Build file list
126  $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
127  $totalsize = 0;
128  foreach ($filearray as $key => $file) {
129  $totalsize += $file['size'];
130  }
131 
132  $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
133 
134  dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
135 
136  print '<div class="fichecenter">';
137 
138  print '<div class="underbanner clearboth"></div>';
139  print '<table class="border tableforfield centpercent">';
140 
141  // Type Prospect/Customer/Supplier
142  print '<tr><td class="titlefield">'.$langs->trans('NatureOfThirdParty').'</td><td>';
143  print $object->getTypeUrl(1);
144  print '</td></tr>';
145 
146  // Prefix
147  if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
148  print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
149  }
150 
151  if ($object->client) {
152  print '<tr><td class="titlefield">';
153  print $langs->trans('CustomerCode').'</td><td colspan="3">';
154  print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client));
155  $tmpcheck = $object->check_codeclient();
156  if ($tmpcheck != 0 && $tmpcheck != -5) {
157  print ' <span class="error">('.$langs->trans("WrongCustomerCode").')</span>';
158  }
159  print '</td></tr>';
160  }
161 
162  if ($object->fournisseur) {
163  print '<tr><td class="titlefield">';
164  print $langs->trans('SupplierCode').'</td><td colspan="3">';
165  print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur));
166  $tmpcheck = $object->check_codefournisseur();
167  if ($tmpcheck != 0 && $tmpcheck != -5) {
168  print ' <span class="error">('.$langs->trans("WrongSupplierCode").')</span>';
169  }
170  print '</td></tr>';
171  }
172 
173  // Number of files
174  print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
175 
176  // Total size
177  print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.dol_print_size($totalsize, 1, 1).'</td></tr>';
178 
179  print '</table>';
180 
181  print '</div>';
182 
183  print dol_get_fiche_end();
184 
185  $modulepart = 'societe';
186  $permissiontoadd = $user->rights->societe->creer;
187  $permtoedit = $user->rights->societe->creer;
188  $param = '&id='.$object->id;
189  include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
190 } else {
191  accessforbidden('', 0, 0);
192 }
193 
194 // End of page
195 llxFooter();
196 $db->close();
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:48
dol_escape_htmltag
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
Definition: functions.lib.php:1468
restrictedArea
restrictedArea($user, $features, $objectid=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.
Definition: security.lib.php:234
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
llxFooter
llxFooter()
Footer empty.
Definition: document.php:89
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
dol_dir_list
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
dol_banner_tab
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.
Definition: functions.lib.php:2046
$help_url
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:116
llxHeader
if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) if(isset($_GET["hashp"]) &&!defined("NOLOGIN")) if((isset($_GET["modulepart"]) && $_GET["modulepart"]=='medias')) llxHeader()
Header empty.
Definition: document.php:80
get_exdir
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
Definition: functions.lib.php:6549
showValueWithClipboardCPButton
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
Definition: functions.lib.php:11087
dol_print_size
dol_print_size($size, $shortvalue=0, $shortunit=0)
Return string with formated size.
Definition: functions.lib.php:2884
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
societe_prepare_head
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_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
accessforbidden
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 ...
Definition: security.lib.php:933