dolibarr 21.0.0-alpha
workstation_document.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2020 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
5 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27// Load Dolibarr environment
28require '../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php';
34require_once DOL_DOCUMENT_ROOT.'/workstation/lib/workstation_workstation.lib.php';
35
36global $conf, $db, $hookmanager, $langs, $user;
37
38// Load translation files required by the page
39$langs->loadLangs(array('companies', 'mails', 'other', 'mrp'));
40
41
42$action = GETPOST('action', 'aZ09');
43$confirm = GETPOST('confirm');
44$id = (GETPOSTINT('socid') ? GETPOSTINT('socid') : GETPOSTINT('id'));
45$ref = GETPOST('ref', 'alpha');
46
47// Get parameters
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");
52if (empty($page) || $page == -1) {
53 $page = 0;
54} // If $page is not defined, or '' or -1
55$offset = $limit * $page;
56$pageprev = $page - 1;
57$pagenext = $page + 1;
58if (!$sortorder) {
59 $sortorder = "ASC";
60}
61if (!$sortfield) {
62 $sortfield = "name";
63}
64//if (! $sortfield) $sortfield="position_name";
65
66// Initialize a technical objects
67$object = new Workstation($db);
68$extrafields = new ExtraFields($db);
69$diroutputmassaction = $conf->workstation->dir_output.'/temp/massgeneration/'.$user->id;
70$hookmanager->initHooks(array('workstationdocument', 'globalcard')); // Note that conf->hooks_modules contains array
71
72// Fetch optionals attributes and labels
73$extrafields->fetch_name_optionals_label($object->table_element);
74
75// Load object
76include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'. Include fetch and fetch_thirdparty but not fetch_optionals
77
78if ($id > 0 || !empty($ref)) {
79 $upload_dir = rtrim(getMultidirOutput($object, '', 1), '/');
80}
81
82// Security check
83$isdraft = 0;
84restrictedArea($user, $object->element, $object->id, $object->table_element, 'workstation', 'fk_soc', 'rowid', $isdraft);
85
86$permissiontoadd = $user->hasRight('workstation', 'workstation', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles
87
88
89/*
90 * Actions
91 */
92
93include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
94
95
96/*
97 * View
98 */
99
100$form = new Form($db);
101
102$title = $langs->trans("Workstation").' - '.$langs->trans("Files");
103
104$help_url = 'EN:Module_Workstation';
105
106llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-workstation page-card_workstation_document');
107
108if ($object->id) {
109 /*
110 * Show tabs
111 */
112 $head = workstationPrepareHead($object);
113
114 print dol_get_fiche_head($head, 'document', $langs->trans("Workstation"), -1, $object->picto);
115
116
117 // Build file list
118 $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1);
119 $totalsize = 0;
120 foreach ($filearray as $key => $file) {
121 $totalsize += $file['size'];
122 }
123
124 // Object card
125 // ------------------------------------------------------------
126 $linkback = '<a href="'.DOL_URL_ROOT.'/workstation/workstation_list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
127
128 $morehtmlref = '<div class="refidno">';
129 /*
130 // Ref customer
131 $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
132 $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
133 // Thirdparty
134 $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
135 // Project
136 if (isModEnabled('project'))
137 {
138 $langs->load("projects");
139 $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
140 if ($permissiontoadd)
141 {
142 if ($action != 'classify')
143 //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token='.newToken().'&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
144 $morehtmlref.=' : ';
145 if ($action == 'classify') {
146 //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
147 $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
148 $morehtmlref.='<input type="hidden" name="action" value="classin">';
149 $morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">';
150 $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
151 $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
152 $morehtmlref.='</form>';
153 } else {
154 $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
155 }
156 } else {
157 if (! empty($object->fk_project)) {
158 $proj = new Project($db);
159 $proj->fetch($object->fk_project);
160 $morehtmlref .= ': '.$proj->getNomUrl();
161 } else {
162 $morehtmlref .= '';
163 }
164 }
165 }*/
166 $morehtmlref .= '</div>';
167
168 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
169
170 print '<div class="fichecenter">';
171
172 print '<div class="underbanner clearboth"></div>';
173 print '<table class="border centpercent tableforfield">';
174
175 // Number of files
176 print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
177
178 // Total size
179 print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
180
181 print '</table>';
182
183 print '</div>';
184
185 print dol_get_fiche_end();
186
187 $modulepart = 'workstation';
188 $param = '&id='.$object->id;
189 //$relativepathwithnofile='workstation/' . dol_sanitizeFileName($object->id).'/';
190 //$relativepathwithnofile = 'workstation/'.dol_sanitizeFileName($object->ref).'/';
191
192 include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
193} else {
194 accessforbidden('', 0, 1);
195}
196
197// End of page
198llxFooter();
199$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 standard extra fields.
Class to manage generation of HTML components Only common components must be here.
Class for Workstation.
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
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.
if(!function_exists( 'utf8_encode')) if(!function_exists('utf8_decode')) if(!function_exists( 'str_starts_with')) if(!function_exists('str_ends_with')) if(!function_exists( 'str_contains')) getMultidirOutput($object, $module='', $forobject=0, $mode='output')
Return the full path of the directory where a module (or an object of a module) stores its files,...
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.
workstationPrepareHead($object)
Prepare array of tabs for Workstation.